bolt 0.21.1 → 0.21.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bolt might be problematic. Click here for more details.

Files changed (105) hide show
  1. checksums.yaml +5 -5
  2. data/lib/bolt/applicator.rb +56 -0
  3. data/lib/bolt/error.rb +6 -0
  4. data/lib/bolt/pal.rb +8 -1
  5. data/lib/bolt/transport/winrm.rb +4 -1
  6. data/lib/bolt/version.rb +1 -1
  7. data/libexec/apply_catalog.rb +61 -0
  8. data/{exe → libexec}/bolt_catalog +0 -0
  9. data/vendored/puppet/lib/puppet/application.rb +8 -1
  10. data/vendored/puppet/lib/puppet/application/device.rb +24 -28
  11. data/vendored/puppet/lib/puppet/application/doc.rb +4 -2
  12. data/vendored/puppet/lib/puppet/configurer/plugin_handler.rb +1 -2
  13. data/vendored/puppet/lib/puppet/datatypes.rb +1 -1
  14. data/vendored/puppet/lib/puppet/defaults.rb +2 -6
  15. data/vendored/puppet/lib/puppet/environments.rb +4 -10
  16. data/vendored/puppet/lib/puppet/error.rb +1 -1
  17. data/vendored/puppet/lib/puppet/etc.rb +4 -5
  18. data/vendored/puppet/lib/puppet/face/config.rb +1 -1
  19. data/vendored/puppet/lib/puppet/face/module/build.rb +5 -55
  20. data/vendored/puppet/lib/puppet/face/module/generate.rb +5 -247
  21. data/vendored/puppet/lib/puppet/gettext/config.rb +28 -5
  22. data/vendored/puppet/lib/puppet/indirector/catalog/compiler.rb +5 -7
  23. data/vendored/puppet/lib/puppet/indirector/rest.rb +7 -56
  24. data/vendored/puppet/lib/puppet/indirector/terminus.rb +1 -1
  25. data/vendored/puppet/lib/puppet/interface.rb +1 -1
  26. data/vendored/puppet/lib/puppet/interface/face_collection.rb +3 -1
  27. data/vendored/puppet/lib/puppet/metatype/manager.rb +2 -2
  28. data/vendored/puppet/lib/puppet/module_tool/applications.rb +0 -1
  29. data/vendored/puppet/lib/puppet/module_tool/applications/application.rb +1 -1
  30. data/vendored/puppet/lib/puppet/network/http/connection.rb +2 -23
  31. data/vendored/puppet/lib/puppet/network/http/factory.rb +2 -6
  32. data/vendored/puppet/lib/puppet/node.rb +1 -2
  33. data/vendored/puppet/lib/puppet/node/environment.rb +5 -1
  34. data/vendored/puppet/lib/puppet/parser/functions.rb +35 -3
  35. data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +12 -0
  36. data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -5
  37. data/vendored/puppet/lib/puppet/pops/model/ast.rb +107 -0
  38. data/vendored/puppet/lib/puppet/pops/model/factory.rb +11 -0
  39. data/vendored/puppet/lib/puppet/pops/model/model_label_provider.rb +2 -0
  40. data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +1519 -1485
  41. data/vendored/puppet/lib/puppet/pops/parser/lexer2.rb +1 -1
  42. data/vendored/puppet/lib/puppet/pops/puppet_stack.rb +1 -1
  43. data/vendored/puppet/lib/puppet/pops/serialization/to_data_converter.rb +1 -1
  44. data/vendored/puppet/lib/puppet/pops/types/p_binary_type.rb +1 -2
  45. data/vendored/puppet/lib/puppet/pops/types/types.rb +1 -24
  46. data/vendored/puppet/lib/puppet/pops/validation/checker4_0.rb +5 -0
  47. data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +31 -4
  48. data/vendored/puppet/lib/puppet/provider.rb +12 -1
  49. data/vendored/puppet/lib/puppet/provider/package/dnf.rb +2 -1
  50. data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +1 -1
  51. data/vendored/puppet/lib/puppet/provider/service/base.rb +1 -1
  52. data/vendored/puppet/lib/puppet/provider/service/systemd.rb +3 -1
  53. data/vendored/puppet/lib/puppet/provider/service/upstart.rb +2 -0
  54. data/vendored/puppet/lib/puppet/reference/configuration.rb +6 -0
  55. data/vendored/puppet/lib/puppet/reports.rb +2 -2
  56. data/vendored/puppet/lib/puppet/resource/status.rb +2 -0
  57. data/vendored/puppet/lib/puppet/resource/type_collection.rb +1 -1
  58. data/vendored/puppet/lib/puppet/rest/client.rb +28 -24
  59. data/vendored/puppet/lib/puppet/rest/response.rb +5 -0
  60. data/vendored/puppet/lib/puppet/rest/route.rb +13 -31
  61. data/vendored/puppet/lib/puppet/rest/routes.rb +65 -5
  62. data/vendored/puppet/lib/puppet/rest/ssl_context.rb +13 -0
  63. data/vendored/puppet/lib/puppet/settings.rb +6 -0
  64. data/vendored/puppet/lib/puppet/settings/config_file.rb +1 -2
  65. data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +5 -1
  66. data/vendored/puppet/lib/puppet/ssl/host.rb +148 -43
  67. data/vendored/puppet/lib/puppet/ssl/oids.rb +1 -1
  68. data/vendored/puppet/lib/puppet/test/test_helper.rb +3 -0
  69. data/vendored/puppet/lib/puppet/transaction/event_manager.rb +3 -1
  70. data/vendored/puppet/lib/puppet/transaction/report.rb +1 -1
  71. data/vendored/puppet/lib/puppet/type.rb +2 -2
  72. data/vendored/puppet/lib/puppet/type/file/content.rb +2 -3
  73. data/vendored/puppet/lib/puppet/type/schedule.rb +33 -84
  74. data/vendored/puppet/lib/puppet/type/user.rb +1 -1
  75. data/vendored/puppet/lib/puppet/util.rb +5 -0
  76. data/vendored/puppet/lib/puppet/util/autoload.rb +39 -31
  77. data/vendored/puppet/lib/puppet/util/character_encoding.rb +0 -22
  78. data/vendored/puppet/lib/puppet/util/command_line.rb +0 -1
  79. data/vendored/puppet/lib/puppet/util/connection.rb +74 -0
  80. data/vendored/puppet/lib/puppet/util/feature.rb +2 -2
  81. data/vendored/puppet/lib/puppet/util/instance_loader.rb +1 -19
  82. data/vendored/puppet/lib/puppet/util/json.rb +0 -8
  83. data/vendored/puppet/lib/puppet/util/log/destinations.rb +1 -1
  84. data/vendored/puppet/lib/puppet/util/network_device/base.rb +1 -1
  85. data/vendored/puppet/lib/puppet/util/platform.rb +3 -0
  86. data/vendored/puppet/lib/puppet/util/rdoc/parser/puppet_parser_core.rb +1 -1
  87. data/vendored/puppet/lib/puppet/util/reference.rb +2 -2
  88. data/vendored/puppet/lib/puppet/util/rubygems.rb +1 -13
  89. data/vendored/puppet/lib/puppet/util/ssl.rb +40 -1
  90. data/vendored/puppet/lib/puppet/util/windows.rb +1 -0
  91. data/vendored/puppet/lib/puppet/util/windows/file.rb +18 -0
  92. data/vendored/puppet/lib/puppet/util/windows/security.rb +26 -14
  93. metadata +8 -73
  94. data/vendored/puppet/lib/puppet/module_tool/applications/builder.rb +0 -152
  95. data/vendored/puppet/lib/puppet/module_tool/skeleton/templates/generator/spec/spec_helper.rb +0 -1
  96. data/vendored/puppet/lib/puppet/provider/mailalias/aliases.rb +0 -50
  97. data/vendored/puppet/lib/puppet/provider/maillist/mailman.rb +0 -108
  98. data/vendored/puppet/lib/puppet/provider/zfs/zfs.rb +0 -108
  99. data/vendored/puppet/lib/puppet/provider/zone/solaris.rb +0 -364
  100. data/vendored/puppet/lib/puppet/provider/zpool/zpool.rb +0 -125
  101. data/vendored/puppet/lib/puppet/type/mailalias.rb +0 -46
  102. data/vendored/puppet/lib/puppet/type/maillist.rb +0 -62
  103. data/vendored/puppet/lib/puppet/type/zfs.rb +0 -154
  104. data/vendored/puppet/lib/puppet/type/zone.rb +0 -382
  105. data/vendored/puppet/lib/puppet/type/zpool.rb +0 -91
