|
1 Enables puppet provider basic functionality with Solaris 11 zones. Also fixes a bug that |
|
2 was introduced with the putback of 15886 into the puppet gate that prevented |
|
3 zones networking from being created. |
|
4 --- puppet-3.0.1/lib/puppet/provider/zone/solaris.rb.orig 2013-02-15 15:00:38.925896083 -0700 |
|
5 +++ puppet-3.0.1/lib/puppet/provider/zone/solaris.rb 2013-02-15 15:00:48.805231725 -0700 |
|
6 @@ -31,7 +31,7 @@ |
|
7 |
|
8 def multi_conf(name, should, &action) |
|
9 has = properties[name] |
|
10 - has = [] if has == :absent |
|
11 + has = [] if has == :absent or has.nil? |
|
12 rms = has - should |
|
13 adds = should - has |
|
14 (rms.map{|o| action.call(:rm,o)} + adds.map{|o| action.call(:add,o)}).join("\n") |
|
15 @@ -60,12 +60,36 @@ |
|
16 end |
|
17 end |
|
18 |
|
19 + def self.def_net_prop(var, &conf) |
|
20 + define_method(var.to_s) do |v| |
|
21 + o = properties[var] |
|
22 + return '' if o.nil? or o == :absent |
|
23 + o.join(' ') |
|
24 + end |
|
25 + define_method('%s_conf'% var.to_s) do |v| |
|
26 + multi_conf(var, v, &conf) |
|
27 + end |
|
28 + end |
|
29 + |
|
30 def_prop :iptype, "set ip-type=%s" |
|
31 def_prop :autoboot, "set autoboot=%s" |
|
32 def_prop :path, "set zonepath=%s" |
|
33 def_prop :pool, "set pool=%s" |
|
34 def_prop :shares, "add rctl\nset name=zone.cpu-shares\nadd value (priv=privileged,limit=%s,action=none)\nend" |
|
35 |
|
36 + if ['5.11', '5.12'].include? Facter.value(:kernelrelease) |
|
37 + def_net_prop :net_resource do |action, str| |
|
38 + case action |
|
39 + when :add |
|
40 + cmd = [" add anet"] |
|
41 + cmd << "end" |
|
42 + cmd.join("\n") |
|
43 + when :rm |
|
44 + " remove anet" |
|
45 + end |
|
46 + end |
|
47 + end |
|
48 + |
|
49 def_multiprop :ip do |action, str| |
|
50 interface, ip, defrouter = str.split(':') |
|
51 case action |
|
52 @@ -96,20 +120,27 @@ |
|
53 end |
|
54 end |
|
55 |
|
56 - def_multiprop :inherit do |action, str| |
|
57 - case action |
|
58 - when :add; ['add inherit-pkg-dir', "set dir=#{str}",'end'].join("\n") |
|
59 - when :rm; "remove inherit-pkg-dir dir=#{str}" |
|
60 - else self.fail action |
|
61 + if ['5.10'].include? Facter.value(:kernelrelease) |
|
62 + def_multiprop :inherit do |action, str| |
|
63 + case action |
|
64 + when :add; ['add inherit-pkg-dir', "set dir=#{str}",'end'].join("\n") |
|
65 + when :rm; "remove inherit-pkg-dir dir=#{str}" |
|
66 + else self.fail action |
|
67 + end |
|
68 end |
|
69 end |
|
70 |
|
71 def my_properties |
|
72 - [:path, :iptype, :autoboot, :pool, :shares, :ip, :dataset, :inherit] |
|
73 + if ['5.11', '5.12'].include? Facter.value(:kernelrelease) |
|
74 + [:path, :iptype, :autoboot, :pool, :shares, :ip, :dataset, :net_resource] |
|
75 + elsif ['5.10'].include? Facter.value(:kernelrelease) |
|
76 + [:path, :iptype, :autoboot, :pool, :shares, :ip, :dataset, :inherit] |
|
77 + end |
|
78 end |
|
79 |
|
80 # Perform all of our configuration steps. |
|
81 def configure |
|
82 + |
|
83 self.fail "Path is required" unless @resource[:path] |
|
84 arr = ["create -b #{@resource[:create_args]}"] |
|
85 |
|
86 @@ -161,6 +192,14 @@ |
|
87 end |
|
88 |
|
89 def install(dummy_argument=:work_arround_for_ruby_GC_bug) |
|
90 + if ['5.11', '5.12'].include? Facter.value(:kernelrelease) |
|
91 + if !@resource[:install_args] and @resource[:config_profile] |
|
92 + @resource[:install_args] = "-c " + @resource[:config_profile] |
|
93 + else |
|
94 + @resource[:install_args] << "-c " + @resource[:config_profile] |
|
95 + end |
|
96 + end |
|
97 + |
|
98 if @resource[:clone] # TODO: add support for "-s snapshot" |
|
99 zoneadm :clone, @resource[:clone] |
|
100 elsif @resource[:install_args] |
|
101 @@ -183,6 +222,7 @@ |
|
102 end |
|
103 end |
|
104 @property_hash.dup |
|
105 + |
|
106 end |
|
107 |
|
108 # We need a way to test whether a zone is in process. Our 'ensure' |
|
109 @@ -253,6 +293,7 @@ |
|
110 |
|
111 def start |
|
112 # Check the sysidcfg stuff |
|
113 + if ['5.10'].include? Facter.value(:kernelrelease) |
|
114 if cfg = @resource[:sysidcfg] |
|
115 self.fail "Path is required" unless @resource[:path] |
|
116 zoneetc = File.join(@resource[:path], "root", "etc") |
|
117 @@ -273,6 +314,7 @@ |
|
118 end |
|
119 end |
|
120 end |
|
121 + end |
|
122 |
|
123 zoneadm :boot |
|
124 end |
|
125 @@ -300,7 +342,11 @@ |
|
126 end |
|
127 |
|
128 def stop |
|
129 - zoneadm :halt |
|
130 + if ['5.10'].include? Facter.value(:kernelrelease) |
|
131 + execute_zoneadm :halt |
|
132 + elsif ['5.11', '5.12'].include? Facter.value(:kernelrelease) |
|
133 + zoneadm :shutdown |
|
134 + end |
|
135 end |
|
136 |
|
137 def unconfigure |