Puppet Class: powercli

Inherits:
powercli::params
Defined in:
manifests/init.pp

Summary

Class that installs PowerCLI via PowerShell Gallery on a Windows host. Requires PowerShell 5 (default on Windows 2016) or PowerShellCore 6.

Overview

Examples:

Basic usage

# install PowerCLI from PowerShell Gallery
include powercli

Specify vCenter connection settings globally

class { 'powercli':
  vcenter_connection => {
    'server' => 'vcenter.domain.tld',
    'username' => 'user@domain.tld',
    'password' => 'xyz123!',
  }
}

Override config settings

# install PowerCLI from PowerShell Gallery
class { 'powercli':
  config => {
    'ParticipateInCEIP' => {
      value => true,
    },
  }
}

Parameters:

  • config (Optional[Hash]) (defaults to: $powercli::params::config)

    Hash of config settings for PowerCLI that will be used to create new powercli::config instances using create_resources

  • vcenter_connection (Optional[Powercli::Connection]) (defaults to: undef)


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'manifests/init.pp', line 31

class powercli (
  Optional[Powercli::Connection] $vcenter_connection = undef,
  Optional[Hash]                 $config             = $powercli::params::config,
) inherits powercli::params {

  pspackageprovider { 'Nuget':
    ensure => 'present',
  }

  psrepository { 'PSGallery':
    ensure              => present,
    source_location     => 'https://www.powershellgallery.com/api/v2',
    installation_policy => 'trusted',
  }

  package { 'VMware.PowerCLI':
    ensure   => latest,
    provider => 'windowspowershell',
    source   => 'PSGallery',
  }

  if $config != undef {
    create_resources('powercli::config', $config)
  }

  if $vcenter_connection != undef {
    class { 'powercli::vcenter::connection':
      server   => $vcenter_connection['server'],
      username => $vcenter_connection['username'],
      password => $vcenter_connection['password'],
    }
    contain powercli::vcenter::connection
  }
}