@@ -1,125 +0,0 @@
1
- Puppet::Type.type(:zpool).provide(:zpool) do
2
- desc "Provider for zpool."
3
-
4
- commands :zpool => 'zpool'
5
-
6
- #NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
7
- def self.instances
8
- zpool(:list, '-H').split("\n").collect do |line|
9
- name, _size, _alloc, _free, _cap, _health, _altroot = line.split(/\s+/)
10
- new({:name => name, :ensure => :present})
11
- end
12
- end
13
-
14
- def process_zpool_data(pool_array)
15
- if pool_array == []
16
- return Hash.new(:absent)
17
- end
18
- #get the name and get rid of it
19
- pool = Hash.new
20
- pool[:pool] = pool_array[0]
21
- pool_array.shift
22
-
23
- tmp = []
24
-
25
- #order matters here :(
26
- pool_array.reverse_each do |value|
27
- sym = nil
28
- case value
29
- when "spares";
30
- sym = :spare
31
- when "logs";
32
- sym = :log
33
- when /^mirror|^raidz1|^raidz2/;
34
- sym = value =~ /^mirror/ ? :mirror : :raidz
35
- pool[:raid_parity] = "raidz2" if value =~ /^raidz2/
36
- else
37
- tmp << value
38
- sym = :disk if value == pool_array.first
39
- end
40
-
41
- if sym
42
- pool[sym] = pool[sym] ? pool[sym].unshift(tmp.reverse.join(' ')) : [tmp.reverse.join(' ')]
43
- tmp.clear
44
- end
45
- end
46
-
47
- pool
48
- end
49
-
50
- def get_pool_data
51
- # https://docs.oracle.com/cd/E19082-01/817-2271/gbcve/index.html
52
- # we could also use zpool iostat -v mypool for a (little bit) cleaner output
53
- out = execute("zpool status #{@resource[:pool]}", :failonfail => false, :combine => false)
54
- zpool_data = out.lines.select { |line| line.index("\t") == 0 }.collect { |l| l.strip.split("\s")[0] }
55
- zpool_data.shift
56
- zpool_data
57
- end
58
-
59
- def current_pool
60
- @current_pool = process_zpool_data(get_pool_data) unless (defined?(@current_pool) and @current_pool)
61
- @current_pool
62
- end
63
-
64
- def flush
65
- @current_pool= nil
66
- end
67
-
68
- #Adds log and spare
69
- def build_named(name)
70
- if prop = @resource[name.intern]
71
- [name] + prop.collect { |p| p.split(' ') }.flatten
72
- else
73
- []
74
- end
75
- end
76
-
77
- #query for parity and set the right string
78
- def raidzarity
79
- @resource[:raid_parity] ? @resource[:raid_parity] : "raidz1"
80
- end
81
-
82
- #handle mirror or raid
83
- def handle_multi_arrays(prefix, array)
84
- array.collect{ |a| [prefix] + a.split(' ') }.flatten
85
- end
86
-
87
- #builds up the vdevs for create command
88
- def build_vdevs
89
- if disk = @resource[:disk]
90
- disk.collect { |d| d.split(' ') }.flatten
91
- elsif mirror = @resource[:mirror]
92
- handle_multi_arrays("mirror", mirror)
93
- elsif raidz = @resource[:raidz]
94
- handle_multi_arrays(raidzarity, raidz)
95
- end
96
- end
97
-
98
- def create
99
- zpool(*([:create, @resource[:pool]] + build_vdevs + build_named("spare") + build_named("log")))
100
- end
101
-
102
- def destroy
103
- zpool :destroy, @resource[:pool]
104
- end
105
-
106
- def exists?
107
- if current_pool[:pool] == :absent
108
- false
109
- else
110
- true
111
- end
112
- end
113
-
114
- [:disk, :mirror, :raidz, :log, :spare].each do |field|
115
- define_method(field) do
116
- current_pool[field]
117
- end
118
-
119
- define_method(field.to_s + "=") do |should|
120
- self.fail "zpool #{field} can't be changed. should be #{should}, currently is #{current_pool[field]}"
121
- end
122
- end
123
-
124
- end
125
-
@@ -1,46 +0,0 @@
1
- module Puppet
2
- Type.newtype(:mailalias) do
3
- @doc = "Creates an email alias in the local alias database."
4
-
5
- ensurable
6
-
7
- newparam(:name, :namevar => true) do
8
- desc "The alias name."
9
- end
10
-
11
- newproperty(:recipient, :array_matching => :all) do
12
- desc "Where email should be sent. Multiple values
13
- should be specified as an array. The file and the
14
- recipient entries are mutually exclusive."
15
- end
16
-
17
- newproperty(:file) do
18
- desc "A file containing the alias's contents. The file and the
19
- recipient entries are mutually exclusive."
20
-
21
- validate do |value|
22
- unless Puppet::Util.absolute_path?(value)
23
- fail Puppet::Error, _("File paths must be fully qualified, not '%{value}'") % { value: value }
24
- end
25
- end
26
- end
27
-
28
- newproperty(:target) do
29
- desc "The file in which to store the aliases. Only used by
30
- those providers that write to disk."
31
-
32
- defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
33
- @resource.class.defaultprovider.default_target
34
- else
35
- nil
36
- end
37
- }
38
- end
39
-
40
- validate do
41
- if self[:recipient] && self[:file]
42
- self.fail _("You cannot specify both a recipient and a file")
43
- end
44
- end
45
- end
46
- end
@@ -1,62 +0,0 @@
1
- module Puppet
2
- Type.newtype(:maillist) do
3
- @doc = "Manage email lists. This resource type can only create
4
- and remove lists; it cannot currently reconfigure them."
5
-
6
- ensurable do
7
- defaultvalues
8
-
9
- newvalue(:purged) do
10
- provider.purge
11
- end
12
-
13
- def change_to_s(current_value, newvalue)
14
- return _("Purged %{resource}") % { resource: resource } if newvalue == :purged
15
- super
16
- end
17
-
18
- def insync?(is)
19
- return true if is == :absent && should == :purged
20
- super
21
- end
22
- end
23
-
24
- newparam(:name, :namevar => true) do
25
- desc "The name of the email list."
26
- end
27
-
28
- newparam(:description) do
29
- desc "The description of the mailing list."
30
- end
31
-
32
- newparam(:password) do
33
- desc "The admin password."
34
- end
35
-
36
- newparam(:webserver) do
37
- desc "The name of the host providing web archives and the administrative interface."
38
- end
39
-
40
- newparam(:mailserver) do
41
- desc "The name of the host handling email for the list."
42
- end
43
-
44
- newparam(:admin) do
45
- desc "The email address of the administrator."
46
- end
47
-
48
- def generate
49
- if provider.respond_to?(:aliases)
50
- should = self.should(:ensure) || :present
51
- if should == :purged
52
- should = :absent
53
- end
54
- atype = Puppet::Type.type(:mailalias)
55
-
56
- provider.aliases.
57
- reject { |name,recipient| catalog.resource(:mailalias, name) }.
58
- collect { |name,recipient| atype.new(:name => name, :recipient => recipient, :ensure => should) }
59
- end
60
- end
61
- end
62
- end
@@ -1,154 +0,0 @@
1
- module Puppet
2
- Type.newtype(:zfs) do
3
- @doc = "Manage zfs. Create destroy and set properties on zfs instances.
4
-
5
- **Autorequires:** If Puppet is managing the zpool at the root of this zfs
6
- instance, the zfs resource will autorequire it. If Puppet is managing any
7
- parent zfs instances, the zfs resource will autorequire them."
8
-
9
- ensurable
10
-
11
- newparam(:name) do
12
- desc "The full name for this filesystem (including the zpool)."
13
- end
14
-
15
- newproperty(:aclinherit) do
16
- desc "The aclinherit property. Valid values are `discard`, `noallow`, `restricted`, `passthrough`, `passthrough-x`."
17
- end
18
-
19
- newproperty(:aclmode) do
20
- desc "The aclmode property. Valid values are `discard`, `groupmask`, `passthrough`."
21
- end
22
-
23
- newproperty(:acltype) do
24
- desc "The acltype propery. Valid values are 'noacl' and 'posixacl'. Only supported on Linux."
25
- end
26
-
27
- newproperty(:atime) do
28
- desc "The atime property. Valid values are `on`, `off`."
29
- end
30
-
31
- newproperty(:canmount) do
32
- desc "The canmount property. Valid values are `on`, `off`, `noauto`."
33
- end
34
-
35
- newproperty(:checksum) do
36
- desc "The checksum property. Valid values are `on`, `off`, `fletcher2`, `fletcher4`, `sha256`."
37
- end
38
-
39
- newproperty(:compression) do
40
- desc "The compression property. Valid values are `on`, `off`, `lzjb`, `gzip`, `gzip-[1-9]`, `zle`."
41
- end
42
-
43
- newproperty(:copies) do
44
- desc "The copies property. Valid values are `1`, `2`, `3`."
45
- end
46
-
47
- newproperty(:dedup) do
48
- desc "The dedup property. Valid values are `on`, `off`."
49
- end
50
-
51
- newproperty(:devices) do
52
- desc "The devices property. Valid values are `on`, `off`."
53
- end
54
-
55
- newproperty(:exec) do
56
- desc "The exec property. Valid values are `on`, `off`."
57
- end
58
-
59
- newproperty(:logbias) do
60
- desc "The logbias property. Valid values are `latency`, `throughput`."
61
- end
62
-
63
- newproperty(:mountpoint) do
64
- desc "The mountpoint property. Valid values are `<path>`, `legacy`, `none`."
65
- end
66
-
67
- newproperty(:nbmand) do
68
- desc "The nbmand property. Valid values are `on`, `off`."
69
- end
70
-
71
- newproperty(:primarycache) do
72
- desc "The primarycache property. Valid values are `all`, `none`, `metadata`."
73
- end
74
-
75
- newproperty(:quota) do
76
- desc "The quota property. Valid values are `<size>`, `none`."
77
- end
78
-
79
- newproperty(:readonly) do
80
- desc "The readonly property. Valid values are `on`, `off`."
81
- end
82
-
83
- newproperty(:recordsize) do
84
- desc "The recordsize property. Valid values are powers of two between 512 and 128k."
85
- end
86
-
87
- newproperty(:refquota) do
88
- desc "The refquota property. Valid values are `<size>`, `none`."
89
- end
90
-
91
- newproperty(:refreservation) do
92
- desc "The refreservation property. Valid values are `<size>`, `none`."
93
- end
94
-
95
- newproperty(:reservation) do
96
- desc "The reservation property. Valid values are `<size>`, `none`."
97
- end
98
-
99
- newproperty(:secondarycache) do
100
- desc "The secondarycache property. Valid values are `all`, `none`, `metadata`."
101
- end
102
-
103
- newproperty(:setuid) do
104
- desc "The setuid property. Valid values are `on`, `off`."
105
- end
106
-
107
- newproperty(:shareiscsi) do
108
- desc "The shareiscsi property. Valid values are `on`, `off`, `type=<type>`."
109
- end
110
-
111
- newproperty(:sharenfs) do
112
- desc "The sharenfs property. Valid values are `on`, `off`, share(1M) options"
113
- end
114
-
115
- newproperty(:sharesmb) do
116
- desc "The sharesmb property. Valid values are `on`, `off`, sharemgr(1M) options"
117
- end
118
-
119
- newproperty(:snapdir) do
120
- desc "The snapdir property. Valid values are `hidden`, `visible`."
121
- end
122
-
123
- newproperty(:version) do
124
- desc "The version property. Valid values are `1`, `2`, `3`, `4`, `current`."
125
- end
126
-
127
- newproperty(:volsize) do
128
- desc "The volsize property. Valid values are `<size>`"
129
- end
130
-
131
- newproperty(:vscan) do
132
- desc "The vscan property. Valid values are `on`, `off`."
133
- end
134
-
135
- newproperty(:xattr) do
136
- desc "The xattr property. Valid values are `on`, `off`."
137
- end
138
-
139
- newproperty(:zoned) do
140
- desc "The zoned property. Valid values are `on`, `off`."
141
- end
142
-
143
- autorequire(:zpool) do
144
- #strip the zpool off the zfs name and autorequire it
145
- [@parameters[:name].value.split('/')[0]]
146
- end
147
-
148
- autorequire(:zfs) do
149
- #slice and dice, we want all the zfs before this one
150
- names = @parameters[:name].value.split('/')
151
- names.slice(1..-2).inject([]) { |a,v| a << "#{a.last}/#{v}" }.collect { |fs| names[0] + fs }
152
- end
153
- end
154
- end
@@ -1,382 +0,0 @@
1
- require 'puppet/property/list'
2
- Puppet::Type.newtype(:zone) do
3
- @doc = "Manages Solaris zones.
4
-
5
- **Autorequires:** If Puppet is managing the directory specified as the root of
6
- the zone's filesystem (with the `path` attribute), the zone resource will
7
- autorequire that directory."
8
-
9
- module Puppet::Zone
10
- class StateMachine
11
- # A silly little state machine.
12
- def initialize
13
- @state = {}
14
- @sequence = []
15
- @state_aliases = {}
16
- @default = nil
17
- end
18
-
19
- # The order of calling insert_state is important
20
- def insert_state(name, transitions)
21
- @sequence << name
22
- @state[name] = transitions
23
- end
24
-
25
- def alias_state(state, salias)
26
- @state_aliases[state] = salias
27
- end
28
-
29
- def name(n)
30
- @state_aliases[n.to_sym] || n.to_sym
31
- end
32
-
33
- def index(state)
34
- @sequence.index(name(state))
35
- end
36
-
37
- # return all states between fs and ss excluding fs
38
- def sequence(fs, ss)
39
- fi = index(fs)
40
- si= index(ss)
41
- (if fi > si
42
- then @sequence[si .. fi].map{|i| @state[i]}.reverse
43
- else @sequence[fi .. si].map{|i| @state[i]}
44
- end)[1..-1]
45
- end
46
-
47
- def cmp?(a,b)
48
- index(a) < index(b)
49
- end
50
- end
51
- end
52
-
53
- ensurable do
54
- desc "The running state of the zone. The valid states directly reflect
55
- the states that `zoneadm` provides. The states are linear,
56
- in that a zone must be `configured`, then `installed`, and
57
- only then can be `running`. Note also that `halt` is currently
58
- used to stop zones."
59
-
60
- def self.fsm
61
- return @fsm if @fsm
62
- @fsm = Puppet::Zone::StateMachine.new
63
- end
64
-
65
- def self.alias_state(values)
66
- values.each do |k,v|
67
- fsm.alias_state(k,v)
68
- end
69
- end
70
-
71
- def self.seqvalue(name, hash)
72
- fsm.insert_state(name, hash)
73
- self.newvalue name
74
- end
75
-
76
- # This is seq value because the order of declaration is important.
77
- # i.e we go linearly from :absent -> :configured -> :installed -> :running
78
- seqvalue :absent, :down => :destroy
79
- seqvalue :configured, :up => :configure, :down => :uninstall
80
- seqvalue :installed, :up => :install, :down => :stop
81
- seqvalue :running, :up => :start
82
-
83
- alias_state :incomplete => :installed, :ready => :installed, :shutting_down => :running
84
-
85
- defaultto :running
86
-
87
- def self.state_sequence(first, second)
88
- fsm.sequence(first, second)
89
- end
90
-
91
- # Why override it? because property/ensure.rb has a default retrieve method
92
- # that knows only about :present and :absent. That method just calls
93
- # provider.exists? and returns :present if a result was returned.
94
- def retrieve
95
- provider.properties[:ensure]
96
- end
97
-
98
- def provider_sync_send(method)
99
- warned = false
100
- while provider.processing?
101
- next if warned
102
- info _("Waiting for zone to finish processing")
103
- warned = true
104
- sleep 1
105
- end
106
- provider.send(method)
107
- provider.flush()
108
- end
109
-
110
- def sync
111
- method = nil
112
- direction = up? ? :up : :down
113
-
114
- # We need to get the state we're currently in and just call
115
- # everything between it and us.
116
- self.class.state_sequence(self.retrieve, self.should).each do |state|
117
- method = state[direction]
118
- raise Puppet::DevError, _("Cannot move %{direction} from %{name}") % { direction: direction, name: st[:name] } unless method
119
- provider_sync_send(method)
120
- end
121
-
122
- ("zone_#{self.should}").intern
123
- end
124
-
125
- # Are we moving up the property tree?
126
- def up?
127
- self.class.fsm.cmp?(self.retrieve, self.should)
128
- end
129
-
130
- end
131
-
132
- newparam(:name) do
133
- desc "The name of the zone."
134
-
135
- isnamevar
136
- end
137
-
138
- newparam(:id) do
139
- desc "The numerical ID of the zone. This number is autogenerated
140
- and cannot be changed."
141
- end
142
-
143
- newparam(:clone) do
144
- desc "Instead of installing the zone, clone it from another zone.
145
- If the zone root resides on a zfs file system, a snapshot will be
146
- used to create the clone; if it resides on a ufs filesystem, a copy of the
147
- zone will be used. The zone from which you clone must not be running."
148
- end
149
-
150
- newproperty(:ip, :parent => Puppet::Property::List) do
151
- require 'ipaddr'
152
-
153
- desc "The IP address of the zone. IP addresses **must** be specified
154
- with an interface, and may optionally be specified with a default router
155
- (sometimes called a defrouter). The interface, IP address, and default
156
- router should be separated by colons to form a complete IP address string.
157
- For example: `bge0:192.168.178.200` would be a valid IP address string
158
- without a default router, and `bge0:192.168.178.200:192.168.178.1` adds a
159
- default router to it.
160
-
161
- For zones with multiple interfaces, the value of this attribute should be
162
- an array of IP address strings (each of which must include an interface
163
- and may include a default router)."
164
-
165
- # The default action of list should is to lst.join(' '). By specifying
166
- # @should, we ensure the should remains an array. If we override should, we
167
- # should also override insync?() -- property/list.rb
168
- def should
169
- @should
170
- end
171
-
172
- # overridden so that we match with self.should
173
- def insync?(is)
174
- is = [] if !is || is == :absent
175
- is.sort == self.should.sort
176
- end
177
- end
178
-
179
- newproperty(:iptype) do
180
- desc "The IP stack type of the zone."
181
- defaultto :shared
182
- newvalue :shared
183
- newvalue :exclusive
184
- end
185
-
186
- newproperty(:autoboot, :boolean => true) do
187
- desc "Whether the zone should automatically boot."
188
- defaultto true
189
- newvalues(:true, :false)
190
- end
191
-
192
- newproperty(:path) do
193
- desc "The root of the zone's filesystem. Must be a fully qualified
194
- file name. If you include `%s` in the path, then it will be
195
- replaced with the zone's name. Currently, you cannot use
196
- Puppet to move a zone. Consequently this is a readonly property."
197
-
198
- validate do |value|
199
- raise ArgumentError, _("The zone base must be fully qualified") unless value =~ /^\//
200
- end
201
-
202
- munge do |value|
203
- if value =~ /%s/
204
- value % @resource[:name]
205
- else
206
- value
207
- end
208
- end
209
- end
210
-
211
- newproperty(:pool) do
212
- desc "The resource pool for this zone."
213
- end
214
-
215
- newproperty(:shares) do
216
- desc "Number of FSS CPU shares allocated to the zone."
217
- end
218
-
219
- newproperty(:dataset, :parent => Puppet::Property::List ) do
220
- desc "The list of datasets delegated to the non-global zone from the
221
- global zone. All datasets must be zfs filesystem names which are
222
- different from the mountpoint."
223
-
224
- def should
225
- @should
226
- end
227
-
228
- # overridden so that we match with self.should
229
- def insync?(is)
230
- is = [] if !is || is == :absent
231
- is.sort == self.should.sort
232
- end
233
-
234
- validate do |value|
235
- unless value !~ /^\//
236
- raise ArgumentError, _("Datasets must be the name of a zfs filesystem")
237
- end
238
- end
239
- end
240
-
241
- newproperty(:inherit, :parent => Puppet::Property::List) do
242
- desc "The list of directories that the zone inherits from the global
243
- zone. All directories must be fully qualified."
244
-
245
- def should
246
- @should
247
- end
248
-
249
- # overridden so that we match with self.should
250
- def insync?(is)
251
- is = [] if !is || is == :absent
252
- is.sort == self.should.sort
253
- end
254
-
255
- validate do |value|
256
- unless value =~ /^\//
257
- raise ArgumentError, _("Inherited filesystems must be fully qualified")
258
- end
259
- end
260
- end
261
-
262
- # Specify the sysidcfg file. This is pretty hackish, because it's
263
- # only used to boot the zone the very first time.
264
- newparam(:sysidcfg) do
265
- desc %{The text to go into the `sysidcfg` file when the zone is first
266
- booted. The best way is to use a template:
267
-
268
- # $confdir/modules/site/templates/sysidcfg.erb
269
- system_locale=en_US
270
- timezone=GMT
271
- terminal=xterms
272
- security_policy=NONE
273
- root_password=<%= password %>
274
- timeserver=localhost
275
- name_service=DNS {domain_name=<%= domain %> name_server=<%= nameserver %>}
276
- network_interface=primary {hostname=<%= realhostname %>
277
- ip_address=<%= ip %>
278
- netmask=<%= netmask %>
279
- protocol_ipv6=no
280
- default_route=<%= defaultroute %>}
281
- nfs4_domain=dynamic
282
-
283
- And then call that:
284
-
285
- zone { 'myzone':
286
- ip => 'bge0:192.168.0.23',
287
- sysidcfg => template('site/sysidcfg.erb'),
288
- path => '/opt/zones/myzone',
289
- realhostname => 'fully.qualified.domain.name',
290
- }
291
-
292
- The `sysidcfg` only matters on the first booting of the zone,
293
- so Puppet only checks for it at that time.}
294
- end
295
-
296
- newparam(:create_args) do
297
- desc "Arguments to the `zonecfg` create command. This can be used to create branded zones."
298
- end
299
-
300
- newparam(:install_args) do
301
- desc "Arguments to the `zoneadm` install command. This can be used to create branded zones."
302
- end
303
-
304
- newparam(:realhostname) do
305
- desc "The actual hostname of the zone."
306
- end
307
-
308
- # If Puppet is also managing the base dir or its parent dir, list them
309
- # both as prerequisites.
310
- autorequire(:file) do
311
- if @parameters.include? :path
312
- [@parameters[:path].value, ::File.dirname(@parameters[:path].value)]
313
- else
314
- nil
315
- end
316
- end
317
-
318
- # If Puppet is also managing the zfs filesystem which is the zone dataset
319
- # then list it as a prerequisite. Zpool's get autorequired by the zfs
320
- # type. We just need to autorequire the dataset zfs itself as the zfs type
321
- # will autorequire all of the zfs parents and zpool.
322
- autorequire(:zfs) do
323
- # Check if we have datasets in our zone configuration and autorequire each dataset
324
- self[:dataset] if @parameters.include? :dataset
325
- end
326
-
327
- def validate_ip(ip, name)
328
- IPAddr.new(ip) if ip
329
- rescue ArgumentError
330
- self.fail Puppet::Error, _("'%{ip}' is an invalid %{name}") % { ip: ip, name: name }, $!
331
- end
332
-
333
- def validate_exclusive(interface, address, router)
334
- return if !interface.nil? and address.nil?
335
- self.fail _("only interface may be specified when using exclusive IP stack: %{interface}:%{address}") % { interface: interface, address: address }
336
- end
337
- def validate_shared(interface, address, router)
338
- self.fail _("ip must contain interface name and ip address separated by a \":\"") if interface.nil? or address.nil?
339
- [address, router].each do |ip|
340
- validate_ip(address, "IP address") unless ip.nil?
341
- end
342
- end
343
-
344
- validate do
345
- return unless self[:ip]
346
- # self[:ip] reflects the type passed from property:ip.should. If we
347
- # override it and pass @should, then we get an array here back.
348
- self[:ip].each do |ip|
349
- interface, address, router = ip.split(':')
350
- if self[:iptype] == :shared
351
- validate_shared(interface, address, router)
352
- else
353
- validate_exclusive(interface, address, router)
354
- end
355
- end
356
- end
357
-
358
- def retrieve
359
- provider.flush
360
- hash = provider.properties
361
- return setstatus(hash) unless hash.nil? or hash[:ensure] == :absent
362
- # Return all properties as absent.
363
- return Hash[properties.map{|p| [p, :absent]} ]
364
- end
365
-
366
- # Take the results of a listing and set everything appropriately.
367
- def setstatus(hash)
368
- prophash = {}
369
- hash.each do |param, value|
370
- next if param == :name
371
- case self.class.attrtype(param)
372
- when :property
373
- # Only try to provide values for the properties we're managing
374
- prop = self.property(param)
375
- prophash[prop] = value if prop
376
- else
377
- self[param] = value
378
- end
379
- end
380
- prophash
381
- end
382
- end