puppet 2.7.6 → 2.7.8
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CHANGELOG +168 -0
- data/conf/auth.conf +5 -4
- data/conf/redhat/puppet.spec +16 -1
- data/conf/solaris/pkginfo +2 -2
- data/conf/suse/puppet.spec +9 -3
- data/ext/upload_facts.rb +120 -0
- data/install.rb +11 -16
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +0 -3
- data/lib/puppet/application/apply.rb +0 -3
- data/lib/puppet/application/queue.rb +21 -1
- data/lib/puppet/defaults.rb +6 -4
- data/lib/puppet/face/file/store.rb +1 -1
- data/lib/puppet/feature/base.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_serving/content.rb +1 -1
- data/lib/puppet/file_serving/metadata.rb +5 -2
- data/lib/puppet/indirector/facts/inventory_service.rb +20 -0
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/report/processor.rb +1 -1
- data/lib/puppet/network/handler/filebucket.rb +2 -0
- data/lib/puppet/network/handler/fileserver.rb +1 -1
- data/lib/puppet/network/handler/master.rb +1 -0
- data/lib/puppet/network/handler/report.rb +2 -0
- data/lib/puppet/network/handler/runner.rb +1 -0
- data/lib/puppet/network/handler/status.rb +2 -0
- data/lib/puppet/network/http/mongrel/rest.rb +8 -1
- data/lib/puppet/network/http_server.rb +3 -0
- data/lib/puppet/network/http_server/mongrel.rb +129 -0
- data/lib/puppet/network/rest_authconfig.rb +12 -4
- data/lib/puppet/parameter.rb +18 -0
- data/lib/puppet/parser/compiler.rb +1 -1
- data/lib/puppet/parser/grammar.ra +1 -1
- data/lib/puppet/parser/parser.rb +360 -350
- data/lib/puppet/property.rb +3 -3
- data/lib/puppet/provider/augeas/augeas.rb +1 -1
- data/lib/puppet/provider/exec/windows.rb +6 -7
- data/lib/puppet/provider/file/windows.rb +9 -2
- data/lib/puppet/provider/group/aix.rb +8 -8
- data/lib/puppet/provider/group/groupadd.rb +1 -3
- data/lib/puppet/provider/group/ldap.rb +8 -10
- data/lib/puppet/provider/group/windows_adsi.rb +8 -2
- data/lib/puppet/provider/package/aix.rb +1 -1
- data/lib/puppet/provider/package/macports.rb +3 -3
- data/lib/puppet/provider/package/msi.rb +12 -5
- data/lib/puppet/provider/package/nim.rb +1 -1
- data/lib/puppet/provider/package/pkgdmg.rb +3 -3
- data/lib/puppet/provider/package/ports.rb +1 -1
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +560 -0
- data/lib/puppet/provider/service/base.rb +2 -2
- data/lib/puppet/provider/service/bsd.rb +4 -3
- data/lib/puppet/provider/service/daemontools.rb +25 -25
- data/lib/puppet/provider/service/debian.rb +6 -4
- data/lib/puppet/provider/service/freebsd.rb +1 -1
- data/lib/puppet/provider/service/gentoo.rb +4 -3
- data/lib/puppet/provider/service/init.rb +3 -8
- data/lib/puppet/provider/service/launchd.rb +129 -96
- data/lib/puppet/provider/service/redhat.rb +2 -3
- data/lib/puppet/provider/service/runit.rb +20 -20
- data/lib/puppet/provider/service/smf.rb +8 -7
- data/lib/puppet/provider/service/src.rb +5 -6
- data/lib/puppet/provider/service/systemd.rb +1 -1
- data/lib/puppet/provider/service/upstart.rb +3 -5
- data/lib/puppet/provider/service/windows.rb +7 -7
- data/lib/puppet/provider/sshkey/parsed.rb +2 -3
- data/lib/puppet/provider/user/aix.rb +21 -21
- data/lib/puppet/provider/user/hpux.rb +3 -1
- data/lib/puppet/provider/user/ldap.rb +7 -7
- data/lib/puppet/provider/user/user_role_add.rb +10 -6
- data/lib/puppet/provider/user/useradd.rb +3 -1
- data/lib/puppet/provider/user/windows_adsi.rb +4 -3
- data/lib/puppet/rb_tree_map.rb +388 -0
- data/lib/puppet/reference/configuration.rb +7 -7
- data/lib/puppet/reference/indirection.rb +5 -6
- data/lib/puppet/reference/metaparameter.rb +3 -1
- data/lib/puppet/reference/network.rb +8 -8
- data/lib/puppet/reference/providers.rb +17 -21
- data/lib/puppet/reference/type.rb +12 -9
- data/lib/puppet/resource.rb +2 -5
- data/lib/puppet/resource/catalog.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +70 -0
- data/lib/puppet/ssl/host.rb +6 -0
- data/lib/puppet/transaction.rb +158 -55
- data/lib/puppet/transaction/event_manager.rb +1 -1
- data/lib/puppet/type.rb +60 -30
- data/lib/puppet/type/augeas.rb +83 -49
- data/lib/puppet/type/computer.rb +1 -1
- data/lib/puppet/type/cron.rb +11 -11
- data/lib/puppet/type/exec.rb +28 -21
- data/lib/puppet/type/file.rb +17 -7
- data/lib/puppet/type/file/content.rb +2 -2
- data/lib/puppet/type/file/ensure.rb +15 -12
- data/lib/puppet/type/file/mode.rb +30 -5
- data/lib/puppet/type/file/source.rb +11 -10
- data/lib/puppet/type/file/target.rb +2 -2
- data/lib/puppet/type/filebucket.rb +1 -1
- data/lib/puppet/type/group.rb +4 -5
- data/lib/puppet/type/host.rb +1 -1
- data/lib/puppet/type/interface.rb +13 -10
- data/lib/puppet/type/k5login.rb +6 -6
- data/lib/puppet/type/macauthorization.rb +37 -36
- data/lib/puppet/type/maillist.rb +2 -2
- data/lib/puppet/type/mcx.rb +6 -6
- data/lib/puppet/type/mount.rb +3 -2
- data/lib/puppet/type/notify.rb +1 -1
- data/lib/puppet/type/package.rb +24 -23
- data/lib/puppet/type/router.rb +4 -1
- data/lib/puppet/type/schedule.rb +52 -44
- data/lib/puppet/type/scheduled_task.rb +222 -0
- data/lib/puppet/type/selmodule.rb +10 -6
- data/lib/puppet/type/service.rb +11 -11
- data/lib/puppet/type/ssh_authorized_key.rb +2 -5
- data/lib/puppet/type/sshkey.rb +1 -1
- data/lib/puppet/type/stage.rb +1 -1
- data/lib/puppet/type/tidy.rb +10 -8
- data/lib/puppet/type/user.rb +61 -53
- data/lib/puppet/type/vlan.rb +4 -4
- data/lib/puppet/type/whit.rb +6 -2
- data/lib/puppet/type/yumrepo.rb +33 -31
- data/lib/puppet/type/zfs.rb +34 -32
- data/lib/puppet/type/zone.rb +21 -19
- data/lib/puppet/type/zpool.rb +3 -3
- data/lib/puppet/util.rb +24 -6
- data/lib/puppet/util/adsi.rb +12 -7
- data/lib/puppet/util/checksums.rb +1 -1
- data/lib/puppet/util/diff.rb +1 -1
- data/lib/puppet/util/nagios_maker.rb +2 -2
- data/lib/puppet/util/reference.rb +16 -17
- data/lib/puppet/util/settings/file_setting.rb +14 -2
- data/lib/puppet/util/windows/security.rb +96 -32
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +9 -15
- data/spec/integration/indirector/file_content/file_server_spec.rb +1 -1
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +4 -0
- data/spec/integration/provider/service/init_spec.rb +8 -2
- data/spec/integration/reference/providers_spec.rb +1 -1
- data/spec/integration/ssl/certificate_request_spec.rb +1 -2
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +1 -2
- data/spec/integration/ssl/host_spec.rb +1 -2
- data/spec/integration/transaction_spec.rb +25 -17
- data/spec/integration/type/exec_spec.rb +77 -0
- data/spec/integration/type/file_spec.rb +322 -2
- data/spec/integration/util/windows/security_spec.rb +393 -230
- data/spec/integration/util_spec.rb +16 -0
- data/spec/lib/puppet_spec/files.rb +3 -7
- data/spec/unit/application/apply_spec.rb +0 -9
- data/spec/unit/application/inspect_spec.rb +1 -0
- data/spec/unit/configurer/downloader_spec.rb +3 -3
- data/spec/unit/face/certificate_spec.rb +6 -2
- data/spec/unit/file_bucket/dipper_spec.rb +67 -10
- data/spec/unit/file_bucket/file_spec.rb +22 -28
- data/spec/unit/file_serving/content_spec.rb +1 -1
- data/spec/unit/file_serving/metadata_spec.rb +30 -3
- data/spec/unit/indirector/facts/inventory_service_spec.rb +22 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +21 -24
- data/spec/unit/indirector/node/store_configs_spec.rb +1 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource_type/parser_spec.rb +2 -2
- data/spec/unit/indirector/rest_spec.rb +1 -1
- data/spec/unit/network/handler/ca_spec.rb +1 -1
- data/spec/unit/network/http/mongrel/rest_spec.rb +54 -25
- data/spec/unit/parameter_spec.rb +36 -0
- data/spec/unit/parser/parser_spec.rb +4 -0
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/provider/exec/windows_spec.rb +2 -8
- data/spec/unit/provider/file/posix_spec.rb +6 -0
- data/spec/unit/provider/file/windows_spec.rb +18 -0
- data/spec/unit/provider/group/windows_adsi_spec.rb +22 -6
- data/spec/unit/provider/mount/parsed_spec.rb +1 -1
- data/spec/unit/provider/package/msi_spec.rb +2 -2
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1571 -0
- data/spec/unit/provider/service/launchd_spec.rb +143 -130
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +5 -0
- data/spec/unit/provider/user/user_role_add_spec.rb +39 -9
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +8 -1
- data/spec/unit/rb_tree_map_spec.rb +572 -0
- data/spec/unit/resource/catalog_spec.rb +1 -1
- data/spec/unit/simple_graph_spec.rb +9 -9
- data/spec/unit/ssl/host_spec.rb +60 -12
- data/spec/unit/transaction/report_spec.rb +3 -3
- data/spec/unit/transaction_spec.rb +394 -11
- data/spec/unit/type/exec_spec.rb +35 -15
- data/spec/unit/type/file/content_spec.rb +11 -10
- data/spec/unit/type/file/mode_spec.rb +73 -19
- data/spec/unit/type/file/source_spec.rb +1 -1
- data/spec/unit/type/file_spec.rb +15 -0
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/resources_spec.rb +3 -3
- data/spec/unit/type/scheduled_task_spec.rb +102 -0
- data/spec/unit/type/ssh_authorized_key_spec.rb +2 -3
- data/spec/unit/type/user_spec.rb +2 -1
- data/spec/unit/type_spec.rb +48 -4
- data/spec/unit/util/adsi_spec.rb +18 -7
- data/spec/unit/util/checksums_spec.rb +20 -2
- data/spec/unit/util/execution_stub_spec.rb +10 -5
- data/spec/unit/util/logging_spec.rb +6 -6
- data/spec/unit/util/rdoc/parser_spec.rb +1 -1
- data/spec/unit/util/reference_spec.rb +29 -0
- data/spec/unit/util/settings/file_setting_spec.rb +8 -2
- data/spec/unit/util_spec.rb +115 -0
- data/test/other/transactions.rb +5 -11
- data/test/ral/type/exec.rb +1 -1
- metadata +24 -11
data/lib/puppet/type/maillist.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Puppet
|
2
2
|
newtype(:maillist) do
|
3
|
-
@doc = "Manage email lists. This resource type
|
4
|
-
and remove lists
|
3
|
+
@doc = "Manage email lists. This resource type can only create
|
4
|
+
and remove lists; it cannot currently reconfigure them."
|
5
5
|
|
6
6
|
ensurable do
|
7
7
|
defaultvalues
|
data/lib/puppet/type/mcx.rb
CHANGED
@@ -3,7 +3,7 @@ Puppet::Type.newtype(:mcx) do
|
|
3
3
|
@doc = "MCX object management using DirectoryService on OS X.
|
4
4
|
|
5
5
|
The default provider of this type merely manages the XML plist as
|
6
|
-
reported by the dscl -mcxexport command. This is similar to the
|
6
|
+
reported by the `dscl -mcxexport` command. This is similar to the
|
7
7
|
content property of the file type in Puppet.
|
8
8
|
|
9
9
|
The recommended method of using this type is to use Work Group Manager
|
@@ -53,14 +53,14 @@ MCX settings refer to, the MCX resource will autorequire that user, group, or co
|
|
53
53
|
end
|
54
54
|
|
55
55
|
newparam(:ds_name) do
|
56
|
-
desc "The name to attach the MCX Setting to.
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
desc "The name to attach the MCX Setting to. (For example, `localhost`
|
57
|
+
when `ds_type => computer`.) This setting is not required, as it can be
|
58
|
+
automatically discovered when the resource name is parseable. (For
|
59
|
+
example, in `/Groups/admin`, `group` will be used as the dstype.)"
|
60
60
|
end
|
61
61
|
|
62
62
|
newproperty(:content, :required_features => :manages_content) do
|
63
|
-
desc "The XML Plist
|
63
|
+
desc "The XML Plist used as the value of MCXSettings in DirectoryService.
|
64
64
|
This is the standard output from the system command:
|
65
65
|
|
66
66
|
dscl localhost -mcxexport /Local/Default/<ds_type>/ds_name
|
data/lib/puppet/type/mount.rb
CHANGED
@@ -16,10 +16,11 @@ module Puppet
|
|
16
16
|
newproperty(:ensure) do
|
17
17
|
desc "Control what to do with this mount. Set this attribute to
|
18
18
|
`umounted` to make sure the filesystem is in the filesystem table
|
19
|
-
but not mounted (if the filesystem is currently mounted, it will be
|
19
|
+
but not mounted (if the filesystem is currently mounted, it will be
|
20
|
+
unmounted). Set it to `absent` to unmount (if necessary) and remove
|
20
21
|
the filesystem from the fstab. Set to `mounted` to add it to the
|
21
22
|
fstab and mount it. Set to `present` to add to fstab but not change
|
22
|
-
mount/unmount status"
|
23
|
+
mount/unmount status."
|
23
24
|
|
24
25
|
# IS -> SHOULD In Sync Action
|
25
26
|
# ghost -> present NO create
|
data/lib/puppet/type/notify.rb
CHANGED
data/lib/puppet/type/package.rb
CHANGED
@@ -7,9 +7,9 @@ module Puppet
|
|
7
7
|
newtype(:package) do
|
8
8
|
@doc = "Manage packages. There is a basic dichotomy in package
|
9
9
|
support right now: Some package types (e.g., yum and apt) can
|
10
|
-
retrieve their own package files, while others (e.g., rpm and sun)
|
11
|
-
|
12
|
-
the correct file.
|
10
|
+
retrieve their own package files, while others (e.g., rpm and sun)
|
11
|
+
cannot. For those package formats that cannot retrieve their own files,
|
12
|
+
you can use the `source` parameter to point to the correct file.
|
13
13
|
|
14
14
|
Puppet will automatically guess the packaging format that you are
|
15
15
|
using based on the platform you are on, but you can override it
|
@@ -17,9 +17,9 @@ module Puppet
|
|
17
17
|
requires in order to function, and you must meet those requirements
|
18
18
|
to use a given provider.
|
19
19
|
|
20
|
-
**Autorequires:** If Puppet is managing the files specified as a
|
21
|
-
`adminfile`, `responsefile`, or `source`, the package
|
22
|
-
those files."
|
20
|
+
**Autorequires:** If Puppet is managing the files specified as a
|
21
|
+
package's `adminfile`, `responsefile`, or `source`, the package
|
22
|
+
resource will autorequire those files."
|
23
23
|
|
24
24
|
feature :installable, "The provider can install packages.",
|
25
25
|
:methods => [:install]
|
@@ -48,14 +48,14 @@ module Puppet
|
|
48
48
|
passed to the installer command."
|
49
49
|
|
50
50
|
ensurable do
|
51
|
-
desc
|
52
|
-
|
53
|
-
retrieve new packages on their own
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
desc <<-EOT
|
52
|
+
What state the package should be in. On packaging systems that can
|
53
|
+
retrieve new packages on their own, you can choose which package to
|
54
|
+
retrieve by specifying a version number or `latest` as the ensure
|
55
|
+
value. On packaging systems that manage configuration files separately
|
56
|
+
from "normal" system files, you can uninstall config files by
|
57
|
+
specifying `purged` as the ensure value.
|
58
|
+
EOT
|
59
59
|
|
60
60
|
attr_accessor :latest
|
61
61
|
|
@@ -196,7 +196,7 @@ module Puppet
|
|
196
196
|
# object name.
|
197
197
|
package { $ssl:
|
198
198
|
ensure => installed,
|
199
|
-
alias
|
199
|
+
alias => openssl
|
200
200
|
}
|
201
201
|
|
202
202
|
. etc. .
|
@@ -209,8 +209,8 @@ module Puppet
|
|
209
209
|
# Use the alias to specify a dependency, rather than
|
210
210
|
# having another selector to figure it out again.
|
211
211
|
package { $ssh:
|
212
|
-
ensure
|
213
|
-
alias
|
212
|
+
ensure => installed,
|
213
|
+
alias => openssh,
|
214
214
|
require => Package[openssl]
|
215
215
|
}
|
216
216
|
|
@@ -221,7 +221,12 @@ module Puppet
|
|
221
221
|
newparam(:source) do
|
222
222
|
desc "Where to find the actual package. This must be a local file
|
223
223
|
(or on a network file system) or a URL that your specific
|
224
|
-
packaging type understands; Puppet will not retrieve files for you
|
224
|
+
packaging type understands; Puppet will not retrieve files for you,
|
225
|
+
although you can manage packages as `file` resources."
|
226
|
+
|
227
|
+
validate do |value|
|
228
|
+
provider.validate_source(value)
|
229
|
+
end
|
225
230
|
end
|
226
231
|
|
227
232
|
newparam(:instance) do
|
@@ -260,7 +265,7 @@ module Puppet
|
|
260
265
|
|
261
266
|
newparam(:configfiles) do
|
262
267
|
desc "Whether configfiles should be kept or replaced. Most packages
|
263
|
-
types do not support this parameter."
|
268
|
+
types do not support this parameter. Defaults to `keep`."
|
264
269
|
|
265
270
|
defaultto :keep
|
266
271
|
|
@@ -300,10 +305,6 @@ module Puppet
|
|
300
305
|
installing a package."
|
301
306
|
end
|
302
307
|
|
303
|
-
validate do
|
304
|
-
provider.validate_source(self[:source])
|
305
|
-
end
|
306
|
-
|
307
308
|
autorequire(:file) do
|
308
309
|
autos = []
|
309
310
|
[:responsefile, :adminfile].each { |param|
|
data/lib/puppet/type/router.rb
CHANGED
@@ -7,7 +7,10 @@ module Puppet
|
|
7
7
|
@doc = "Manages connected router."
|
8
8
|
|
9
9
|
newparam(:url) do
|
10
|
-
desc
|
10
|
+
desc <<-EOT
|
11
|
+
An SSH or telnet URL at which to access the router, in the form
|
12
|
+
`ssh://user:pass:enable@host/` or `telnet://user:pass:enable@host/`.
|
13
|
+
EOT
|
11
14
|
isnamevar
|
12
15
|
end
|
13
16
|
end
|
data/lib/puppet/type/schedule.rb
CHANGED
@@ -1,27 +1,32 @@
|
|
1
1
|
module Puppet
|
2
2
|
newtype(:schedule) do
|
3
|
-
@doc =
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
@doc = <<-EOT
|
4
|
+
Define schedules for Puppet. Resources can be limited to a schedule by using the
|
5
|
+
[`schedule`](http://docs.puppetlabs.com/references/latest/metaparameter.html#schedule)
|
6
|
+
metaparameter.
|
7
|
+
|
8
|
+
Currently, **schedules can only be used to stop a resource from being
|
9
|
+
applied;** they cannot cause a resource to be applied when it otherwise
|
10
|
+
wouldn't be, and they cannot accurately specify a time when a resource
|
11
|
+
should run.
|
12
|
+
|
13
|
+
Every time Puppet applies its configuration, it will apply the
|
14
|
+
set of resources whose schedule does not eliminate them from
|
10
15
|
running right then, but there is currently no system in place to
|
11
16
|
guarantee that a given resource runs at a given time. If you
|
12
17
|
specify a very restrictive schedule and Puppet happens to run at a
|
13
18
|
time within that schedule, then the resources will get applied;
|
14
19
|
otherwise, that work may never get done.
|
15
20
|
|
16
|
-
Thus, it
|
21
|
+
Thus, it is advisable to use wider scheduling (e.g., over a couple of
|
17
22
|
hours) combined with periods and repetitions. For instance, if you
|
18
23
|
wanted to restrict certain resources to only running once, between
|
19
24
|
the hours of two and 4 AM, then you would use this schedule:
|
20
25
|
|
21
|
-
schedule { maint:
|
22
|
-
range
|
26
|
+
schedule { 'maint':
|
27
|
+
range => "2 - 4",
|
23
28
|
period => daily,
|
24
|
-
repeat => 1
|
29
|
+
repeat => 1,
|
25
30
|
}
|
26
31
|
|
27
32
|
With this schedule, the first time that Puppet runs between 2 and 4 AM,
|
@@ -30,51 +35,54 @@ module Puppet
|
|
30
35
|
run once that day, and they won't get applied outside that schedule
|
31
36
|
because they will be outside the scheduled range.
|
32
37
|
|
33
|
-
Puppet automatically creates a schedule for each
|
34
|
-
same name as that period (e.g., hourly and daily).
|
35
|
-
a schedule named
|
36
|
-
with the following attributes:
|
38
|
+
Puppet automatically creates a schedule for each of the valid periods
|
39
|
+
with the same name as that period (e.g., hourly and daily).
|
40
|
+
Additionally, a schedule named `puppet` is created and used as the
|
41
|
+
default, with the following attributes:
|
37
42
|
|
38
|
-
schedule { puppet:
|
43
|
+
schedule { 'puppet':
|
39
44
|
period => hourly,
|
40
|
-
repeat => 2
|
45
|
+
repeat => 2,
|
41
46
|
}
|
42
47
|
|
43
48
|
This will cause resources to be applied every 30 minutes by default.
|
44
|
-
|
49
|
+
EOT
|
45
50
|
|
46
51
|
apply_to_all
|
47
52
|
|
48
53
|
newparam(:name) do
|
49
|
-
desc
|
54
|
+
desc <<-EOT
|
55
|
+
The name of the schedule. This name is used to retrieve the
|
50
56
|
schedule when assigning it to an object:
|
51
57
|
|
52
|
-
schedule { daily:
|
58
|
+
schedule { 'daily':
|
53
59
|
period => daily,
|
54
|
-
range
|
60
|
+
range => "2 - 4",
|
55
61
|
}
|
56
|
-
|
57
|
-
exec {
|
58
|
-
schedule => daily
|
62
|
+
|
63
|
+
exec { "/usr/bin/apt-get update":
|
64
|
+
schedule => 'daily',
|
59
65
|
}
|
60
66
|
|
61
|
-
|
67
|
+
EOT
|
62
68
|
isnamevar
|
63
69
|
end
|
64
70
|
|
65
71
|
newparam(:range) do
|
66
|
-
desc
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
desc <<-EOT
|
73
|
+
The earliest and latest that a resource can be applied. This is
|
74
|
+
always a hyphen-separated range within a 24 hour period, and hours
|
75
|
+
must be specified in numbers between 0 and 23, inclusive. Minutes and
|
76
|
+
seconds can optionally be provided, using the normal colon as a
|
77
|
+
separator. For instance:
|
78
|
+
|
79
|
+
schedule { 'maintenance':
|
80
|
+
range => "1:30 - 4:30",
|
74
81
|
}
|
75
82
|
|
76
83
|
This is mostly useful for restricting certain resources to being
|
77
|
-
applied in maintenance windows or during off-peak hours.
|
84
|
+
applied in maintenance windows or during off-peak hours.
|
85
|
+
EOT
|
78
86
|
|
79
87
|
# This is lame; properties all use arrays as values, but parameters don't.
|
80
88
|
# That's going to hurt eventually.
|
@@ -190,24 +198,23 @@ module Puppet
|
|
190
198
|
end
|
191
199
|
|
192
200
|
newparam(:period) do
|
193
|
-
desc
|
194
|
-
a
|
195
|
-
|
196
|
-
Puppet runs, whatever that period is.
|
201
|
+
desc <<-EOT
|
202
|
+
The period of repetition for a resource. The default is for a resource
|
203
|
+
to get applied every time Puppet runs.
|
197
204
|
|
198
205
|
Note that the period defines how often a given resource will get
|
199
206
|
applied but not when; if you would like to restrict the hours
|
200
207
|
that a given resource can be applied (e.g., only at night during
|
201
|
-
a maintenance window) then use the `range` attribute.
|
208
|
+
a maintenance window), then use the `range` attribute.
|
202
209
|
|
203
210
|
If the provided periods are not sufficient, you can provide a
|
204
211
|
value to the *repeat* attribute, which will cause Puppet to
|
205
212
|
schedule the affected resources evenly in the period the
|
206
213
|
specified number of times. Take this schedule:
|
207
214
|
|
208
|
-
schedule { veryoften:
|
215
|
+
schedule { 'veryoften':
|
209
216
|
period => hourly,
|
210
|
-
repeat => 6
|
217
|
+
repeat => 6,
|
211
218
|
}
|
212
219
|
|
213
220
|
This can cause Puppet to apply that resource up to every 10 minutes.
|
@@ -218,7 +225,8 @@ module Puppet
|
|
218
225
|
often (e.g., long-running Puppet runs will squash conflictingly scheduled runs).
|
219
226
|
|
220
227
|
See the `periodmatch` attribute for tuning whether to match
|
221
|
-
times by their distance apart or by their specific value.
|
228
|
+
times by their distance apart or by their specific value.
|
229
|
+
EOT
|
222
230
|
|
223
231
|
newvalues(:hourly, :daily, :weekly, :monthly, :never)
|
224
232
|
|
@@ -268,8 +276,8 @@ module Puppet
|
|
268
276
|
end
|
269
277
|
|
270
278
|
newparam(:repeat) do
|
271
|
-
desc "How often
|
272
|
-
Defaults to 1
|
279
|
+
desc "How often a given resource may be applied in this schedule's `period`.
|
280
|
+
Defaults to 1; must be an integer."
|
273
281
|
|
274
282
|
defaultto 1
|
275
283
|
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'puppet/util'
|
2
|
+
|
3
|
+
Puppet::Type.newtype(:scheduled_task) do
|
4
|
+
include Puppet::Util
|
5
|
+
|
6
|
+
@doc = "Installs and manages Windows Scheduled Tasks. All fields
|
7
|
+
except the name, command, and start_time are optional; specifying
|
8
|
+
no repetition parameters will result in a task that runs once on
|
9
|
+
the start date.
|
10
|
+
|
11
|
+
Examples:
|
12
|
+
|
13
|
+
# Create a task that will fire on August 31st, 2011 at 8am in
|
14
|
+
# the system's time-zone.
|
15
|
+
scheduled_task { 'One-shot task':
|
16
|
+
ensure => present,
|
17
|
+
enabled => true,
|
18
|
+
command => 'C:\path\to\command.exe',
|
19
|
+
arguments => '/flags /to /pass',
|
20
|
+
trigger => {
|
21
|
+
schedule => once,
|
22
|
+
start_date => '2011-08-31', # Defaults to 'today'
|
23
|
+
start_time => '08:00', # Must be specified
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
# Create a task that will fire every other day at 8am in the
|
28
|
+
# system's time-zone, starting August 31st, 2011.
|
29
|
+
scheduled_task { 'Daily task':
|
30
|
+
ensure => present,
|
31
|
+
enabled => true,
|
32
|
+
command => 'C:\path\to\command.exe',
|
33
|
+
arguments => '/flags /to /pass',
|
34
|
+
trigger => {
|
35
|
+
schedule => daily,
|
36
|
+
every => 2 # Defaults to 1
|
37
|
+
start_date => '2011-08-31', # Defaults to 'today'
|
38
|
+
start_time => '08:00', # Must be specified
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
# Create a task that will fire at 8am Monday every third week,
|
43
|
+
# starting after August 31st, 2011.
|
44
|
+
scheduled_task { 'Weekly task':
|
45
|
+
ensure => present,
|
46
|
+
enabled => true,
|
47
|
+
command => 'C:\path\to\command.exe',
|
48
|
+
arguments => '/flags /to /pass',
|
49
|
+
trigger => {
|
50
|
+
schedule => weekly,
|
51
|
+
every => 3, # Defaults to 1
|
52
|
+
start_date => '2011-08-31' # Defaults to 'today'
|
53
|
+
start_time => '08:00', # Must be specified
|
54
|
+
day_of_week => [mon], # Defaults to all
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
# Create a task that will fire at 8am on the 1st, 15th, and last
|
59
|
+
# day of the month in January, March, May, July, September, and
|
60
|
+
# November starting August 31st, 2011.
|
61
|
+
scheduled_task { 'Monthly date task':
|
62
|
+
ensure => present,
|
63
|
+
enabled => true,
|
64
|
+
command => 'C:\path\to\command.exe',
|
65
|
+
arguments => '/flags /to /pass',
|
66
|
+
trigger => {
|
67
|
+
schedule => monthly,
|
68
|
+
start_date => '2011-08-31', # Defaults to 'today'
|
69
|
+
start_time => '08:00', # Must be specified
|
70
|
+
months => [1,3,5,7,9,11], # Defaults to all
|
71
|
+
on => [1, 15, last], # Must be specified
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
# Create a task that will fire at 8am on the first Monday of the
|
76
|
+
# month for January, March, and May, after August 31st, 2011.
|
77
|
+
scheduled_task { 'Monthly day of week task':
|
78
|
+
enabled => true,
|
79
|
+
ensure => present,
|
80
|
+
command => 'C:\path\to\command.exe',
|
81
|
+
arguments => '/flags /to /pass',
|
82
|
+
trigger => {
|
83
|
+
schedule => monthly,
|
84
|
+
start_date => '2011-08-31', # Defaults to 'today'
|
85
|
+
start_time => '08:00', # Must be specified
|
86
|
+
months => [1,3,5], # Defaults to all
|
87
|
+
which_occurrence => first, # Must be specified
|
88
|
+
day_of_week => [mon], # Must be specified
|
89
|
+
}
|
90
|
+
}"
|
91
|
+
|
92
|
+
ensurable
|
93
|
+
|
94
|
+
newproperty(:enabled) do
|
95
|
+
desc "Whether the triggers for this task are enabled. This only
|
96
|
+
supports enabling or disabling all of the triggers for a task,
|
97
|
+
not enabling or disabling them on an individual basis."
|
98
|
+
|
99
|
+
newvalue(:true, :event => :task_enabled)
|
100
|
+
newvalue(:false, :event => :task_disabled)
|
101
|
+
|
102
|
+
defaultto(:true)
|
103
|
+
end
|
104
|
+
|
105
|
+
newparam(:name) do
|
106
|
+
desc "The name assigned to the scheduled task. This will uniquely
|
107
|
+
identify the task on the system."
|
108
|
+
|
109
|
+
isnamevar
|
110
|
+
end
|
111
|
+
|
112
|
+
newproperty(:command) do
|
113
|
+
desc "The full path to the application to be run, without any
|
114
|
+
arguments."
|
115
|
+
|
116
|
+
validate do |value|
|
117
|
+
raise Puppet::Error.new('Must be specified using an absolute path.') unless absolute_path?(value)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
newproperty(:working_dir) do
|
122
|
+
desc "The full path of the directory in which to start the
|
123
|
+
command"
|
124
|
+
|
125
|
+
validate do |value|
|
126
|
+
raise Puppet::Error.new('Must be specified using an absolute path.') unless absolute_path?(value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
newproperty(:arguments, :array_matching => :all) do
|
131
|
+
desc "The optional arguments to pass to the command."
|
132
|
+
end
|
133
|
+
|
134
|
+
newproperty(:user) do
|
135
|
+
desc "The user to run the scheduled task as. Please note that not
|
136
|
+
all security configurations will allow running a scheduled task
|
137
|
+
as 'SYSTEM', and saving the scheduled task under these
|
138
|
+
conditions will fail with a reported error of 'The operation
|
139
|
+
completed successfully'. It is recommended that you either
|
140
|
+
choose another user to run the scheduled task, or alter the
|
141
|
+
security policy to allow v1 scheduled tasks to run as the
|
142
|
+
'SYSTEM' account. Defaults to 'SYSTEM'."
|
143
|
+
|
144
|
+
defaultto :system
|
145
|
+
|
146
|
+
def insync?(current)
|
147
|
+
provider.user_insync?(current, @should)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
newparam(:password) do
|
152
|
+
desc "The password for the user specified in the 'user' property.
|
153
|
+
This is only used if specifying a user other than 'SYSTEM'.
|
154
|
+
Since there is no way to retrieve the password used to set the
|
155
|
+
account information for a task, this parameter will not be used
|
156
|
+
to determine if a scheduled task is in sync or not."
|
157
|
+
end
|
158
|
+
|
159
|
+
newproperty(:trigger, :array_matching => :all) do
|
160
|
+
desc "This is a hash defining the properties of the trigger used
|
161
|
+
to fire the scheduled task. The one key that is always required
|
162
|
+
is 'schedule', which can be one of 'daily', 'weekly', or
|
163
|
+
'monthly'. The other valid & required keys depend on the value
|
164
|
+
of schedule.
|
165
|
+
|
166
|
+
When schedule is 'daily', you can specify a value for 'every'
|
167
|
+
which specifies that the task will trigger every N days. If
|
168
|
+
'every' is not specified, it defaults to 1 (running every day).
|
169
|
+
|
170
|
+
When schedule is 'weekly', you can specify values for 'every',
|
171
|
+
and 'day_of_week'. 'every' has similar behavior as when
|
172
|
+
specified for 'daily', though it repeats every N weeks, instead
|
173
|
+
of every N days. 'day_of_week' is used to specify on which days
|
174
|
+
of the week the task should be run. This can be specified as an
|
175
|
+
array where the possible values are 'mon', 'tues', 'wed',
|
176
|
+
'thurs', 'fri', 'sat', and 'sun', or as the string 'all'. The
|
177
|
+
default is 'all'.
|
178
|
+
|
179
|
+
When schedule is 'monthly', the syntax depends on whether you
|
180
|
+
wish to specify the trigger using absolute, or relative dates.
|
181
|
+
In either case, you can specify which months this trigger
|
182
|
+
applies to using 'months', and specifying an array of integer
|
183
|
+
months. 'months' defaults to all months.
|
184
|
+
|
185
|
+
When specifying a monthly schedule with absolute dates, 'on'
|
186
|
+
must be provided as an array of days (1-31, or the special value
|
187
|
+
'last' which will always be the last day of the month).
|
188
|
+
|
189
|
+
When specifying a monthly schedule with relative dates,
|
190
|
+
'which_occurrence', and 'day_of_week' must be specified. The
|
191
|
+
possible values for 'which_occurrence' are 'first', 'second',
|
192
|
+
'third', 'fourth', 'fifth', and 'last'. 'day_of_week' is an
|
193
|
+
array where the possible values are 'mon', 'tues', 'wed',
|
194
|
+
'thurs', 'fri', 'sat', and 'sun'. These combine to be able to
|
195
|
+
specify things like: The task should run on the first Monday of
|
196
|
+
the specified month(s)."
|
197
|
+
|
198
|
+
validate do |value|
|
199
|
+
provider.validate_trigger(value)
|
200
|
+
end
|
201
|
+
|
202
|
+
def insync?(current)
|
203
|
+
provider.trigger_insync?(current, @should)
|
204
|
+
end
|
205
|
+
|
206
|
+
def should_to_s(new_value=@should)
|
207
|
+
self.class.format_value_for_display(new_value)
|
208
|
+
end
|
209
|
+
|
210
|
+
def is_to_s(current_value=@is)
|
211
|
+
self.class.format_value_for_display(current_value)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
validate do
|
216
|
+
return true if self[:ensure] == :absent
|
217
|
+
|
218
|
+
if self[:arguments] and !(self[:arguments].is_a?(Array) and self[:arguments].length == 1)
|
219
|
+
self.fail('Parameter arguments failed: Must be specified as a single string')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|