author | Kristina Tripp <Kristina.Tripp@oracle.com> |
Fri, 07 Nov 2014 17:33:48 -0800 | |
branch | s11-update |
changeset 3458 | 4912663e9858 |
parent 3151 | components/puppet/files/solaris/lib/puppet/type/nis.rb@0dbc999aeec2 |
permissions | -rw-r--r-- |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
1 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
2 |
# CDDL HEADER START |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
3 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
4 |
# The contents of this file are subject to the terms of the |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
5 |
# Common Development and Distribution License (the "License"). |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
6 |
# You may not use this file except in compliance with the License. |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
7 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
8 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
9 |
# or http://www.opensolaris.org/os/licensing. |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
10 |
# See the License for the specific language governing permissions |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
11 |
# and limitations under the License. |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
12 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
13 |
# When distributing Covered Code, include this CDDL HEADER in each |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
14 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
15 |
# If applicable, add the following below this CDDL HEADER, with the |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
16 |
# fields enclosed by brackets "[]" replaced with your own identifying |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
17 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
18 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
19 |
# CDDL HEADER END |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
20 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
21 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
22 |
# |
2928
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
23 |
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
24 |
# |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
25 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
26 |
require 'ipaddr' |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
27 |
require 'puppet/property/list' |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
28 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
29 |
def valid_hostname?(hostname) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
30 |
return false if hostname.length > 255 or hostname.scan('..').any? |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
31 |
hostname = hostname[0...-1] if hostname.index('.', -1) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
32 |
return hostname.split('.').collect { |i| |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
33 |
i.size <= 63 and |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
34 |
not (i.rindex('-', 0) or i.index('-', -1) or i.scan(/[^a-z\d-]/i).any?) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
35 |
}.all? |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
36 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
37 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
38 |
Puppet::Type.newtype(:nis) do |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
39 |
@doc = "Manage the configuration of the NIS client for Oracle Solaris" |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
40 |
|
2928
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
41 |
newparam(:name) do |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
42 |
desc "The symbolic name for the NIS domain and client settings to use. |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
43 |
This name is used for human reference only." |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
44 |
isnamevar |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
45 |
end |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
46 |
|
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
47 |
newproperty(:domainname) do |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
48 |
desc "The NIS domainname" |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
49 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
50 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
51 |
newproperty(:ypservers, :parent => Puppet::Property::List) do |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
52 |
desc "The hosts or IP addresses to use as NIS servers. Specify |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
53 |
multiple entries as an array" |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
54 |
|
2928
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
55 |
# ensure should remains an array as long as there's more than 1 entry |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
56 |
def should |
2928
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
57 |
if @should.length == 1 |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
58 |
@should[0] |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
59 |
else |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
60 |
@should |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
61 |
end |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
62 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
63 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
64 |
def insync?(is) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
65 |
is = [] if is == :absent or is.nil? |
2928
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
66 |
if should.is_a? Array |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
67 |
is.sort == self.should.sort |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
68 |
end |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
69 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
70 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
71 |
# svcprop returns multivalue entries delimited with a space |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
72 |
def delimiter |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
73 |
" " |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
74 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
75 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
76 |
validate do |value| |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
77 |
begin |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
78 |
ip = IPAddr.new(value) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
79 |
rescue ArgumentError |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
80 |
# the value wasn't a valid IP address, so check the hostname |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
81 |
raise Puppet::Error, "ypserver entry: #{value} is |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
82 |
invalid" if not valid_hostname? value |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
83 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
84 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
85 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
86 |
|
2928
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
87 |
newproperty(:securenets) do |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
88 |
desc "Entries for /var/yp/securenets. Each entry must be a hash. |
43b3da52b84a
PSARC 2013/426 Puppet 3.4.1
Drew Fisher <drew.fisher@oracle.com>
parents:
2771
diff
changeset
|
89 |
The first element in the hash is either a host or a netmask. |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
90 |
The second element must be an IP network address. Specify |
3151
0dbc999aeec2
18713757 'puppet resource service' outputs incorrect services
Drew Fisher <drew.fisher@oracle.com>
parents:
2928
diff
changeset
|
91 |
multiple entries as separate entries in the hash." |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
92 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
93 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
94 |
newproperty(:use_broadcast) do |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
95 |
desc "Send a broadcast datagram requesting needed bind information for |
3151
0dbc999aeec2
18713757 'puppet resource service' outputs incorrect services
Drew Fisher <drew.fisher@oracle.com>
parents:
2928
diff
changeset
|
96 |
a specific NIS server." |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
97 |
newvalues(:true, :false) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
98 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
99 |
|
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
100 |
newproperty(:use_ypsetme) do |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
101 |
desc "Only allow root on the client to change the binding to a desired |
3151
0dbc999aeec2
18713757 'puppet resource service' outputs incorrect services
Drew Fisher <drew.fisher@oracle.com>
parents:
2928
diff
changeset
|
102 |
server." |
2771
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
103 |
newvalues(:true, :false) |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
104 |
end |
8e4227dc2fc4
16453463 Update Puppet's offerings on Solaris
Virginia Wray <virginia.wray@oracle.com>
parents:
diff
changeset
|
105 |
end |