puppet 2.7.3 → 2.7.4
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 +166 -0
- data/install.rb +27 -7
- data/lib/puppet/application/agent.rb +29 -29
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/application/inspect.rb +9 -1
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/application/queue.rb +1 -1
- data/lib/puppet/application/resource.rb +3 -0
- data/lib/puppet/application.rb +4 -5
- data/lib/puppet/configurer.rb +1 -4
- data/lib/puppet/defaults.rb +45 -15
- data/lib/puppet/feature/base.rb +28 -17
- data/lib/puppet/feature/rails.rb +0 -3
- data/lib/puppet/feature/rubygems.rb +0 -3
- data/lib/puppet/file_bucket/dipper.rb +3 -2
- data/lib/puppet/file_bucket/file.rb +3 -3
- data/lib/puppet/file_serving/base.rb +4 -5
- data/lib/puppet/file_serving/configuration.rb +7 -13
- data/lib/puppet/file_serving/content.rb +0 -4
- data/lib/puppet/file_serving/fileset.rb +7 -6
- data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
- data/lib/puppet/file_serving/metadata.rb +0 -4
- data/lib/puppet/file_serving/mount/file.rb +9 -12
- data/lib/puppet/file_serving/mount.rb +0 -5
- data/lib/puppet/file_serving/terminus_helper.rb +0 -4
- data/lib/puppet/file_serving.rb +0 -4
- data/lib/puppet/indirector/catalog/compiler.rb +0 -18
- data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
- data/lib/puppet/indirector/direct_file_server.rb +0 -4
- data/lib/puppet/indirector/facts/facter.rb +2 -2
- data/lib/puppet/indirector/facts/store_configs.rb +5 -0
- data/lib/puppet/indirector/file_content/file.rb +0 -4
- data/lib/puppet/indirector/file_content/file_server.rb +0 -4
- data/lib/puppet/indirector/file_content/rest.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file.rb +0 -4
- data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
- data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
- data/lib/puppet/indirector/file_server.rb +1 -5
- data/lib/puppet/indirector/indirection.rb +3 -5
- data/lib/puppet/indirector/node/store_configs.rb +5 -0
- data/lib/puppet/indirector/request.rb +3 -1
- data/lib/puppet/indirector/resource/active_record.rb +97 -0
- data/lib/puppet/indirector/resource/store_configs.rb +3 -0
- data/lib/puppet/indirector/ssl_file.rb +5 -1
- data/lib/puppet/indirector/store_configs.rb +30 -0
- data/lib/puppet/indirector/yaml.rb +5 -0
- data/lib/puppet/indirector.rb +7 -0
- data/lib/puppet/network/client.rb +0 -5
- data/lib/puppet/network/http_pool.rb +0 -56
- data/lib/puppet/node/environment.rb +9 -11
- data/lib/puppet/parameter/path.rb +1 -5
- data/lib/puppet/parameter.rb +1 -7
- data/lib/puppet/parser/ast/collection.rb +2 -2
- data/lib/puppet/parser/ast/collexpr.rb +10 -39
- data/lib/puppet/parser/collector.rb +41 -90
- data/lib/puppet/parser/compiler.rb +0 -3
- data/lib/puppet/parser/functions/create_resources.rb +22 -10
- data/lib/puppet/parser/functions/versioncmp.rb +9 -6
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/parser/type_loader.rb +2 -1
- data/lib/puppet/provider/augeas/augeas.rb +5 -3
- data/lib/puppet/provider/cron/crontab.rb +2 -2
- data/lib/puppet/provider/exec/posix.rb +23 -96
- data/lib/puppet/provider/exec/shell.rb +11 -2
- data/lib/puppet/provider/exec/windows.rb +35 -0
- data/lib/puppet/provider/exec.rb +79 -0
- data/lib/puppet/provider/group/windows_adsi.rb +48 -0
- data/lib/puppet/provider/host/parsed.rb +3 -0
- data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
- data/lib/puppet/provider/mount.rb +0 -3
- data/lib/puppet/provider/naginator.rb +0 -3
- data/lib/puppet/provider/package/appdmg.rb +0 -1
- data/lib/puppet/provider/package/apple.rb +3 -7
- data/lib/puppet/provider/package/apt.rb +0 -1
- data/lib/puppet/provider/package/aptitude.rb +0 -1
- data/lib/puppet/provider/package/aptrpm.rb +0 -1
- data/lib/puppet/provider/package/blastwave.rb +0 -1
- data/lib/puppet/provider/package/dpkg.rb +5 -6
- data/lib/puppet/provider/package/fink.rb +3 -4
- data/lib/puppet/provider/package/freebsd.rb +0 -1
- data/lib/puppet/provider/package/gem.rb +0 -1
- data/lib/puppet/provider/package/hpux.rb +3 -3
- data/lib/puppet/provider/package/macports.rb +0 -1
- data/lib/puppet/provider/package/msi.rb +82 -0
- data/lib/puppet/provider/package/openbsd.rb +18 -19
- data/lib/puppet/provider/package/pip.rb +0 -1
- data/lib/puppet/provider/package/pkg.rb +0 -1
- data/lib/puppet/provider/package/pkgdmg.rb +9 -7
- data/lib/puppet/provider/package/pkgutil.rb +0 -1
- data/lib/puppet/provider/package/ports.rb +0 -1
- data/lib/puppet/provider/package/portupgrade.rb +183 -193
- data/lib/puppet/provider/package/rpm.rb +1 -1
- data/lib/puppet/provider/package/sun.rb +0 -1
- data/lib/puppet/provider/package/sunfreeware.rb +0 -2
- data/lib/puppet/provider/package/up2date.rb +0 -1
- data/lib/puppet/provider/package/urpmi.rb +0 -1
- data/lib/puppet/provider/package/yum.rb +1 -1
- data/lib/puppet/provider/package.rb +4 -3
- data/lib/puppet/provider/service/systemd.rb +64 -0
- data/lib/puppet/provider/service/windows.rb +110 -0
- data/lib/puppet/provider/user/windows_adsi.rb +71 -0
- data/lib/puppet/rails/resource.rb +1 -1
- data/lib/puppet/relationship.rb +0 -3
- data/lib/puppet/reports/tagmail.rb +15 -11
- data/lib/puppet/resource/catalog.rb +17 -24
- data/lib/puppet/ssl/certificate_authority.rb +7 -5
- data/lib/puppet/ssl/host.rb +6 -10
- data/lib/puppet/type/augeas.rb +19 -13
- data/lib/puppet/type/cron.rb +13 -12
- data/lib/puppet/type/exec.rb +17 -17
- data/lib/puppet/type/file/content.rb +7 -3
- data/lib/puppet/type/file/source.rb +14 -9
- data/lib/puppet/type/file.rb +44 -23
- data/lib/puppet/type/filebucket.rb +13 -5
- data/lib/puppet/type/package.rb +14 -1
- data/lib/puppet/type/service.rb +11 -1
- data/lib/puppet/type/ssh_authorized_key.rb +3 -1
- data/lib/puppet/type.rb +8 -17
- data/lib/puppet/util/adsi.rb +278 -0
- data/lib/puppet/util/autoload.rb +0 -2
- data/lib/puppet/util/cacher.rb +15 -67
- data/lib/puppet/util/feature.rb +0 -3
- data/lib/puppet/util/graph.rb +0 -3
- data/lib/puppet/util/ldap/connection.rb +0 -3
- data/lib/puppet/util/ldap/generator.rb +0 -3
- data/lib/puppet/util/ldap.rb +0 -3
- data/lib/puppet/util/log_paths.rb +0 -3
- data/lib/puppet/util/network_device/cisco/device.rb +2 -1
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/pidlock.rb +5 -1
- data/lib/puppet/util/rdoc/parser.rb +3 -1
- data/lib/puppet/util/run_mode.rb +2 -2
- data/lib/puppet/util/settings/file_setting.rb +3 -2
- data/lib/puppet/util/settings.rb +4 -6
- data/lib/puppet/util/suidmanager.rb +62 -15
- data/lib/puppet/util.rb +113 -131
- data/lib/puppet.rb +1 -1
- data/spec/integration/application/doc_spec.rb +1 -1
- data/spec/integration/defaults_spec.rb +22 -17
- data/spec/integration/file_serving/content_spec.rb +0 -6
- data/spec/integration/file_serving/metadata_spec.rb +0 -6
- data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
- data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
- data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
- data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
- data/spec/integration/network/server/webrick_spec.rb +6 -9
- data/spec/integration/node/facts_spec.rb +0 -6
- data/spec/integration/node_spec.rb +3 -4
- data/spec/integration/parser/compiler_spec.rb +2 -1
- data/spec/integration/parser/parser_spec.rb +2 -4
- data/spec/integration/provider/mount_spec.rb +1 -1
- data/spec/integration/provider/package_spec.rb +13 -3
- data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
- data/spec/integration/reports_spec.rb +0 -4
- data/spec/integration/resource/catalog_spec.rb +0 -5
- data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
- data/spec/integration/ssl/certificate_request_spec.rb +10 -17
- data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
- data/spec/integration/ssl/host_spec.rb +8 -14
- data/spec/integration/transaction/report_spec.rb +0 -5
- data/spec/integration/transaction_spec.rb +11 -13
- data/spec/integration/type/file_spec.rb +16 -16
- data/spec/integration/type/tidy_spec.rb +1 -1
- data/spec/integration/util/settings_spec.rb +2 -2
- data/spec/integration/util_spec.rb +13 -0
- data/spec/lib/puppet_spec/files.rb +18 -10
- data/spec/shared_behaviours/file_server_terminus.rb +1 -5
- data/spec/shared_behaviours/file_serving.rb +0 -4
- data/spec/shared_behaviours/memory_terminus.rb +0 -4
- data/spec/shared_behaviours/path_parameters.rb +20 -18
- data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/unit/agent_spec.rb +0 -4
- data/spec/unit/application/apply_spec.rb +8 -2
- data/spec/unit/application/certificate_spec.rb +2 -0
- data/spec/unit/application/device_spec.rb +8 -6
- data/spec/unit/application/inspect_spec.rb +2 -1
- data/spec/unit/application/master_spec.rb +7 -2
- data/spec/unit/application/queue_spec.rb +3 -4
- data/spec/unit/application/resource_spec.rb +26 -0
- data/spec/unit/application/secret_agent_spec.rb +3 -1
- data/spec/unit/application_spec.rb +4 -0
- data/spec/unit/configurer/downloader_spec.rb +4 -3
- data/spec/unit/configurer_spec.rb +11 -4
- data/spec/unit/daemon_spec.rb +3 -1
- data/spec/unit/face/ca_spec.rb +1 -1
- data/spec/unit/face/node_spec.rb +5 -1
- data/spec/unit/face/secret_agent_spec.rb +3 -1
- data/spec/unit/file_bucket/dipper_spec.rb +4 -4
- data/spec/unit/file_bucket/file_spec.rb +9 -3
- data/spec/unit/file_serving/configuration_spec.rb +26 -37
- data/spec/unit/file_serving/fileset_spec.rb +71 -55
- data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
- data/spec/unit/file_serving/mount/file_spec.rb +163 -169
- data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
- data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
- data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
- data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
- data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
- data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
- data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
- data/spec/unit/indirector/facts/facter_spec.rb +0 -4
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
- data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
- data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_content/file_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
- data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
- data/spec/unit/indirector/file_server_spec.rb +1 -5
- data/spec/unit/indirector/indirection_spec.rb +0 -4
- data/spec/unit/indirector/key/ca_spec.rb +0 -4
- data/spec/unit/indirector/key/file_spec.rb +0 -4
- data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
- data/spec/unit/indirector/report/processor_spec.rb +0 -4
- data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
- data/spec/unit/indirector/resource/ral_spec.rb +1 -1
- data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
- data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
- data/spec/unit/indirector/ssl_file_spec.rb +25 -6
- data/spec/unit/indirector/store_configs_spec.rb +8 -0
- data/spec/unit/indirector/yaml_spec.rb +14 -0
- data/spec/unit/module_spec.rb +2 -2
- data/spec/unit/network/handler/fileserver_spec.rb +5 -5
- data/spec/unit/network/http/mongrel_spec.rb +0 -4
- data/spec/unit/network/http/webrick_spec.rb +5 -9
- data/spec/unit/network/http_pool_spec.rb +4 -75
- data/spec/unit/network/http_spec.rb +0 -4
- data/spec/unit/network/server_spec.rb +0 -4
- data/spec/unit/node/environment_spec.rb +18 -31
- data/spec/unit/node/facts_spec.rb +0 -4
- data/spec/unit/node_spec.rb +1 -8
- data/spec/unit/other/selinux_spec.rb +3 -1
- data/spec/unit/parameter_spec.rb +0 -10
- data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
- data/spec/unit/parser/collector_spec.rb +147 -263
- data/spec/unit/parser/compiler_spec.rb +3 -1
- data/spec/unit/parser/files_spec.rb +7 -4
- data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
- data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
- data/spec/unit/parser/type_loader_spec.rb +7 -7
- data/spec/unit/property_spec.rb +1 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
- data/spec/unit/provider/exec/posix_spec.rb +102 -106
- data/spec/unit/provider/exec/shell_spec.rb +1 -1
- data/spec/unit/provider/exec/windows_spec.rb +119 -0
- data/spec/unit/provider/group/ldap_spec.rb +0 -4
- data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
- data/spec/unit/provider/ldap_spec.rb +0 -4
- data/spec/unit/provider/macauthorization_spec.rb +5 -0
- data/spec/unit/provider/mount/parsed_spec.rb +1 -5
- data/spec/unit/provider/package/msi_spec.rb +170 -0
- data/spec/unit/provider/service/redhat_spec.rb +2 -0
- data/spec/unit/provider/service/smf_spec.rb +3 -0
- data/spec/unit/provider/service/systemd_spec.rb +25 -0
- data/spec/unit/provider/service/windows_spec.rb +166 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
- data/spec/unit/provider/user/ldap_spec.rb +0 -4
- data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
- data/spec/unit/provider/user/useradd_spec.rb +1 -1
- data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
- data/spec/unit/relationship_spec.rb +0 -4
- data/spec/unit/resource/catalog_spec.rb +37 -25
- data/spec/unit/resource/status_spec.rb +4 -2
- data/spec/unit/resource_spec.rb +5 -5
- data/spec/unit/simple_graph_spec.rb +0 -4
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
- data/spec/unit/ssl/host_spec.rb +12 -13
- data/spec/unit/ssl/inventory_spec.rb +2 -2
- data/spec/unit/sslcertificates/ca_spec.rb +6 -10
- data/spec/unit/transaction/event_manager_spec.rb +4 -2
- data/spec/unit/transaction/event_spec.rb +3 -1
- data/spec/unit/transaction/report_spec.rb +2 -6
- data/spec/unit/transaction/resource_harness_spec.rb +9 -5
- data/spec/unit/transaction_spec.rb +3 -1
- data/spec/unit/type/cron_spec.rb +1 -1
- data/spec/unit/type/exec_spec.rb +80 -47
- data/spec/unit/type/file/checksum_spec.rb +9 -8
- data/spec/unit/type/file/content_spec.rb +2 -1
- data/spec/unit/type/file/selinux_spec.rb +10 -8
- data/spec/unit/type/file/source_spec.rb +18 -36
- data/spec/unit/type/file_spec.rb +170 -217
- data/spec/unit/type/group_spec.rb +1 -1
- data/spec/unit/type/mount_spec.rb +5 -5
- data/spec/unit/type/noop_metaparam_spec.rb +3 -1
- data/spec/unit/type/package_spec.rb +15 -3
- data/spec/unit/type/resources_spec.rb +2 -2
- data/spec/unit/type/service_spec.rb +19 -4
- data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
- data/spec/unit/type/tidy_spec.rb +3 -1
- data/spec/unit/type/user_spec.rb +1 -1
- data/spec/unit/type_spec.rb +29 -34
- data/spec/unit/util/adsi_spec.rb +202 -0
- data/spec/unit/util/autoload_spec.rb +23 -19
- data/spec/unit/util/backups_spec.rb +16 -13
- data/spec/unit/util/cacher_spec.rb +64 -141
- data/spec/unit/util/checksums_spec.rb +0 -4
- data/spec/unit/util/constant_inflector_spec.rb +0 -4
- data/spec/unit/util/execution_stub_spec.rb +1 -1
- data/spec/unit/util/ldap/connection_spec.rb +0 -4
- data/spec/unit/util/ldap/generator_spec.rb +0 -4
- data/spec/unit/util/ldap/manager_spec.rb +0 -4
- data/spec/unit/util/log_spec.rb +4 -2
- data/spec/unit/util/logging_spec.rb +2 -2
- data/spec/unit/util/nagios_maker_spec.rb +0 -4
- data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
- data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
- data/spec/unit/util/network_device/config_spec.rb +5 -3
- data/spec/unit/util/rdoc/parser_spec.rb +7 -1
- data/spec/unit/util/run_mode_spec.rb +6 -2
- data/spec/unit/util/settings/file_setting_spec.rb +29 -2
- data/spec/unit/util/settings_spec.rb +28 -15
- data/spec/unit/util/storage_spec.rb +1 -1
- data/spec/unit/util/suidmanager_spec.rb +310 -0
- data/spec/unit/util/tagging_spec.rb +0 -4
- data/spec/unit/util_spec.rb +335 -0
- data/test/language/ast/variable.rb +0 -4
- data/test/lib/puppettest/support/resources.rb +0 -4
- data/test/lib/puppettest/testcase.rb +0 -4
- data/test/lib/puppettest.rb +0 -1
- data/test/network/handler/master.rb +0 -5
- data/test/network/server/webrick.rb +5 -22
- data/test/ral/manager/attributes.rb +0 -4
- data/test/ral/manager/instances.rb +0 -4
- data/test/ral/manager/manager.rb +0 -4
- data/test/ral/providers/cron/crontab.rb +1 -0
- data/test/ral/providers/service/base.rb +0 -4
- data/test/ral/type/filesources.rb +0 -1
- data/test/ral/type/resources.rb +0 -4
- data/test/util/utiltest.rb +0 -13
- metadata +36 -9
- data/spec/unit/network/client_spec.rb +0 -45
- data/test/puppet/tc_suidmanager.rb +0 -120
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# Whole new package, so include pack stuff
|
3
2
|
require 'puppet/provider/package'
|
4
3
|
|
@@ -9,243 +8,234 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P
|
|
9
8
|
Use the port's full origin as the resource name. eg (ports-mgmt/portupgrade)
|
10
9
|
for the portupgrade port."
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
## has_features is usually autodetected based on defs below.
|
12
|
+
# has_features :installable, :uninstallable, :upgradeable
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
commands :portupgrade => "/usr/local/sbin/portupgrade",
|
15
|
+
:portinstall => "/usr/local/sbin/portinstall",
|
16
|
+
:portversion => "/usr/local/sbin/portversion",
|
17
|
+
:portuninstall => "/usr/local/sbin/pkg_deinstall",
|
18
|
+
:portinfo => "/usr/sbin/pkg_info"
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
## Activate this only once approved by someone important.
|
21
|
+
# defaultfor :operatingsystem => :freebsd
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
# Remove unwanted environment variables.
|
24
|
+
%w{INTERACTIVE UNAME}.each do |var|
|
25
|
+
if ENV.include?(var)
|
26
|
+
ENV.delete(var)
|
27
|
+
end
|
28
|
+
end
|
30
29
|
|
31
|
-
|
30
|
+
######## instances sub command (builds the installed packages list)
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
def self.instances
|
33
|
+
Puppet.debug "portupgrade.rb Building packages list from installed ports"
|
35
34
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
# regex to match output from pkg_info
|
36
|
+
regex = %r{^(\S+)-([^-\s]+):(\S+)$}
|
37
|
+
# Corresponding field names
|
38
|
+
fields = [:portname, :ensure, :portorigin]
|
39
|
+
# define Temporary hash used, packages array of hashes
|
40
|
+
hash = Hash.new
|
41
|
+
packages = []
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
# exec command
|
44
|
+
cmdline = ["-aoQ"]
|
45
|
+
begin
|
46
|
+
output = portinfo(*cmdline)
|
47
|
+
rescue Puppet::ExecutionFailure
|
48
|
+
raise Puppet::Error.new(output)
|
49
|
+
return nil
|
50
|
+
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
#
|
52
|
+
# split output and match it and populate temp hash
|
53
|
+
output.split("\n").each { |data|
|
54
|
+
# reset hash to nil for each line
|
55
|
+
hash.clear
|
56
|
+
if match = regex.match(data)
|
57
|
+
# Output matched regex
|
59
58
|
fields.zip(match.captures) { |field, value|
|
60
59
|
hash[field] = value
|
61
|
-
}
|
62
|
-
|
63
|
-
# populate the actual :name field from the :portorigin
|
64
|
-
# Set :provider to this object name
|
65
|
-
hash[:name] = hash[:portorigin]
|
66
|
-
hash[:provider] = self.name
|
67
|
-
|
68
|
-
# Add to the full packages listing
|
69
|
-
packages << new(hash)
|
70
|
-
|
71
|
-
else
|
72
|
-
# unrecognised output from pkg_info
|
73
|
-
Puppet.debug "portupgrade.Instances() - unable to match output: #{data}"
|
74
|
-
end
|
75
60
|
}
|
76
61
|
|
77
|
-
#
|
78
|
-
|
62
|
+
# populate the actual :name field from the :portorigin
|
63
|
+
# Set :provider to this object name
|
64
|
+
hash[:name] = hash[:portorigin]
|
65
|
+
hash[:provider] = self.name
|
79
66
|
|
80
|
-
|
67
|
+
# Add to the full packages listing
|
68
|
+
packages << new(hash)
|
69
|
+
else
|
70
|
+
# unrecognised output from pkg_info
|
71
|
+
Puppet.debug "portupgrade.Instances() - unable to match output: #{data}"
|
72
|
+
end
|
73
|
+
}
|
74
|
+
|
75
|
+
# return the packages array of hashes
|
76
|
+
return packages
|
77
|
+
end
|
81
78
|
|
82
|
-
|
79
|
+
######## Installation sub command
|
83
80
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
def install
|
82
|
+
Puppet.debug "portupgrade.install() - Installation call on #{@resource[:name]}"
|
83
|
+
# -M: yes, we're a batch, so don't ask any questions
|
84
|
+
cmdline = ["-M BATCH=yes", @resource[:name]]
|
88
85
|
|
89
|
-
#
|
86
|
+
# FIXME: it's possible that portinstall prompts for data so locks up.
|
90
87
|
begin
|
91
88
|
output = portinstall(*cmdline)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
if output =~ /\*\* No such /
|
97
|
-
raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
|
98
|
-
end
|
89
|
+
rescue Puppet::ExecutionFailure
|
90
|
+
raise Puppet::Error.new(output)
|
91
|
+
end
|
99
92
|
|
100
|
-
|
101
|
-
|
93
|
+
if output =~ /\*\* No such /
|
94
|
+
raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
|
102
95
|
end
|
103
96
|
|
104
|
-
|
97
|
+
# No return code required, so do nil to be clean
|
98
|
+
return nil
|
99
|
+
end
|
105
100
|
|
106
|
-
|
107
|
-
Puppet.debug "portupgrade.latest() - Latest check called on #{@resource[:name]}"
|
108
|
-
# search for latest version available, or return current version.
|
109
|
-
# cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
|
110
|
-
# or "** No matching package found: <portname>"
|
111
|
-
cmdline = ["-v", @resource[:name]]
|
101
|
+
######## Latest subcommand (returns the latest version available, or current version if installed is latest)
|
112
102
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
103
|
+
def latest
|
104
|
+
Puppet.debug "portupgrade.latest() - Latest check called on #{@resource[:name]}"
|
105
|
+
# search for latest version available, or return current version.
|
106
|
+
# cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
|
107
|
+
# or "** No matching package found: <portname>"
|
108
|
+
cmdline = ["-v", @resource[:name]]
|
118
109
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
comparison = $2
|
125
|
-
otherdata = $3
|
126
|
-
|
127
|
-
# Only return a new version number when it's clear that there is a new version
|
128
|
-
# all others return the current version so no unexpected 'upgrades' occur.
|
129
|
-
case comparison
|
130
|
-
when "=", ">"
|
131
|
-
Puppet.debug "portupgrade.latest() - Installed package is latest (#{installedversion})"
|
132
|
-
return installedversion
|
133
|
-
when "<"
|
134
|
-
# "portpkg-1.7_5 < needs updating (port has 1.14)"
|
135
|
-
# "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg')
|
136
|
-
if otherdata =~ /\(port has (\S+)\)/
|
137
|
-
newversion = $1
|
138
|
-
Puppet.debug "portupgrade.latest() - Installed version needs updating to (#{newversion})"
|
139
|
-
return newversion
|
140
|
-
else
|
141
|
-
Puppet.debug "portupgrade.latest() - Unable to determine new version from (#{otherdata})"
|
142
|
-
return installedversion
|
143
|
-
end
|
144
|
-
when "?", "!", "#"
|
145
|
-
Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (#{output})"
|
146
|
-
return installedversion
|
147
|
-
else
|
148
|
-
Puppet.debug "portupgrade.latest() - Unknown code from portversion output (#{output})"
|
149
|
-
return installedversion
|
150
|
-
end
|
110
|
+
begin
|
111
|
+
output = portversion(*cmdline)
|
112
|
+
rescue Puppet::ExecutionFailure
|
113
|
+
raise Puppet::Error.new(output)
|
114
|
+
end
|
151
115
|
|
116
|
+
# Check: output format.
|
117
|
+
if output =~ /^\S+-([^-\s]+)\s+(\S)\s+(.*)/
|
118
|
+
installedversion = $1
|
119
|
+
comparison = $2
|
120
|
+
otherdata = $3
|
121
|
+
|
122
|
+
# Only return a new version number when it's clear that there is a new version
|
123
|
+
# all others return the current version so no unexpected 'upgrades' occur.
|
124
|
+
case comparison
|
125
|
+
when "=", ">"
|
126
|
+
Puppet.debug "portupgrade.latest() - Installed package is latest (#{installedversion})"
|
127
|
+
return installedversion
|
128
|
+
when "<"
|
129
|
+
# "portpkg-1.7_5 < needs updating (port has 1.14)"
|
130
|
+
# "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg')
|
131
|
+
if otherdata =~ /\(port has (\S+)\)/
|
132
|
+
newversion = $1
|
133
|
+
Puppet.debug "portupgrade.latest() - Installed version needs updating to (#{newversion})"
|
134
|
+
return newversion
|
152
135
|
else
|
153
|
-
|
154
|
-
|
155
|
-
# as verification that the port is installed has already happened in query.
|
156
|
-
if output =~ /^\*\* No matching package /
|
157
|
-
raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
|
158
|
-
else
|
159
|
-
# Any other error (dump output to log)
|
160
|
-
raise Puppet::ExecutionFailure, "Unexpected output from portversion: #{output}"
|
161
|
-
end
|
162
|
-
|
163
|
-
# Just in case we still are running, return nil
|
164
|
-
return nil
|
136
|
+
Puppet.debug "portupgrade.latest() - Unable to determine new version from (#{otherdata})"
|
137
|
+
return installedversion
|
165
138
|
end
|
139
|
+
when "?", "!", "#"
|
140
|
+
Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (#{output})"
|
141
|
+
return installedversion
|
142
|
+
else
|
143
|
+
Puppet.debug "portupgrade.latest() - Unknown code from portversion output (#{output})"
|
144
|
+
return installedversion
|
145
|
+
end
|
166
146
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
147
|
+
else
|
148
|
+
# error: output not parsed correctly, error out with nil.
|
149
|
+
# Seriously - this section should never be called in a perfect world.
|
150
|
+
# as verification that the port is installed has already happened in query.
|
151
|
+
if output =~ /^\*\* No matching package /
|
152
|
+
raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}"
|
153
|
+
else
|
154
|
+
# Any other error (dump output to log)
|
155
|
+
raise Puppet::ExecutionFailure, "Unexpected output from portversion: #{output}"
|
156
|
+
end
|
171
157
|
|
158
|
+
# Just in case we still are running, return nil
|
159
|
+
return nil
|
172
160
|
end
|
173
161
|
|
174
|
-
|
175
|
-
#
|
162
|
+
# At this point normal operation has finished and we shouldn't have been called.
|
163
|
+
# Error out and let the admin deal with it.
|
164
|
+
raise Puppet::Error, "portversion.latest() - fatal error with portversion: #{output}"
|
165
|
+
return nil
|
166
|
+
end
|
176
167
|
|
177
|
-
|
178
|
-
|
168
|
+
###### Query subcommand - return a hash of details if exists, or nil if it doesn't.
|
169
|
+
# Used to make sure the package is installed
|
179
170
|
|
180
|
-
|
181
|
-
|
182
|
-
output = portinfo(*cmdline)
|
183
|
-
rescue Puppet::ExecutionFailure
|
184
|
-
raise Puppet::Error.new(output)
|
185
|
-
end
|
171
|
+
def query
|
172
|
+
Puppet.debug "portupgrade.query() - Called on #{@resource[:name]}"
|
186
173
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
hash[:ensure] = $2
|
174
|
+
cmdline = ["-qO", @resource[:name]]
|
175
|
+
begin
|
176
|
+
output = portinfo(*cmdline)
|
177
|
+
rescue Puppet::ExecutionFailure
|
178
|
+
raise Puppet::Error.new(output)
|
179
|
+
end
|
194
180
|
|
195
|
-
|
196
|
-
|
181
|
+
# Check: if output isn't in the right format, return nil
|
182
|
+
if output =~ /^(\S+)-([^-\s]+)/
|
183
|
+
# Fill in the details
|
184
|
+
hash = Hash.new
|
185
|
+
hash[:portorigin] = self.name
|
186
|
+
hash[:portname] = $1
|
187
|
+
hash[:ensure] = $2
|
188
|
+
|
189
|
+
# If more details are required, then we can do another pkg_info
|
190
|
+
# query here and parse out that output and add to the hash
|
191
|
+
# return the hash to the caller
|
192
|
+
return hash
|
193
|
+
else
|
194
|
+
Puppet.debug "portupgrade.query() - package (#{@resource[:name]}) not installed"
|
195
|
+
return nil
|
196
|
+
end
|
197
|
+
end
|
197
198
|
|
198
|
-
|
199
|
-
return hash
|
200
|
-
else
|
201
|
-
Puppet.debug "portupgrade.query() - package (#{@resource[:name]}) not installed"
|
202
|
-
return nil
|
203
|
-
end
|
199
|
+
####### Uninstall command
|
204
200
|
|
201
|
+
def uninstall
|
202
|
+
Puppet.debug "portupgrade.uninstall() - called on #{@resource[:name]}"
|
203
|
+
# Get full package name from port origin to uninstall with
|
204
|
+
cmdline = ["-qO", @resource[:name]]
|
205
|
+
begin
|
206
|
+
output = portinfo(*cmdline)
|
207
|
+
rescue Puppet::ExecutionFailure
|
208
|
+
raise Puppet::Error.new(output)
|
205
209
|
end
|
206
210
|
|
207
|
-
|
211
|
+
if output =~ /^(\S+)/
|
212
|
+
# output matches, so uninstall it
|
213
|
+
portuninstall $1
|
214
|
+
end
|
215
|
+
end
|
208
216
|
|
209
|
-
|
210
|
-
Puppet.debug "portupgrade.uninstall() - called on #{@resource[:name]}"
|
211
|
-
# Get full package name from port origin to uninstall with
|
212
|
-
cmdline = ["-qO", @resource[:name]]
|
213
|
-
begin
|
214
|
-
output = portinfo(*cmdline)
|
215
|
-
rescue Puppet::ExecutionFailure
|
216
|
-
raise Puppet::Error.new(output)
|
217
|
-
end
|
217
|
+
######## Update/upgrade command
|
218
218
|
|
219
|
-
|
220
|
-
|
221
|
-
portuninstall $1
|
222
|
-
end
|
219
|
+
def update
|
220
|
+
Puppet.debug "portupgrade.update() - called on (#{@resource[:name]})"
|
223
221
|
|
222
|
+
cmdline = ["-qO", @resource[:name]]
|
223
|
+
begin
|
224
|
+
output = portinfo(*cmdline)
|
225
|
+
rescue Puppet::ExecutionFailure
|
226
|
+
raise Puppet::Error.new(output)
|
224
227
|
end
|
225
228
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
Puppet.debug "portupgrade.update() - called on (#{@resource[:name]})"
|
230
|
-
|
231
|
-
cmdline = ["-qO", @resource[:name]]
|
229
|
+
if output =~ /^(\S+)/
|
230
|
+
# output matches, so upgrade the software
|
231
|
+
cmdline = ["-M BATCH=yes", $1]
|
232
232
|
begin
|
233
|
-
output =
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
if output =~ /^(\S+)/
|
239
|
-
# output matches, so upgrade the software
|
240
|
-
cmdline = ["-M BATCH=yes", $1]
|
241
|
-
begin
|
242
|
-
output = portupgrade(*cmdline)
|
243
|
-
rescue Puppet::ExecutionFailure
|
244
|
-
raise Puppet::Error.new(output)
|
245
|
-
end
|
246
|
-
end
|
233
|
+
output = portupgrade(*cmdline)
|
234
|
+
rescue Puppet::ExecutionFailure
|
235
|
+
raise Puppet::Error.new(output)
|
236
|
+
end
|
247
237
|
end
|
238
|
+
end
|
248
239
|
|
249
|
-
## EOF
|
240
|
+
## EOF
|
250
241
|
end
|
251
|
-
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'puppet/provider/package'
|
2
|
+
|
2
3
|
# RPM packaging. Should work anywhere that has rpm installed.
|
3
4
|
Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Provider::Package do
|
4
5
|
desc "RPM packaging support; should work anywhere with a working `rpm`
|
@@ -129,4 +130,3 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr
|
|
129
130
|
hash
|
130
131
|
end
|
131
132
|
end
|
132
|
-
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'puppet/util/package'
|
2
|
+
|
2
3
|
Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
|
3
4
|
desc "Support via `yum`."
|
4
5
|
|
@@ -104,4 +105,3 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
|
|
104
105
|
yum "-y", :erase, @resource[:name]
|
105
106
|
end
|
106
107
|
end
|
107
|
-
|
@@ -1,6 +1,3 @@
|
|
1
|
-
# Created by Luke A. Kanies on 2007-06-05.
|
2
|
-
# Copyright (c) 2007. All rights reserved.
|
3
|
-
|
4
1
|
class Puppet::Provider::Package < Puppet::Provider
|
5
2
|
# Prefetch our package list, yo.
|
6
3
|
def self.prefetch(packages)
|
@@ -24,4 +21,8 @@ class Puppet::Provider::Package < Puppet::Provider
|
|
24
21
|
end
|
25
22
|
@property_hash.dup
|
26
23
|
end
|
24
|
+
|
25
|
+
def validate_source(value)
|
26
|
+
true
|
27
|
+
end
|
27
28
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Manage systemd services using /bin/systemctl
|
2
|
+
|
3
|
+
Puppet::Type.type(:service).provide :systemd, :parent => :base do
|
4
|
+
desc "Manage systemd services using /bin/systemctl"
|
5
|
+
|
6
|
+
commands :systemctl => "/bin/systemctl"
|
7
|
+
|
8
|
+
#defaultfor :operatingsystem => [:redhat, :fedora, :suse, :centos, :sles, :oel, :ovm]
|
9
|
+
|
10
|
+
def self.instances
|
11
|
+
i = []
|
12
|
+
output = `systemctl list-units --full --all --no-pager`
|
13
|
+
output.scan(/^(\S+)\s+(loaded|error)\s+(active|inactive)\s+(active|waiting|running|plugged|mounted|dead|exited|listening|elapsed)\s*?(\S.*?)?$/i).each do |m|
|
14
|
+
i << m[0]
|
15
|
+
end
|
16
|
+
return i
|
17
|
+
rescue Puppet::ExecutionFailure
|
18
|
+
return []
|
19
|
+
end
|
20
|
+
|
21
|
+
def disable
|
22
|
+
output = systemctl(:disable, @resource[:name])
|
23
|
+
rescue Puppet::ExecutionFailure
|
24
|
+
raise Puppet::Error, "Could not disable #{self.name}: #{output}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def enabled?
|
28
|
+
begin
|
29
|
+
systemctl("is-enabled", @resource[:name])
|
30
|
+
rescue Puppet::ExecutionFailure
|
31
|
+
return :false
|
32
|
+
end
|
33
|
+
|
34
|
+
:true
|
35
|
+
end
|
36
|
+
|
37
|
+
def status
|
38
|
+
begin
|
39
|
+
output = systemctl("is-active", @resource[:name])
|
40
|
+
rescue Puppet::ExecutionFailure
|
41
|
+
return :stopped
|
42
|
+
end
|
43
|
+
return :running
|
44
|
+
end
|
45
|
+
|
46
|
+
def enable
|
47
|
+
output = systemctl("enable", @resource[:name])
|
48
|
+
rescue Puppet::ExecutionFailure
|
49
|
+
raise Puppet::Error, "Could not enable #{self.name}: #{output}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def restartcmd
|
53
|
+
[command(:systemctl), "restart", @resource[:name]]
|
54
|
+
end
|
55
|
+
|
56
|
+
def startcmd
|
57
|
+
[command(:systemctl), "start", @resource[:name]]
|
58
|
+
end
|
59
|
+
|
60
|
+
def stopcmd
|
61
|
+
[command(:systemctl), "stop", @resource[:name]]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Windows Service Control Manager (SCM) provider
|
2
|
+
|
3
|
+
require 'win32/service' if Puppet.features.microsoft_windows?
|
4
|
+
|
5
|
+
Puppet::Type.type(:service).provide :windows do
|
6
|
+
|
7
|
+
desc "Support for Windows Service Control Manager (SCM).
|
8
|
+
|
9
|
+
Services are controlled according to win32-service gem.
|
10
|
+
|
11
|
+
* All SCM operations (start/stop/enable/disable/query) are supported.
|
12
|
+
|
13
|
+
* Control of service groups (dependencies) is not yet supported."
|
14
|
+
|
15
|
+
defaultfor :operatingsystem => :windows
|
16
|
+
confine :operatingsystem => :windows
|
17
|
+
|
18
|
+
has_feature :refreshable
|
19
|
+
|
20
|
+
def enable
|
21
|
+
w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_AUTO_START )
|
22
|
+
raise Puppet::Error.new("Win32 service enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
|
23
|
+
rescue Win32::Service::Error => detail
|
24
|
+
raise Puppet::Error.new("Cannot enable #{@resource[:name]}, error was: #{detail}" )
|
25
|
+
end
|
26
|
+
|
27
|
+
def disable
|
28
|
+
w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_DISABLED )
|
29
|
+
raise Puppet::Error.new("Win32 service disable of #{@resource[:name]} failed" ) if( w32ss.nil? )
|
30
|
+
rescue Win32::Service::Error => detail
|
31
|
+
raise Puppet::Error.new("Cannot disable #{@resource[:name]}, error was: #{detail}" )
|
32
|
+
end
|
33
|
+
|
34
|
+
def manual_start
|
35
|
+
w32ss = Win32::Service.configure( 'service_name' => @resource[:name], 'start_type' => Win32::Service::SERVICE_DEMAND_START )
|
36
|
+
raise Puppet::Error.new("Win32 service manual enable of #{@resource[:name]} failed" ) if( w32ss.nil? )
|
37
|
+
rescue Win32::Service::Error => detail
|
38
|
+
raise Puppet::Error.new("Cannot enable #{@resource[:name]} for manual start, error was: #{detail}" )
|
39
|
+
end
|
40
|
+
|
41
|
+
def enabled?
|
42
|
+
w32ss = Win32::Service.config_info( @resource[:name] )
|
43
|
+
raise Puppet::Error.new("Win32 service query of #{@resource[:name]} failed" ) unless( !w32ss.nil? && w32ss.instance_of?( Struct::ServiceConfigInfo ) )
|
44
|
+
debug("Service #{@resource[:name]} start type is #{w32ss.start_type}")
|
45
|
+
case w32ss.start_type
|
46
|
+
when Win32::Service.get_start_type(Win32::Service::SERVICE_AUTO_START),
|
47
|
+
Win32::Service.get_start_type(Win32::Service::SERVICE_BOOT_START),
|
48
|
+
Win32::Service.get_start_type(Win32::Service::SERVICE_SYSTEM_START)
|
49
|
+
:true
|
50
|
+
when Win32::Service.get_start_type(Win32::Service::SERVICE_DEMAND_START)
|
51
|
+
:manual
|
52
|
+
when Win32::Service.get_start_type(Win32::Service::SERVICE_DISABLED)
|
53
|
+
:false
|
54
|
+
else
|
55
|
+
raise Puppet::Error.new("Unknown start type: #{w32ss.start_type}")
|
56
|
+
end
|
57
|
+
rescue Win32::Service::Error => detail
|
58
|
+
raise Puppet::Error.new("Cannot get start type for #{@resource[:name]}, error was: #{detail}" )
|
59
|
+
end
|
60
|
+
|
61
|
+
def start
|
62
|
+
if enabled? == :false
|
63
|
+
# If disabled and not managing enable, respect disabled and fail.
|
64
|
+
if @resource[:enable].nil?
|
65
|
+
raise Puppet::Error, "Will not start disabled service #{@resource[:name]} without managing enable. Specify 'enable => false' to override."
|
66
|
+
# Otherwise start. If enable => false, we will later sync enable and
|
67
|
+
# disable the service again.
|
68
|
+
elsif @resource[:enable] == :true
|
69
|
+
enable
|
70
|
+
else
|
71
|
+
manual_start
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
Win32::Service.start( @resource[:name] )
|
76
|
+
rescue Win32::Service::Error => detail
|
77
|
+
raise Puppet::Error.new("Cannot start #{@resource[:name]}, error was: #{detail}" )
|
78
|
+
end
|
79
|
+
|
80
|
+
def stop
|
81
|
+
Win32::Service.stop( @resource[:name] )
|
82
|
+
rescue Win32::Service::Error => detail
|
83
|
+
raise Puppet::Error.new("Cannot stop #{@resource[:name]}, error was: #{detail}" )
|
84
|
+
end
|
85
|
+
|
86
|
+
def restart
|
87
|
+
self.stop
|
88
|
+
self.start
|
89
|
+
end
|
90
|
+
|
91
|
+
def status
|
92
|
+
w32ss = Win32::Service.status( @resource[:name] )
|
93
|
+
raise Puppet::Error.new("Win32 service query of #{@resource[:name]} failed" ) unless( !w32ss.nil? && w32ss.instance_of?( Struct::ServiceStatus ) )
|
94
|
+
state = case w32ss.current_state
|
95
|
+
when "stopped", "pause pending", "stop pending", "paused" then :stopped
|
96
|
+
when "running", "continue pending", "start pending" then :running
|
97
|
+
else
|
98
|
+
raise Puppet::Error.new("Unknown service state '#{w32ss.current_state}' for service '#{@resource[:name]}'")
|
99
|
+
end
|
100
|
+
debug("Service #{@resource[:name]} is #{w32ss.current_state}")
|
101
|
+
return state
|
102
|
+
rescue Win32::Service::Error => detail
|
103
|
+
raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" )
|
104
|
+
end
|
105
|
+
|
106
|
+
# returns all providers for all existing services and startup state
|
107
|
+
def self.instances
|
108
|
+
Win32::Service.services.collect { |s| new(:name => s.service_name) }
|
109
|
+
end
|
110
|
+
end
|