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
@@ -4,8 +4,8 @@ Puppet::Type.type(:service).provide :base do
|
|
4
4
|
You have to specify enough about your service for this to work; the
|
5
5
|
minimum you can specify is a binary for starting the process, and this
|
6
6
|
same binary will be searched for in the process table to stop the
|
7
|
-
service.
|
8
|
-
|
7
|
+
service. As with `init`-style services, it is preferable to specify start,
|
8
|
+
stop, and status commands.
|
9
9
|
|
10
10
|
"
|
11
11
|
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# Manage FreeBSD services.
|
2
2
|
Puppet::Type.type(:service).provide :bsd, :parent => :init do
|
3
|
-
desc
|
3
|
+
desc <<-EOT
|
4
|
+
FreeBSD's (and probably NetBSD's?) form of `init`-style service management.
|
4
5
|
|
5
|
-
|
6
|
+
Uses `rc.conf.d` for service enabling and disabling.
|
6
7
|
|
7
|
-
|
8
|
+
EOT
|
8
9
|
|
9
10
|
confine :operatingsystem => [:freebsd, :netbsd, :openbsd]
|
10
11
|
|
@@ -2,42 +2,42 @@
|
|
2
2
|
#
|
3
3
|
# author Brice Figureau <brice-puppet@daysofwonder.com>
|
4
4
|
Puppet::Type.type(:service).provide :daemontools, :parent => :base do
|
5
|
-
desc
|
5
|
+
desc <<-EOT
|
6
|
+
Daemontools service management.
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
This provider manages daemons supervised by D.J. Bernstein daemontools.
|
9
|
+
When detecting the service directory it will check, in order of preference:
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
* `/service`
|
12
|
+
* `/etc/service`
|
13
|
+
* `/var/lib/svscan`
|
13
14
|
|
14
|
-
|
15
|
-
by default in:
|
15
|
+
The daemon directory should be in one of the following locations:
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
* `/var/lib/service`
|
18
|
+
* `/etc`
|
19
19
|
|
20
|
-
|
20
|
+
...or this can be overriden in the resource's attributes:
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
service { "myservice":
|
23
|
+
provider => "daemontools",
|
24
|
+
path => "/path/to/daemons",
|
25
|
+
}
|
26
26
|
|
27
|
-
|
27
|
+
This provider supports out of the box:
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
* start/stop (mapped to enable/disable)
|
30
|
+
* enable/disable
|
31
|
+
* restart
|
32
|
+
* status
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
If a service has `ensure => "running"`, it will link /path/to/daemon to
|
35
|
+
/path/to/service, which will automatically enable the service.
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
If a service has `ensure => "stopped"`, it will only shut down the service, not
|
38
|
+
remove the `/path/to/service` link.
|
39
39
|
|
40
|
-
|
40
|
+
EOT
|
41
41
|
|
42
42
|
commands :svc => "/usr/bin/svc", :svstat => "/usr/bin/svstat"
|
43
43
|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# Manage debian services. Start/stop is the same as InitSvc, but enable/disable
|
2
2
|
# is special.
|
3
3
|
Puppet::Type.type(:service).provide :debian, :parent => :init do
|
4
|
-
desc
|
4
|
+
desc <<-EOT
|
5
|
+
Debian's form of `init`-style management.
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
The only differences from `init` are support for enabling and disabling
|
8
|
+
services via `update-rc.d` and the ability to determine enabled status via
|
9
|
+
`invoke-rc.d`.
|
8
10
|
|
9
|
-
|
11
|
+
EOT
|
10
12
|
|
11
13
|
commands :update_rc => "/usr/sbin/update-rc.d"
|
12
14
|
# note this isn't being used as a command until
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Puppet::Type.type(:service).provide :freebsd, :parent => :init do
|
2
2
|
|
3
|
-
desc "Provider for FreeBSD.
|
3
|
+
desc "Provider for FreeBSD. Uses the `rcvar` argument of init scripts and parses/edits rc files."
|
4
4
|
|
5
5
|
confine :operatingsystem => [:freebsd]
|
6
6
|
defaultfor :operatingsystem => [:freebsd]
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# Manage gentoo services. Start/stop is the same as InitSvc, but enable/disable
|
2
2
|
# is special.
|
3
3
|
Puppet::Type.type(:service).provide :gentoo, :parent => :init do
|
4
|
-
desc
|
4
|
+
desc <<-EOT
|
5
|
+
Gentoo's form of `init`-style service management.
|
5
6
|
|
6
|
-
|
7
|
+
Uses `rc-update` for service enabling and disabling.
|
7
8
|
|
8
|
-
|
9
|
+
EOT
|
9
10
|
|
10
11
|
commands :update => "/sbin/rc-update"
|
11
12
|
|
@@ -1,14 +1,7 @@
|
|
1
1
|
# The standard init-based service type. Many other service types are
|
2
2
|
# customizations of this module.
|
3
3
|
Puppet::Type.type(:service).provide :init, :parent => :base do
|
4
|
-
desc "Standard init service management.
|
5
|
-
|
6
|
-
This provider assumes that the init script has no `status` command,
|
7
|
-
because so few scripts do, so you need to either provide a status
|
8
|
-
command or specify via `hasstatus` that one already exists in the
|
9
|
-
init script.
|
10
|
-
|
11
|
-
"
|
4
|
+
desc "Standard `init`-style service management."
|
12
5
|
|
13
6
|
class << self
|
14
7
|
attr_accessor :defpath
|
@@ -19,6 +12,8 @@ Puppet::Type.type(:service).provide :init, :parent => :base do
|
|
19
12
|
@defpath = ["/etc/rc.d", "/usr/local/etc/rc.d"]
|
20
13
|
when "HP-UX"
|
21
14
|
@defpath = "/sbin/init.d"
|
15
|
+
when "Archlinux"
|
16
|
+
@defpath = "/etc/rc.d"
|
22
17
|
else
|
23
18
|
@defpath = "/etc/init.d"
|
24
19
|
end
|
@@ -1,114 +1,167 @@
|
|
1
1
|
require 'facter/util/plist'
|
2
|
-
|
3
2
|
Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
4
|
-
desc
|
3
|
+
desc <<-EOT
|
4
|
+
This provider manages jobs with `launchd`, which is the default service
|
5
|
+
framework for Mac OS X (and may be available for use on other platforms).
|
5
6
|
|
6
|
-
|
7
|
-
Mac OS X and is potentially available for use on other platforms.
|
7
|
+
For `launchd` documentation, see:
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
* http://developer.apple.com/macosx/launchd.html
|
12
|
-
* http://launchd.macosforge.org/
|
9
|
+
* <http://developer.apple.com/macosx/launchd.html>
|
10
|
+
* <http://launchd.macosforge.org/>
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
* /System/Library/LaunchDaemons
|
17
|
-
* /System/Library/LaunchAgents
|
18
|
-
* /Library/LaunchDaemons
|
19
|
-
* /Library/LaunchAgents
|
12
|
+
This provider reads plists out of the following directories:
|
20
13
|
|
21
|
-
|
14
|
+
* `/System/Library/LaunchDaemons`
|
15
|
+
* `/System/Library/LaunchAgents`
|
16
|
+
* `/Library/LaunchDaemons`
|
17
|
+
* `/Library/LaunchAgents`
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
* ensure => running/stopped,
|
26
|
-
* enable => true/false
|
27
|
-
* status
|
28
|
-
* restart
|
19
|
+
...and builds up a list of services based upon each plist's "Label" entry.
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
21
|
+
This provider supports:
|
22
|
+
|
23
|
+
* ensure => running/stopped,
|
24
|
+
* enable => true/false
|
25
|
+
* status
|
26
|
+
* restart
|
27
|
+
|
28
|
+
Here is how the Puppet states correspond to `launchd` states:
|
29
|
+
|
30
|
+
* stopped --- job unloaded
|
31
|
+
* started --- job loaded
|
32
|
+
* enabled --- 'Disable' removed from job plist file
|
33
|
+
* disabled --- 'Disable' added to job plist file
|
36
34
|
|
37
|
-
|
38
|
-
|
35
|
+
Note that this allows you to do something `launchctl` can't do, which is to
|
36
|
+
be in a state of "stopped/enabled" or "running/disabled".
|
39
37
|
|
40
|
-
|
38
|
+
EOT
|
39
|
+
|
40
|
+
include Puppet::Util::Warnings
|
41
41
|
|
42
42
|
commands :launchctl => "/bin/launchctl"
|
43
|
-
commands :sw_vers
|
44
|
-
commands :plutil
|
43
|
+
commands :sw_vers => "/usr/bin/sw_vers"
|
44
|
+
commands :plutil => "/usr/bin/plutil"
|
45
45
|
|
46
46
|
defaultfor :operatingsystem => :darwin
|
47
|
-
confine :operatingsystem
|
47
|
+
confine :operatingsystem => :darwin
|
48
48
|
|
49
49
|
has_feature :enableable
|
50
|
+
mk_resource_methods
|
50
51
|
|
51
|
-
Launchd_Paths = ["/Library/LaunchAgents",
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
Launchd_Paths = [ "/Library/LaunchAgents",
|
53
|
+
"/Library/LaunchDaemons",
|
54
|
+
"/System/Library/LaunchAgents",
|
55
|
+
"/System/Library/LaunchDaemons"]
|
55
56
|
|
56
57
|
Launchd_Overrides = "/var/db/launchd.db/com.apple.launchd/overrides.plist"
|
58
|
+
|
59
|
+
# Caching is enabled through the following three methods. Self.prefetch will
|
60
|
+
# call self.instances to create an instance for each service. Self.flush will
|
61
|
+
# clear out our cache when we're done.
|
62
|
+
def self.prefetch(resources)
|
63
|
+
instances.each do |prov|
|
64
|
+
if resource = resources[prov.name]
|
65
|
+
resource.provider = prov
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
57
69
|
|
58
|
-
|
59
|
-
#
|
60
|
-
#
|
61
|
-
def self.
|
62
|
-
|
70
|
+
# Self.instances will return an array with each element being a hash
|
71
|
+
# containing the name, provider, path, and status of each service on the
|
72
|
+
# system.
|
73
|
+
def self.instances
|
74
|
+
jobs = self.jobsearch
|
75
|
+
@job_list ||= self.job_list
|
76
|
+
jobs.keys.collect do |job|
|
77
|
+
job_status = @job_list.has_key?(job) ? :running : :stopped
|
78
|
+
new(:name => job, :provider => :launchd, :path => jobs[job], :status => job_status)
|
79
|
+
end
|
63
80
|
end
|
64
81
|
|
65
|
-
#
|
66
|
-
#
|
82
|
+
# Sets a class instance variable with a hash of all launchd plist files that
|
83
|
+
# are found on the system. The key of the hash is the job id and the value
|
84
|
+
# is the path to the file. If a label is passed, we return the job id and
|
85
|
+
# path for that specific job.
|
67
86
|
def self.jobsearch(label=nil)
|
68
|
-
label_to_path_map
|
69
|
-
|
70
|
-
|
71
|
-
Dir.
|
72
|
-
next if
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
else
|
79
|
-
label_to_path_map[job["Label"]] = fullpath
|
80
|
-
end
|
87
|
+
@label_to_path_map ||= {}
|
88
|
+
if @label_to_path_map.empty?
|
89
|
+
Launchd_Paths.each do |path|
|
90
|
+
Dir.glob(File.join(path,'*')).each do |filepath|
|
91
|
+
next if ! File.file?(filepath)
|
92
|
+
job = read_plist(filepath)
|
93
|
+
if job.has_key?("Label") and job["Label"] == label
|
94
|
+
return { label => filepath }
|
95
|
+
else
|
96
|
+
@label_to_path_map[job["Label"]] = filepath
|
81
97
|
end
|
82
98
|
end
|
83
99
|
end
|
84
100
|
end
|
85
101
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
102
|
+
if label
|
103
|
+
if @label_to_path_map.has_key? label
|
104
|
+
return { label => @label_to_path_map[label] }
|
105
|
+
else
|
106
|
+
raise Puppet::Error.new("Unable to find launchd plist for job: #{label}")
|
107
|
+
end
|
108
|
+
else
|
109
|
+
@label_to_path_map
|
110
|
+
end
|
90
111
|
end
|
91
112
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
113
|
+
# This status method lists out all currently running services.
|
114
|
+
# This hash is returned at the end of the method.
|
115
|
+
def self.job_list
|
116
|
+
@job_list = Hash.new
|
117
|
+
begin
|
118
|
+
output = launchctl :list
|
119
|
+
raise Puppet::Error.new("launchctl list failed to return any data.") if output.nil?
|
120
|
+
output.split("\n").each do |line|
|
121
|
+
@job_list[line.split(/\s/).last] = :running
|
122
|
+
end
|
123
|
+
rescue Puppet::ExecutionFailure
|
124
|
+
raise Puppet::Error.new("Unable to determine status of #{resource[:name]}")
|
97
125
|
end
|
126
|
+
@job_list
|
127
|
+
end
|
128
|
+
|
129
|
+
# Launchd implemented plist overrides in version 10.6.
|
130
|
+
# This method checks the major_version of OS X and returns true if
|
131
|
+
# it is 10.6 or greater. This allows us to implement different plist
|
132
|
+
# behavior for versions >= 10.6
|
133
|
+
def has_macosx_plist_overrides?
|
134
|
+
@product_version ||= self.class.get_macosx_version_major
|
135
|
+
return true unless /^10\.[0-5]/.match(@product_version)
|
136
|
+
return false
|
98
137
|
end
|
99
138
|
|
139
|
+
# Read a plist, whether its format is XML or in Apple's "binary1"
|
140
|
+
# format.
|
141
|
+
def self.read_plist(path)
|
142
|
+
Plist::parse_xml(plutil('-convert', 'xml1', '-o', '/dev/stdout', path))
|
143
|
+
end
|
144
|
+
|
145
|
+
# Clean out the @property_hash variable containing the cached list of services
|
146
|
+
def flush
|
147
|
+
@property_hash.clear
|
148
|
+
end
|
149
|
+
|
150
|
+
def exists?
|
151
|
+
Puppet.debug("Puppet::Provider::Launchd:Ensure for #{@property_hash[:name]}: #{@property_hash[:ensure]}")
|
152
|
+
@property_hash[:ensure] != :absent
|
153
|
+
end
|
100
154
|
|
101
155
|
def self.get_macosx_version_major
|
102
|
-
return @macosx_version_major if
|
156
|
+
return @macosx_version_major if @macosx_version_major
|
103
157
|
begin
|
104
158
|
# Make sure we've loaded all of the facts
|
105
159
|
Facter.loadfacts
|
106
|
-
|
107
160
|
if Facter.value(:macosx_productversion_major)
|
108
161
|
product_version_major = Facter.value(:macosx_productversion_major)
|
109
162
|
else
|
110
163
|
# TODO: remove this code chunk once we require Facter 1.5.5 or higher.
|
111
|
-
|
164
|
+
warnonce("DEPRECATION WARNING: Future versions of the launchd provider will require Facter 1.5.5 or newer.")
|
112
165
|
product_version = Facter.value(:macosx_productversion)
|
113
166
|
fail("Could not determine OS X version from Facter") if product_version.nil?
|
114
167
|
product_version_major = product_version.scan(/(\d+)\.(\d+)./).join(".")
|
@@ -135,26 +188,6 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
135
188
|
[job_path, job_plist]
|
136
189
|
end
|
137
190
|
|
138
|
-
|
139
|
-
def status
|
140
|
-
# launchctl list <jobname> exits zero if the job is loaded
|
141
|
-
# and non-zero if it isn't. Simple way to check... but is only
|
142
|
-
# available on OS X 10.5 unfortunately, so we grab the whole list
|
143
|
-
# and check if our resource is included. The output formats differ
|
144
|
-
# between 10.4 and 10.5, thus the necessity for splitting
|
145
|
-
begin
|
146
|
-
output = launchctl :list
|
147
|
-
raise Puppet::Error.new("launchctl list failed to return any data.") if output.nil?
|
148
|
-
output.split("\n").each do |j|
|
149
|
-
return :running if j.split(/\s/).last == resource[:name]
|
150
|
-
end
|
151
|
-
return :stopped
|
152
|
-
rescue Puppet::ExecutionFailure
|
153
|
-
raise Puppet::Error.new("Unable to determine status of #{resource[:name]}")
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
|
158
191
|
# start the service. To get to a state of running/enabled, we need to
|
159
192
|
# conditionally enable at load, then disable by modifying the plist file
|
160
193
|
# directly.
|
@@ -200,8 +233,8 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
200
233
|
|
201
234
|
# launchd jobs are enabled by default. They are only disabled if the key
|
202
235
|
# "Disabled" is set to true, but it can also be set to false to enable it.
|
203
|
-
#
|
204
|
-
# is no entry in the global overrides plist.
|
236
|
+
# Starting in 10.6, the Disabled key in the job plist is consulted, but only
|
237
|
+
# if there is no entry in the global overrides plist.
|
205
238
|
# We need to draw a distinction between undefined, true and false for both
|
206
239
|
# locations where the Disabled flag can be defined.
|
207
240
|
def enabled?
|
@@ -211,7 +244,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
211
244
|
job_path, job_plist = plist_from_label(resource[:name])
|
212
245
|
job_plist_disabled = job_plist["Disabled"] if job_plist.has_key?("Disabled")
|
213
246
|
|
214
|
-
if
|
247
|
+
if has_macosx_plist_overrides?
|
215
248
|
if FileTest.file?(Launchd_Overrides) and overrides = self.class.read_plist(Launchd_Overrides)
|
216
249
|
if overrides.has_key?(resource[:name])
|
217
250
|
overrides_disabled = overrides[resource[:name]]["Disabled"] if overrides[resource[:name]].has_key?("Disabled")
|
@@ -233,10 +266,10 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
233
266
|
# enable and disable are a bit hacky. We write out the plist with the appropriate value
|
234
267
|
# rather than dealing with launchctl as it is unable to change the Disabled flag
|
235
268
|
# without actually loading/unloading the job.
|
236
|
-
#
|
237
|
-
# versions this is stored in the job plist itself.
|
269
|
+
# Starting in 10.6 we need to write out a disabled key to the global
|
270
|
+
# overrides plist, in earlier versions this is stored in the job plist itself.
|
238
271
|
def enable
|
239
|
-
if
|
272
|
+
if has_macosx_plist_overrides?
|
240
273
|
overrides = self.class.read_plist(Launchd_Overrides)
|
241
274
|
overrides[resource[:name]] = { "Disabled" => false }
|
242
275
|
Plist::Emit.save_plist(overrides, Launchd_Overrides)
|
@@ -251,7 +284,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do
|
|
251
284
|
|
252
285
|
|
253
286
|
def disable
|
254
|
-
if
|
287
|
+
if has_macosx_plist_overrides?
|
255
288
|
overrides = self.class.read_plist(Launchd_Overrides)
|
256
289
|
overrides[resource[:name]] = { "Disabled" => true }
|
257
290
|
Plist::Emit.save_plist(overrides, Launchd_Overrides)
|