Class: Packer::Provisioner

Inherits:
DataObject show all
Defined in:
lib/packer/provisioner.rb,
lib/packer/provisioners/file.rb,
lib/packer/provisioners/salt.rb,
lib/packer/provisioners/shell.rb,
lib/packer/provisioners/ansible.rb,
lib/packer/provisioners/chef/solo.rb,
lib/packer/provisioners/powershell.rb,
lib/packer/provisioners/chef/client.rb,
lib/packer/provisioners/puppet/server.rb,
lib/packer/provisioners/windows_shell.rb,
lib/packer/provisioners/windows_restart.rb,
lib/packer/provisioners/puppet/masterless.rb

Defined Under Namespace

Classes: Ansible, Chef, File, Powershell, Puppet, Salt, Shell, UnrecognizedProvisionerTypeError, WindowsRestart, WindowsShell

Constant Summary collapse

SHELL =
'shell'
WINDOWS_SHELL =
'windows-shell'
POWERSHELL =
'powershell'
FILE =
'file'
SALT =
'salt-masterless'
ANSIBLE =
'ansible-local'
CHEF_CLIENT =
'chef-client'
CHEF_SOLO =
'chef-solo'
PUPPET_MASTERLESS =
'puppet-masterless'
PUPPET_SERVER =
'puppet-server'
WINDOWS_RESTART =
'windows-restart'
VALID_PROVISIONER_TYPES =
[
  SHELL,
  WINDOWS_SHELL,
  POWERSHELL,
  FILE,
  SALT,
  ANSIBLE,
  CHEF_CLIENT,
  CHEF_SOLO,
  PUPPET_MASTERLESS,
  PUPPET_SERVER,
  WINDOWS_RESTART
]

Instance Attribute Summary

Attributes inherited from DataObject

#data, #key_dependencies, #required

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataObject

#__add_array_of_array_of_strings, #__add_array_of_hashes, #__add_array_of_ints, #__add_array_of_strings, #__add_boolean, #__add_hash, #__add_integer, #__add_json, #__add_string, #__exclusive_key_error, #add_key_dependencies, #add_required, #deep_copy, #validate, #validate_key_dependencies, #validate_required

Constructor Details

#initializeProvisioner


60
61
62
63
# File 'lib/packer/provisioner.rb', line 60

def initialize
  super
  self.add_required('type')
end

Class Method Details

.get_provisioner(type) ⇒ Object


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/packer/provisioner.rb', line 36

def self.get_provisioner(type)
  unless validate_type(type)
    raise UnrecognizedProvisionerTypeError.new("Unrecognized provisioner type #{type}")
  end

  {
    SHELL             => Packer::Provisioner::Shell,
    WINDOWS_SHELL     => Packer::Provisioner::WindowsShell,
    POWERSHELL        => Packer::Provisioner::Powershell,
    FILE              => Packer::Provisioner::File,
    SALT              => Packer::Provisioner::Salt,
    ANSIBLE           => Packer::Provisioner::Ansible,
    CHEF_CLIENT       => Packer::Provisioner::Chef::Client,
    CHEF_SOLO         => Packer::Provisioner::Chef::Solo,
    PUPPET_MASTERLESS => Packer::Provisioner::Puppet::Masterless,
    PUPPET_SERVER     => Packer::Provisioner::Puppet::Server,
    WINDOWS_RESTART   => Packer::Provisioner::WindowsRestart
  }.fetch(type).new
end

.typesObject


56
57
58
# File 'lib/packer/provisioner.rb', line 56

def self.types
  VALID_PROVISIONER_TYPES
end

Instance Method Details

#except(buildname) ⇒ Object


72
73
74
75
76
77
# File 'lib/packer/provisioner.rb', line 72

def except(buildname)
  unless self.data.key? 'except'
    self.data['except'] = []
  end
  self.data['except'] << buildname.to_s
end

#only(buildname) ⇒ Object


65
66
67
68
69
70
# File 'lib/packer/provisioner.rb', line 65

def only(buildname)
  unless self.data.key? 'only'
    self.data['only'] = []
  end
  self.data['only'] << buildname.to_s
end

#override(builddefinition, values) ⇒ Object

Raises:

  • (TypeError)

83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/packer/provisioner.rb', line 83

def override(builddefinition, values)
  raise TypeError.new() unless values.is_a?(Hash)

  unless self.data.key? 'override'
    self.data['override'] = {}
  end
  if self.data.key? @data['override'][builddefinition]
    self.data['override'][builddefinition].merge! values
  else
    self.data['override'][builddefinition] = values
  end
end

#pause_before(duration) ⇒ Object


79
80
81
# File 'lib/packer/provisioner.rb', line 79

def pause_before(duration)
  self.data["pause_before"] = duration.to_s
end