36 end |
36 end |
37 |
37 |
38 Puppet::Type.newtype(:nis) do |
38 Puppet::Type.newtype(:nis) do |
39 @doc = "Manage the configuration of the NIS client for Oracle Solaris" |
39 @doc = "Manage the configuration of the NIS client for Oracle Solaris" |
40 |
40 |
41 newparam(:domainname) do |
41 newparam(:name) do |
|
42 desc "The symbolic name for the NIS domain and client settings to use. |
|
43 This name is used for human reference only." |
|
44 isnamevar |
|
45 end |
|
46 |
|
47 newproperty(:domainname) do |
42 desc "The NIS domainname" |
48 desc "The NIS domainname" |
43 isnamevar |
|
44 end |
49 end |
45 |
50 |
46 newproperty(:ypservers, :parent => Puppet::Property::List) do |
51 newproperty(:ypservers, :parent => Puppet::Property::List) do |
47 desc "The hosts or IP addresses to use as NIS servers. Specify |
52 desc "The hosts or IP addresses to use as NIS servers. Specify |
48 multiple entries as an array" |
53 multiple entries as an array" |
49 |
54 |
50 # ensure should remains an array |
55 # ensure should remains an array as long as there's more than 1 entry |
51 def should |
56 def should |
52 @should |
57 if @should.length == 1 |
|
58 @should[0] |
|
59 else |
|
60 @should |
|
61 end |
53 end |
62 end |
54 |
63 |
55 def insync?(is) |
64 def insync?(is) |
56 is = [] if is == :absent or is.nil? |
65 is = [] if is == :absent or is.nil? |
57 is.sort == self.should.sort |
66 if should.is_a? Array |
|
67 is.sort == self.should.sort |
|
68 end |
58 end |
69 end |
59 |
70 |
60 # svcprop returns multivalue entries delimited with a space |
71 # svcprop returns multivalue entries delimited with a space |
61 def delimiter |
72 def delimiter |
62 " " |
73 " " |
71 invalid" if not valid_hostname? value |
82 invalid" if not valid_hostname? value |
72 end |
83 end |
73 end |
84 end |
74 end |
85 end |
75 |
86 |
76 newproperty(:securenets, :parent => Puppet::Property::List) do |
87 newproperty(:securenets) do |
77 desc "Entries for /var/yp/securenets. Each entry must be a 2 element |
88 desc "Entries for /var/yp/securenets. Each entry must be a hash. |
78 array. The first element must be either a host or a netmask. |
89 The first element in the hash is either a host or a netmask. |
79 The second element must be an IP network address. Specify |
90 The second element must be an IP network address. Specify |
80 multiple entires as an array of arrays" |
91 multiple entires as separate entries in the hash." |
81 |
|
82 # ensure should remains an array |
|
83 def should |
|
84 @should |
|
85 end |
|
86 |
|
87 def insync?(is) |
|
88 is = [] if is == :absent or is.nil? |
|
89 is.sort == self.should.sort |
|
90 end |
|
91 |
|
92 # svcprop returns multivalue entries delimited with a space |
|
93 def delimiter |
|
94 " " |
|
95 end |
|
96 |
|
97 validate do |value| |
|
98 netmask, network = value |
|
99 # check the netmask |
|
100 begin |
|
101 ip = IPAddr.new(netmask) |
|
102 rescue ArgumentError |
|
103 # the value wasn't a valid IP address, so check the hostname |
|
104 raise Puppet::Error, "securenets entry: #{value} has an |
|
105 invalid netmask" if not valid_hostname? netmask |
|
106 end |
|
107 |
|
108 begin |
|
109 ip = IPAddr.net(network) |
|
110 rescue ArgumentError |
|
111 # the value wasn't a valid IP address |
|
112 raise Puppet::Error, "securenets entry: #{value} has an |
|
113 invalid network" |
|
114 end |
|
115 end |
|
116 end |
92 end |
117 |
93 |
118 newproperty(:use_broadcast) do |
94 newproperty(:use_broadcast) do |
119 desc "Send a broadcast datagram requesting needed bind information for |
95 desc "Send a broadcast datagram requesting needed bind information for |
120 a specific NIS server. Valid vales are true, false" |
96 a specific NIS server. Valid vales are true, false" |