bolt 0.21.7 → 0.21.8
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.
- checksums.yaml +4 -4
- data/lib/bolt/transport/ssh/connection.rb +4 -5
- data/lib/bolt/transport/ssh.rb +4 -1
- data/lib/bolt/transport/winrm/connection.rb +3 -4
- data/lib/bolt/transport/winrm.rb +4 -1
- data/lib/bolt/version.rb +1 -1
- data/libexec/apply_catalog.rb +10 -2
- data/vendored/puppet/lib/puppet/application/apply.rb +20 -9
- data/vendored/puppet/lib/puppet/application/cert.rb +3 -1
- data/vendored/puppet/lib/puppet/application/device.rb +22 -5
- data/vendored/puppet/lib/puppet/configurer/fact_handler.rb +5 -1
- data/vendored/puppet/lib/puppet/configurer.rb +15 -2
- data/vendored/puppet/lib/puppet/defaults.rb +36 -25
- data/vendored/puppet/lib/puppet/face/certificate.rb +2 -0
- data/vendored/puppet/lib/puppet/feature/base.rb +0 -3
- data/vendored/puppet/lib/puppet/functions/call.rb +37 -0
- data/vendored/puppet/lib/puppet/functions.rb +5 -0
- data/vendored/puppet/lib/puppet/indirector/ldap.rb +6 -0
- data/vendored/puppet/lib/puppet/node/environment.rb +4 -2
- data/vendored/puppet/lib/puppet/parser/scope.rb +2 -2
- data/vendored/puppet/lib/puppet/pops/adapters.rb +14 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/deferred_resolver.rb +128 -0
- data/vendored/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb +4 -1
- data/vendored/puppet/lib/puppet/pops/functions/dispatch.rb +2 -0
- data/vendored/puppet/lib/puppet/pops/issues.rb +9 -1
- data/vendored/puppet/lib/puppet/pops/loader/static_loader.rb +0 -16
- data/vendored/puppet/lib/puppet/pops/loaders.rb +1 -3
- data/vendored/puppet/lib/puppet/pops/parser/eparser.rb +6 -6
- data/vendored/puppet/lib/puppet/pops/pcore.rb +11 -0
- data/vendored/puppet/lib/puppet/pops/types/type_factory.rb +17 -0
- data/vendored/puppet/lib/puppet/pops/validation/tasks_checker.rb +13 -5
- data/vendored/puppet/lib/puppet/pops.rb +1 -0
- data/vendored/puppet/lib/puppet/provider/service/debian.rb +1 -0
- data/vendored/puppet/lib/puppet/provider/service/smf.rb +2 -3
- data/vendored/puppet/lib/puppet/provider/service/upstart.rb +10 -2
- data/vendored/puppet/lib/puppet/ssl/certificate_authority.rb +6 -84
- data/vendored/puppet/lib/puppet/ssl/certificate_request.rb +11 -3
- data/vendored/puppet/lib/puppet/type/file.rb +3 -0
- data/vendored/puppet/lib/puppet/type/user.rb +17 -3
- data/vendored/puppet/lib/puppet/util/autoload.rb +36 -31
- data/vendored/puppet/lib/puppet/util.rb +2 -0
- metadata +3 -43
- data/vendored/puppet/lib/puppet/indirector/node/write_only_yaml.rb +0 -39
- data/vendored/puppet/lib/puppet/provider/augeas/augeas.rb +0 -573
- data/vendored/puppet/lib/puppet/provider/cisco.rb +0 -9
- data/vendored/puppet/lib/puppet/provider/computer/computer.rb +0 -20
- data/vendored/puppet/lib/puppet/provider/host/parsed.rb +0 -46
- data/vendored/puppet/lib/puppet/provider/interface/cisco.rb +0 -27
- data/vendored/puppet/lib/puppet/provider/macauthorization/macauthorization.rb +0 -298
- data/vendored/puppet/lib/puppet/provider/mcx/mcxcontent.rb +0 -173
- data/vendored/puppet/lib/puppet/provider/mount/parsed.rb +0 -282
- data/vendored/puppet/lib/puppet/provider/mount.rb +0 -76
- data/vendored/puppet/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +0 -590
- data/vendored/puppet/lib/puppet/provider/selboolean/getsetsebool.rb +0 -47
- data/vendored/puppet/lib/puppet/provider/selmodule/semodule.rb +0 -140
- data/vendored/puppet/lib/puppet/provider/ssh_authorized_key/parsed.rb +0 -105
- data/vendored/puppet/lib/puppet/provider/sshkey/parsed.rb +0 -50
- data/vendored/puppet/lib/puppet/provider/vlan/cisco.rb +0 -28
- data/vendored/puppet/lib/puppet/provider/yumrepo/inifile.rb +0 -315
- data/vendored/puppet/lib/puppet/type/augeas.rb +0 -211
- data/vendored/puppet/lib/puppet/type/computer.rb +0 -66
- data/vendored/puppet/lib/puppet/type/host.rb +0 -95
- data/vendored/puppet/lib/puppet/type/interface.rb +0 -121
- data/vendored/puppet/lib/puppet/type/k5login.rb +0 -165
- data/vendored/puppet/lib/puppet/type/macauthorization.rb +0 -167
- data/vendored/puppet/lib/puppet/type/mcx.rb +0 -98
- data/vendored/puppet/lib/puppet/type/mount.rb +0 -314
- data/vendored/puppet/lib/puppet/type/router.rb +0 -17
- data/vendored/puppet/lib/puppet/type/scheduled_task.rb +0 -183
- data/vendored/puppet/lib/puppet/type/selboolean.rb +0 -26
- data/vendored/puppet/lib/puppet/type/selmodule.rb +0 -59
- data/vendored/puppet/lib/puppet/type/ssh_authorized_key.rb +0 -143
- data/vendored/puppet/lib/puppet/type/sshkey.rb +0 -83
- data/vendored/puppet/lib/puppet/type/vlan.rb +0 -26
- data/vendored/puppet/lib/puppet/type/yumrepo.rb +0 -430
- data/vendored/puppet/lib/puppet/util/network_device/cisco/device.rb +0 -285
- data/vendored/puppet/lib/puppet/util/network_device/cisco/facts.rb +0 -72
- data/vendored/puppet/lib/puppet/util/network_device/cisco/interface.rb +0 -94
- data/vendored/puppet/lib/puppet/util/network_device/cisco.rb +0 -4
- data/vendored/puppet/lib/puppet/util/network_device/ipcalc.rb +0 -68
- data/vendored/puppet/lib/puppet/util/network_device/transport/ssh.rb +0 -126
- data/vendored/puppet/lib/puppet/util/network_device/transport/telnet.rb +0 -47
- data/vendored/puppet/lib/puppet/util/windows/taskscheduler.rb +0 -1267
@@ -1,211 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright 2011 Bryan Kearney <bkearney@redhat.com>
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
|
16
|
-
require 'puppet/parameter/boolean'
|
17
|
-
|
18
|
-
Puppet::Type.newtype(:augeas) do
|
19
|
-
include Puppet::Util
|
20
|
-
|
21
|
-
feature :parse_commands, "Parse the command string"
|
22
|
-
feature :need_to_run?, "If the command should run"
|
23
|
-
feature :execute_changes, "Actually make the changes"
|
24
|
-
|
25
|
-
@doc = <<-'EOT'
|
26
|
-
Apply a change or an array of changes to the filesystem
|
27
|
-
using the augeas tool.
|
28
|
-
|
29
|
-
Requires:
|
30
|
-
|
31
|
-
- [Augeas](http://www.augeas.net)
|
32
|
-
- The ruby-augeas bindings
|
33
|
-
|
34
|
-
Sample usage with a string:
|
35
|
-
|
36
|
-
augeas{"test1" :
|
37
|
-
context => "/files/etc/sysconfig/firstboot",
|
38
|
-
changes => "set RUN_FIRSTBOOT YES",
|
39
|
-
onlyif => "match other_value size > 0",
|
40
|
-
}
|
41
|
-
|
42
|
-
Sample usage with an array and custom lenses:
|
43
|
-
|
44
|
-
augeas{"jboss_conf":
|
45
|
-
context => "/files",
|
46
|
-
changes => [
|
47
|
-
"set etc/jbossas/jbossas.conf/JBOSS_IP $ipaddress",
|
48
|
-
"set etc/jbossas/jbossas.conf/JAVA_HOME /usr",
|
49
|
-
],
|
50
|
-
load_path => "$/usr/share/jbossas/lenses",
|
51
|
-
}
|
52
|
-
|
53
|
-
EOT
|
54
|
-
|
55
|
-
newparam (:name) do
|
56
|
-
desc "The name of this task. Used for uniqueness."
|
57
|
-
isnamevar
|
58
|
-
end
|
59
|
-
|
60
|
-
newparam (:context) do
|
61
|
-
desc "Optional context path. This value is prepended to the paths of all
|
62
|
-
changes if the path is relative. If the `incl` parameter is set,
|
63
|
-
defaults to `/files + incl`; otherwise, defaults to the empty string."
|
64
|
-
defaultto ""
|
65
|
-
munge do |value|
|
66
|
-
if value.empty? and resource[:incl]
|
67
|
-
"/files" + resource[:incl]
|
68
|
-
else
|
69
|
-
value
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
newparam (:onlyif) do
|
75
|
-
desc "Optional augeas command and comparisons to control the execution of this type.
|
76
|
-
|
77
|
-
Note: `values` is not an actual augeas API command. It calls `match` to retrieve an array of paths
|
78
|
-
in <MATCH_PATH> and then `get` to retrieve the values from each of the returned paths.
|
79
|
-
|
80
|
-
Supported onlyif syntax:
|
81
|
-
|
82
|
-
* `get <AUGEAS_PATH> <COMPARATOR> <STRING>`
|
83
|
-
* `values <MATCH_PATH> include <STRING>`
|
84
|
-
* `values <MATCH_PATH> not_include <STRING>`
|
85
|
-
* `values <MATCH_PATH> == <AN_ARRAY>`
|
86
|
-
* `values <MATCH_PATH> != <AN_ARRAY>`
|
87
|
-
* `match <MATCH_PATH> size <COMPARATOR> <INT>`
|
88
|
-
* `match <MATCH_PATH> include <STRING>`
|
89
|
-
* `match <MATCH_PATH> not_include <STRING>`
|
90
|
-
* `match <MATCH_PATH> == <AN_ARRAY>`
|
91
|
-
* `match <MATCH_PATH> != <AN_ARRAY>`
|
92
|
-
|
93
|
-
where:
|
94
|
-
|
95
|
-
* `AUGEAS_PATH` is a valid path scoped by the context
|
96
|
-
* `MATCH_PATH` is a valid match syntax scoped by the context
|
97
|
-
* `COMPARATOR` is one of `>, >=, !=, ==, <=,` or `<`
|
98
|
-
* `STRING` is a string
|
99
|
-
* `INT` is a number
|
100
|
-
* `AN_ARRAY` is in the form `['a string', 'another']`"
|
101
|
-
defaultto ""
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
newparam(:changes) do
|
106
|
-
desc "The changes which should be applied to the filesystem. This
|
107
|
-
can be a command or an array of commands. The following commands are supported:
|
108
|
-
|
109
|
-
* `set <PATH> <VALUE>` --- Sets the value `VALUE` at location `PATH`
|
110
|
-
* `setm <PATH> <SUB> <VALUE>` --- Sets multiple nodes (matching `SUB` relative to `PATH`) to `VALUE`
|
111
|
-
* `rm <PATH>` --- Removes the node at location `PATH`
|
112
|
-
* `remove <PATH>` --- Synonym for `rm`
|
113
|
-
* `clear <PATH>` --- Sets the node at `PATH` to `NULL`, creating it if needed
|
114
|
-
* `clearm <PATH> <SUB>` --- Sets multiple nodes (matching `SUB` relative to `PATH`) to `NULL`
|
115
|
-
* `touch <PATH>` --- Creates `PATH` with the value `NULL` if it does not exist
|
116
|
-
* `ins <LABEL> (before|after) <PATH>` --- Inserts an empty node `LABEL` either before or after `PATH`.
|
117
|
-
* `insert <LABEL> <WHERE> <PATH>` --- Synonym for `ins`
|
118
|
-
* `mv <PATH> <OTHER PATH>` --- Moves a node at `PATH` to the new location `OTHER PATH`
|
119
|
-
* `move <PATH> <OTHER PATH>` --- Synonym for `mv`
|
120
|
-
* `rename <PATH> <LABEL>` --- Rename a node at `PATH` to a new `LABEL`
|
121
|
-
* `defvar <NAME> <PATH>` --- Sets Augeas variable `$NAME` to `PATH`
|
122
|
-
* `defnode <NAME> <PATH> <VALUE>` --- Sets Augeas variable `$NAME` to `PATH`, creating it with `VALUE` if needed
|
123
|
-
|
124
|
-
If the `context` parameter is set, that value is prepended to any relative `PATH`s."
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
newparam(:root) do
|
129
|
-
desc "A file system path; all files loaded by Augeas are loaded underneath `root`."
|
130
|
-
defaultto "/"
|
131
|
-
end
|
132
|
-
|
133
|
-
newparam(:load_path) do
|
134
|
-
desc "Optional colon-separated list or array of directories; these directories are searched for schema definitions. The agent's `$libdir/augeas/lenses` path will always be added to support pluginsync."
|
135
|
-
defaultto ""
|
136
|
-
end
|
137
|
-
|
138
|
-
newparam(:force) do
|
139
|
-
desc "Optional command to force the augeas type to execute even if it thinks changes
|
140
|
-
will not be made. This does not override the `onlyif` parameter."
|
141
|
-
|
142
|
-
defaultto false
|
143
|
-
end
|
144
|
-
|
145
|
-
newparam(:type_check) do
|
146
|
-
desc "Whether augeas should perform typechecking. Defaults to false."
|
147
|
-
newvalues(:true, :false)
|
148
|
-
|
149
|
-
defaultto :false
|
150
|
-
end
|
151
|
-
|
152
|
-
newparam(:lens) do
|
153
|
-
desc "Use a specific lens, such as `Hosts.lns`. When this parameter is set, you
|
154
|
-
must also set the `incl` parameter to indicate which file to load.
|
155
|
-
The Augeas documentation includes [a list of available lenses](http://augeas.net/stock_lenses.html)."
|
156
|
-
end
|
157
|
-
|
158
|
-
newparam(:incl) do
|
159
|
-
desc "Load only a specific file, such as `/etc/hosts`. This can greatly speed
|
160
|
-
up the execution the resource. When this parameter is set, you must also
|
161
|
-
set the `lens` parameter to indicate which lens to use."
|
162
|
-
end
|
163
|
-
|
164
|
-
validate do
|
165
|
-
has_lens = !self[:lens].nil?
|
166
|
-
has_incl = !self[:incl].nil?
|
167
|
-
self.fail _("You must specify both the lens and incl parameters, or neither.") if has_lens != has_incl
|
168
|
-
end
|
169
|
-
|
170
|
-
newparam(:show_diff, :boolean => true, :parent => Puppet::Parameter::Boolean) do
|
171
|
-
desc "Whether to display differences when the file changes, defaulting to
|
172
|
-
true. This parameter is useful for files that may contain passwords or
|
173
|
-
other secret data, which might otherwise be included in Puppet reports or
|
174
|
-
other insecure outputs. If the global `show_diff` setting
|
175
|
-
is false, then no diffs will be shown even if this parameter is true."
|
176
|
-
|
177
|
-
defaultto :true
|
178
|
-
end
|
179
|
-
|
180
|
-
# This is the actual meat of the code. It forces
|
181
|
-
# augeas to be run and fails or not based on the augeas return
|
182
|
-
# code.
|
183
|
-
newproperty(:returns) do |property|
|
184
|
-
include Puppet::Util
|
185
|
-
desc "The expected return code from the augeas command. Should not be set."
|
186
|
-
|
187
|
-
defaultto 0
|
188
|
-
|
189
|
-
# Make output a bit prettier
|
190
|
-
def change_to_s(currentvalue, newvalue)
|
191
|
-
_("executed successfully")
|
192
|
-
end
|
193
|
-
|
194
|
-
# if the onlyif resource is provided, then the value is parsed.
|
195
|
-
# a return value of 0 will stop execution because it matches the
|
196
|
-
# default value.
|
197
|
-
def retrieve
|
198
|
-
if @resource.provider.need_to_run?()
|
199
|
-
:need_to_run
|
200
|
-
else
|
201
|
-
0
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
# Actually execute the command.
|
206
|
-
def sync
|
207
|
-
@resource.provider.execute_changes
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
Puppet::Type.newtype(:computer) do
|
2
|
-
|
3
|
-
@doc = "Computer object management using DirectoryService
|
4
|
-
on OS X.
|
5
|
-
|
6
|
-
Note that these are distinctly different kinds of objects to 'hosts',
|
7
|
-
as they require a MAC address and can have all sorts of policy attached to
|
8
|
-
them.
|
9
|
-
|
10
|
-
This provider only manages Computer objects in the local directory service
|
11
|
-
domain, not in remote directories.
|
12
|
-
|
13
|
-
If you wish to manage `/etc/hosts` file on Mac OS X, then simply use the host
|
14
|
-
type as per other platforms.
|
15
|
-
|
16
|
-
This type primarily exists to create localhost Computer objects that MCX
|
17
|
-
policy can then be attached to.
|
18
|
-
|
19
|
-
**Autorequires:** If Puppet is managing the plist file representing a
|
20
|
-
Computer object (located at `/var/db/dslocal/nodes/Default/computers/{name}.plist`),
|
21
|
-
the Computer resource will autorequire it."
|
22
|
-
|
23
|
-
# ensurable
|
24
|
-
|
25
|
-
# We autorequire the computer object in case it is being managed at the
|
26
|
-
# file level by Puppet.
|
27
|
-
|
28
|
-
autorequire(:file) do
|
29
|
-
if self[:name]
|
30
|
-
"/var/db/dslocal/nodes/Default/computers/#{self[:name]}.plist"
|
31
|
-
else
|
32
|
-
nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
newproperty(:ensure, :parent => Puppet::Property::Ensure) do
|
37
|
-
desc "Control the existences of this computer record. Set this attribute to
|
38
|
-
`present` to ensure the computer record exists. Set it to `absent`
|
39
|
-
to delete any computer records with this name"
|
40
|
-
newvalue(:present) do
|
41
|
-
provider.create
|
42
|
-
end
|
43
|
-
|
44
|
-
newvalue(:absent) do
|
45
|
-
provider.delete
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
newparam(:name) do
|
50
|
-
desc "The authoritative 'short' name of the computer record."
|
51
|
-
isnamevar
|
52
|
-
end
|
53
|
-
|
54
|
-
newparam(:realname) do
|
55
|
-
desc "The 'long' name of the computer record."
|
56
|
-
end
|
57
|
-
|
58
|
-
newproperty(:en_address) do
|
59
|
-
desc "The MAC address of the primary network interface. Must match en0."
|
60
|
-
end
|
61
|
-
|
62
|
-
newproperty(:ip_address) do
|
63
|
-
desc "The IP Address of the Computer object."
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'puppet/property/ordered_list'
|
2
|
-
|
3
|
-
module Puppet
|
4
|
-
Type.newtype(:host) do
|
5
|
-
ensurable
|
6
|
-
|
7
|
-
newproperty(:ip) do
|
8
|
-
desc "The host's IP address, IPv4 or IPv6."
|
9
|
-
|
10
|
-
|
11
|
-
def valid_v4?(addr)
|
12
|
-
if /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ =~ addr
|
13
|
-
return $~.captures.all? {|i| i = i.to_i; i >= 0 and i <= 255 }
|
14
|
-
end
|
15
|
-
return false
|
16
|
-
end
|
17
|
-
|
18
|
-
def valid_v6?(addr)
|
19
|
-
# http://forums.dartware.com/viewtopic.php?t=452
|
20
|
-
# ...and, yes, it is this hard. Doing it programmatically is harder.
|
21
|
-
return true if addr =~ /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/
|
22
|
-
|
23
|
-
return false
|
24
|
-
end
|
25
|
-
def valid_newline?(addr)
|
26
|
-
return false if (addr =~ /\n/ || addr =~ /\r/)
|
27
|
-
return true
|
28
|
-
end
|
29
|
-
|
30
|
-
validate do |value|
|
31
|
-
return true if ((valid_v4?(value) || valid_v6?(value)) && (valid_newline?(value)))
|
32
|
-
raise Puppet::Error, _("Invalid IP address %{value}") % { value: value.inspect }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# for now we use OrderedList to indicate that the order does matter.
|
37
|
-
newproperty(:host_aliases, :parent => Puppet::Property::OrderedList) do
|
38
|
-
desc "Any aliases the host might have. Multiple values must be
|
39
|
-
specified as an array."
|
40
|
-
|
41
|
-
def delimiter
|
42
|
-
" "
|
43
|
-
end
|
44
|
-
|
45
|
-
def inclusive?
|
46
|
-
true
|
47
|
-
end
|
48
|
-
|
49
|
-
validate do |value|
|
50
|
-
# This regex already includes newline check.
|
51
|
-
raise Puppet::Error, _("Host aliases cannot include whitespace") if value =~ /\s/
|
52
|
-
raise Puppet::Error, _("Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ") if value =~ /^\s*$/
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
newproperty(:comment) do
|
58
|
-
desc "A comment that will be attached to the line with a # character."
|
59
|
-
validate do |value|
|
60
|
-
raise Puppet::Error, _("Comment cannot include newline") if (value =~ /\n/ || value =~ /\r/)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
newproperty(:target) do
|
65
|
-
desc "The file in which to store service information. Only used by
|
66
|
-
those providers that write to disk. On most systems this defaults to `/etc/hosts`."
|
67
|
-
|
68
|
-
defaultto { if @resource.class.defaultprovider.ancestors.include?(Puppet::Provider::ParsedFile)
|
69
|
-
@resource.class.defaultprovider.default_target
|
70
|
-
else
|
71
|
-
nil
|
72
|
-
end
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
newparam(:name) do
|
77
|
-
desc "The host name."
|
78
|
-
|
79
|
-
isnamevar
|
80
|
-
|
81
|
-
validate do |value|
|
82
|
-
value.split('.').each do |hostpart|
|
83
|
-
unless hostpart =~ /^([\w]+|[\w][\w\-]+[\w])$/
|
84
|
-
raise Puppet::Error, _("Invalid host name")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
raise Puppet::Error, _("Hostname cannot include newline") if (value =~ /\n/ || value =~ /\r/)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
@doc = "Installs and manages host entries. For most systems, these
|
92
|
-
entries will just be in `/etc/hosts`, but some systems (notably OS X)
|
93
|
-
will have different solutions."
|
94
|
-
end
|
95
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Manages an interface on a given router or switch
|
3
|
-
#
|
4
|
-
|
5
|
-
require 'puppet/util/network_device/ipcalc'
|
6
|
-
|
7
|
-
Puppet::Type.newtype(:interface) do
|
8
|
-
|
9
|
-
@doc = "This represents a router or switch interface. It is possible to manage
|
10
|
-
interface mode (access or trunking, native vlan and encapsulation) and
|
11
|
-
switchport characteristics (speed, duplex)."
|
12
|
-
|
13
|
-
apply_to_device
|
14
|
-
|
15
|
-
ensurable do
|
16
|
-
defaultvalues
|
17
|
-
|
18
|
-
aliasvalue :shutdown, :absent
|
19
|
-
aliasvalue :no_shutdown, :present
|
20
|
-
|
21
|
-
defaultto { :no_shutdown }
|
22
|
-
end
|
23
|
-
|
24
|
-
newparam(:name) do
|
25
|
-
desc "The interface's name."
|
26
|
-
end
|
27
|
-
|
28
|
-
newparam(:device_url) do
|
29
|
-
desc "The URL at which the router or switch can be reached."
|
30
|
-
end
|
31
|
-
|
32
|
-
newproperty(:description) do
|
33
|
-
desc "Interface description."
|
34
|
-
|
35
|
-
defaultto { @resource[:name] }
|
36
|
-
end
|
37
|
-
|
38
|
-
newproperty(:speed) do
|
39
|
-
desc "Interface speed."
|
40
|
-
newvalues(:auto, /^\d+/)
|
41
|
-
end
|
42
|
-
|
43
|
-
newproperty(:duplex) do
|
44
|
-
desc "Interface duplex."
|
45
|
-
newvalues(:auto, :full, :half)
|
46
|
-
end
|
47
|
-
|
48
|
-
newproperty(:access_vlan) do
|
49
|
-
desc "Interface static access vlan."
|
50
|
-
newvalues(/^\d+/)
|
51
|
-
end
|
52
|
-
|
53
|
-
newproperty(:native_vlan) do
|
54
|
-
desc "Interface native vlan when trunking."
|
55
|
-
newvalues(/^\d+/)
|
56
|
-
end
|
57
|
-
|
58
|
-
newproperty(:encapsulation) do
|
59
|
-
desc "Interface switchport encapsulation."
|
60
|
-
newvalues(:none, :dot1q, :isl, :negotiate)
|
61
|
-
end
|
62
|
-
|
63
|
-
newproperty(:mode) do
|
64
|
-
desc "Interface switchport mode."
|
65
|
-
newvalues(:access, :trunk, 'dynamic auto', 'dynamic desirable')
|
66
|
-
end
|
67
|
-
|
68
|
-
newproperty(:allowed_trunk_vlans) do
|
69
|
-
desc "Allowed list of Vlans that this trunk can forward."
|
70
|
-
newvalues(:all, /./)
|
71
|
-
end
|
72
|
-
|
73
|
-
newproperty(:etherchannel) do
|
74
|
-
desc "Channel group this interface is part of."
|
75
|
-
newvalues(/^\d+/)
|
76
|
-
end
|
77
|
-
|
78
|
-
newproperty(:ipaddress, :array_matching => :all) do
|
79
|
-
include Puppet::Util::NetworkDevice::IPCalc
|
80
|
-
|
81
|
-
desc "IP Address of this interface. Note that it might not be possible to set
|
82
|
-
an interface IP address; it depends on the interface type and device type.
|
83
|
-
|
84
|
-
Valid format of ip addresses are:
|
85
|
-
|
86
|
-
* IPV4, like 127.0.0.1
|
87
|
-
* IPV4/prefixlength like 127.0.1.1/24
|
88
|
-
* IPV6/prefixlength like FE80::21A:2FFF:FE30:ECF0/128
|
89
|
-
* an optional suffix for IPV6 addresses from this list: `eui-64`, `link-local`
|
90
|
-
|
91
|
-
It is also possible to supply an array of values.
|
92
|
-
"
|
93
|
-
|
94
|
-
validate do |values|
|
95
|
-
values = [values] unless values.is_a?(Array)
|
96
|
-
values.each do |value|
|
97
|
-
self.fail _("Invalid interface ip address") unless parse(value.gsub(/\s*(eui-64|link-local)\s*$/,''))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
munge do |value|
|
102
|
-
option = value =~ /eui-64|link-local/i ? value.gsub(/^.*?\s*(eui-64|link-local)\s*$/,'\1') : nil
|
103
|
-
[parse(value.gsub(/\s*(eui-64|link-local)\s*$/,'')), option].flatten
|
104
|
-
end
|
105
|
-
|
106
|
-
def value_to_s(value)
|
107
|
-
value = [value] unless value.is_a?(Array)
|
108
|
-
value.map{ |v| "#{v[1].to_s}/#{v[0]} #{v[2]}"}.join(",")
|
109
|
-
end
|
110
|
-
|
111
|
-
def change_to_s(currentvalue, newvalue)
|
112
|
-
currentvalue = value_to_s(currentvalue) if currentvalue != :absent
|
113
|
-
newvalue = value_to_s(newvalue)
|
114
|
-
super(currentvalue, newvalue)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def present?(current_values)
|
119
|
-
super && current_values[:ensure] != :shutdown
|
120
|
-
end
|
121
|
-
end
|
@@ -1,165 +0,0 @@
|
|
1
|
-
# Plug-in type for handling k5login files
|
2
|
-
require 'puppet/util'
|
3
|
-
require 'puppet/util/selinux'
|
4
|
-
require 'puppet/type/file/selcontext'
|
5
|
-
|
6
|
-
Puppet::Type.newtype(:k5login) do
|
7
|
-
@doc = "Manage the `.k5login` file for a user. Specify the full path to
|
8
|
-
the `.k5login` file as the name, and an array of principals as the
|
9
|
-
`principals` attribute."
|
10
|
-
|
11
|
-
ensurable
|
12
|
-
|
13
|
-
# Principals that should exist in the file
|
14
|
-
newproperty(:principals, :array_matching => :all) do
|
15
|
-
desc "The principals present in the `.k5login` file. This should be specified as an array."
|
16
|
-
end
|
17
|
-
|
18
|
-
# The path/name of the k5login file
|
19
|
-
newparam(:path) do
|
20
|
-
isnamevar
|
21
|
-
desc "The path to the `.k5login` file to manage. Must be fully qualified."
|
22
|
-
|
23
|
-
validate do |value|
|
24
|
-
unless absolute_path?(value)
|
25
|
-
raise Puppet::Error, _("File paths must be fully qualified.")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# To manage the mode of the file
|
31
|
-
newproperty(:mode) do
|
32
|
-
desc "The desired permissions mode of the `.k5login` file. Defaults to `644`."
|
33
|
-
defaultto { "644" }
|
34
|
-
end
|
35
|
-
|
36
|
-
# To manage the selinux user of the file
|
37
|
-
newproperty(:seluser, :parent => Puppet::SELFileContext) do
|
38
|
-
desc "What the SELinux user component of the context of the file should be.
|
39
|
-
Any valid SELinux user component is accepted. For example `user_u`.
|
40
|
-
If not specified it defaults to the value returned by matchpathcon for
|
41
|
-
the file, if any exists. Only valid on systems with SELinux support
|
42
|
-
enabled."
|
43
|
-
|
44
|
-
defaultto { "user_u" }
|
45
|
-
end
|
46
|
-
|
47
|
-
# To manage the selinux role of the file
|
48
|
-
newproperty(:selrole, :parent => Puppet::SELFileContext) do
|
49
|
-
desc "What the SELinux role component of the context of the file should be.
|
50
|
-
Any valid SELinux role component is accepted. For example `role_r`.
|
51
|
-
If not specified it defaults to the value returned by matchpathcon for
|
52
|
-
the file, if any exists. Only valid on systems with SELinux support
|
53
|
-
enabled."
|
54
|
-
|
55
|
-
defaultto { "object_r" }
|
56
|
-
end
|
57
|
-
|
58
|
-
# To manage the selinux type of the file
|
59
|
-
newproperty(:seltype, :parent => Puppet::SELFileContext) do
|
60
|
-
desc "What the SELinux type component of the context of the file should be.
|
61
|
-
Any valid SELinux type component is accepted. For example `tmp_t`.
|
62
|
-
If not specified it defaults to the value returned by matchpathcon for
|
63
|
-
the file, if any exists. Only valid on systems with SELinux support
|
64
|
-
enabled."
|
65
|
-
|
66
|
-
# to my knowledge, `krb5_home_t` is the only valid type for .k5login
|
67
|
-
defaultto { "krb5_home_t" }
|
68
|
-
end
|
69
|
-
|
70
|
-
# To manage the selinux range of the file
|
71
|
-
newproperty(:selrange, :parent => Puppet::SELFileContext) do
|
72
|
-
desc "What the SELinux range component of the context of the file should be.
|
73
|
-
Any valid SELinux range component is accepted. For example `s0` or
|
74
|
-
`SystemHigh`. If not specified it defaults to the value returned by
|
75
|
-
matchpathcon for the file, if any exists. Only valid on systems with
|
76
|
-
SELinux support enabled and that have support for MCS (Multi-Category
|
77
|
-
Security)."
|
78
|
-
|
79
|
-
defaultto { "s0" }
|
80
|
-
end
|
81
|
-
|
82
|
-
# Stat our file.
|
83
|
-
#
|
84
|
-
# We use the initial value :needs_stat to ensure we only stat the file once,
|
85
|
-
# but can also keep track of a failed stat (@stat == nil). This also allows
|
86
|
-
# us to re-stat on demand by setting @stat = :needs_stat.
|
87
|
-
def stat
|
88
|
-
return @stat unless @stat == :needs_stat
|
89
|
-
|
90
|
-
@stat = begin
|
91
|
-
Puppet::FileSystem.stat(self[:path])
|
92
|
-
rescue Errno::ENOENT
|
93
|
-
nil
|
94
|
-
rescue Errno::ENOTDIR
|
95
|
-
nil
|
96
|
-
rescue Errno::EACCES
|
97
|
-
warning _("Could not stat; permission denied")
|
98
|
-
nil
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def initialize(args)
|
103
|
-
@stat = :needs_stat
|
104
|
-
super
|
105
|
-
end
|
106
|
-
|
107
|
-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
108
|
-
|
109
|
-
provide(:k5login) do
|
110
|
-
desc "The k5login provider is the only provider for the k5login
|
111
|
-
type."
|
112
|
-
|
113
|
-
include Puppet::Util::SELinux
|
114
|
-
|
115
|
-
# Does this file exist?
|
116
|
-
def exists?
|
117
|
-
Puppet::FileSystem.exist?(@resource[:name])
|
118
|
-
end
|
119
|
-
|
120
|
-
# create the file
|
121
|
-
def create
|
122
|
-
write(@resource.should(:principals))
|
123
|
-
should_mode = @resource.should(:mode)
|
124
|
-
unless self.mode == should_mode
|
125
|
-
self.mode = should_mode
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
# remove the file
|
130
|
-
def destroy
|
131
|
-
Puppet::FileSystem.unlink(@resource[:name])
|
132
|
-
end
|
133
|
-
|
134
|
-
# Return the principals
|
135
|
-
def principals
|
136
|
-
if Puppet::FileSystem.exist?(@resource[:name])
|
137
|
-
File.readlines(@resource[:name]).collect { |line| line.chomp }
|
138
|
-
else
|
139
|
-
:absent
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
# Write the principals out to the k5login file
|
144
|
-
def principals=(value)
|
145
|
-
write(value)
|
146
|
-
end
|
147
|
-
|
148
|
-
# Return the mode as an octal string, not as an integer
|
149
|
-
def mode
|
150
|
-
"%o" % (Puppet::FileSystem.stat(@resource[:name]).mode & 007777)
|
151
|
-
end
|
152
|
-
|
153
|
-
# Set the file mode, converting from a string to an integer.
|
154
|
-
def mode=(value)
|
155
|
-
File.chmod(Integer("0#{value}"), @resource[:name])
|
156
|
-
end
|
157
|
-
|
158
|
-
private
|
159
|
-
def write(value)
|
160
|
-
Puppet::Util.replace_file(@resource[:name], 0644) do |f|
|
161
|
-
f.puts value
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|