chef 13.6.4-universal-mingw32 → 13.7.16-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +7 -19
- data/acceptance/.DS_Store +0 -0
- data/acceptance/.bundle/config +0 -2
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
- data/distro/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/chef/.DS_Store +0 -0
- data/lib/chef/knife/.DS_Store +0 -0
- data/lib/chef/mixin/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/spec/functional/.DS_Store +0 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/unit/.DS_Store +0 -0
- data/tasks/.DS_Store +0 -0
@@ -35,6 +35,7 @@ class Chef
|
|
35
35
|
def load_current_resource
|
36
36
|
@current_resource = Chef::Resource::SystemdUnit.new(new_resource.name)
|
37
37
|
|
38
|
+
current_resource.unit_name(new_resource.unit_name)
|
38
39
|
current_resource.content(::File.read(unit_path)) if ::File.exist?(unit_path)
|
39
40
|
current_resource.user(new_resource.user)
|
40
41
|
current_resource.enabled(enabled?)
|
@@ -57,7 +58,7 @@ class Chef
|
|
57
58
|
|
58
59
|
def action_create
|
59
60
|
if current_resource.content != new_resource.to_ini
|
60
|
-
converge_by("creating unit: #{new_resource.
|
61
|
+
converge_by("creating unit: #{new_resource.unit_name}") do
|
61
62
|
manage_unit_file(:create)
|
62
63
|
daemon_reload if new_resource.triggers_reload
|
63
64
|
end
|
@@ -66,7 +67,7 @@ class Chef
|
|
66
67
|
|
67
68
|
def action_delete
|
68
69
|
if ::File.exist?(unit_path)
|
69
|
-
converge_by("deleting unit: #{new_resource.
|
70
|
+
converge_by("deleting unit: #{new_resource.unit_name}") do
|
70
71
|
manage_unit_file(:delete)
|
71
72
|
daemon_reload if new_resource.triggers_reload
|
72
73
|
end
|
@@ -75,117 +76,117 @@ class Chef
|
|
75
76
|
|
76
77
|
def action_enable
|
77
78
|
if current_resource.static
|
78
|
-
Chef::Log.debug("#{new_resource.
|
79
|
+
Chef::Log.debug("#{new_resource.unit_name} is a static unit, enabling is a NOP.")
|
79
80
|
end
|
80
81
|
|
81
82
|
unless current_resource.enabled || current_resource.static
|
82
|
-
converge_by("enabling unit: #{new_resource.
|
83
|
-
systemctl_execute!(:enable, new_resource.
|
83
|
+
converge_by("enabling unit: #{new_resource.unit_name}") do
|
84
|
+
systemctl_execute!(:enable, new_resource.unit_name)
|
84
85
|
end
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
89
|
def action_disable
|
89
90
|
if current_resource.static
|
90
|
-
Chef::Log.debug("#{new_resource.
|
91
|
+
Chef::Log.debug("#{new_resource.unit_name} is a static unit, disabling is a NOP.")
|
91
92
|
end
|
92
93
|
|
93
94
|
if current_resource.enabled && !current_resource.static
|
94
|
-
converge_by("disabling unit: #{new_resource.
|
95
|
-
systemctl_execute!(:disable, new_resource.
|
95
|
+
converge_by("disabling unit: #{new_resource.unit_name}") do
|
96
|
+
systemctl_execute!(:disable, new_resource.unit_name)
|
96
97
|
end
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
100
101
|
def action_mask
|
101
102
|
unless current_resource.masked
|
102
|
-
converge_by("masking unit: #{new_resource.
|
103
|
-
systemctl_execute!(:mask, new_resource.
|
103
|
+
converge_by("masking unit: #{new_resource.unit_name}") do
|
104
|
+
systemctl_execute!(:mask, new_resource.unit_name)
|
104
105
|
end
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
109
|
def action_unmask
|
109
110
|
if current_resource.masked
|
110
|
-
converge_by("unmasking unit: #{new_resource.
|
111
|
-
systemctl_execute!(:unmask, new_resource.
|
111
|
+
converge_by("unmasking unit: #{new_resource.unit_name}") do
|
112
|
+
systemctl_execute!(:unmask, new_resource.unit_name)
|
112
113
|
end
|
113
114
|
end
|
114
115
|
end
|
115
116
|
|
116
117
|
def action_start
|
117
118
|
unless current_resource.active
|
118
|
-
converge_by("starting unit: #{new_resource.
|
119
|
-
systemctl_execute!(:start, new_resource.
|
119
|
+
converge_by("starting unit: #{new_resource.unit_name}") do
|
120
|
+
systemctl_execute!(:start, new_resource.unit_name)
|
120
121
|
end
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
125
|
def action_stop
|
125
126
|
if current_resource.active
|
126
|
-
converge_by("stopping unit: #{new_resource.
|
127
|
-
systemctl_execute!(:stop, new_resource.
|
127
|
+
converge_by("stopping unit: #{new_resource.unit_name}") do
|
128
|
+
systemctl_execute!(:stop, new_resource.unit_name)
|
128
129
|
end
|
129
130
|
end
|
130
131
|
end
|
131
132
|
|
132
133
|
def action_restart
|
133
|
-
converge_by("restarting unit: #{new_resource.
|
134
|
-
systemctl_execute!(:restart, new_resource.
|
134
|
+
converge_by("restarting unit: #{new_resource.unit_name}") do
|
135
|
+
systemctl_execute!(:restart, new_resource.unit_name)
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
138
139
|
def action_reload
|
139
140
|
if current_resource.active
|
140
|
-
converge_by("reloading unit: #{new_resource.
|
141
|
-
systemctl_execute!(:reload, new_resource.
|
141
|
+
converge_by("reloading unit: #{new_resource.unit_name}") do
|
142
|
+
systemctl_execute!(:reload, new_resource.unit_name)
|
142
143
|
end
|
143
144
|
else
|
144
|
-
Chef::Log.debug("#{new_resource.
|
145
|
+
Chef::Log.debug("#{new_resource.unit_name} is not active, skipping reload.")
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
148
149
|
def action_try_restart
|
149
|
-
converge_by("try-restarting unit: #{new_resource.
|
150
|
-
systemctl_execute!("try-restart", new_resource.
|
150
|
+
converge_by("try-restarting unit: #{new_resource.unit_name}") do
|
151
|
+
systemctl_execute!("try-restart", new_resource.unit_name)
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
154
155
|
def action_reload_or_restart
|
155
|
-
converge_by("reload-or-restarting unit: #{new_resource.
|
156
|
-
systemctl_execute!("reload-or-restart", new_resource.
|
156
|
+
converge_by("reload-or-restarting unit: #{new_resource.unit_name}") do
|
157
|
+
systemctl_execute!("reload-or-restart", new_resource.unit_name)
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
160
161
|
def action_reload_or_try_restart
|
161
|
-
converge_by("reload-or-try-restarting unit: #{new_resource.
|
162
|
-
systemctl_execute!("reload-or-try-restart", new_resource.
|
162
|
+
converge_by("reload-or-try-restarting unit: #{new_resource.unit_name}") do
|
163
|
+
systemctl_execute!("reload-or-try-restart", new_resource.unit_name)
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
166
167
|
def active?
|
167
|
-
systemctl_execute("is-active", new_resource.
|
168
|
+
systemctl_execute("is-active", new_resource.unit_name).exitstatus == 0
|
168
169
|
end
|
169
170
|
|
170
171
|
def enabled?
|
171
|
-
systemctl_execute("is-enabled", new_resource.
|
172
|
+
systemctl_execute("is-enabled", new_resource.unit_name).exitstatus == 0
|
172
173
|
end
|
173
174
|
|
174
175
|
def masked?
|
175
|
-
systemctl_execute(:status, new_resource.
|
176
|
+
systemctl_execute(:status, new_resource.unit_name).stdout.include?("masked")
|
176
177
|
end
|
177
178
|
|
178
179
|
def static?
|
179
|
-
systemctl_execute("is-enabled", new_resource.
|
180
|
+
systemctl_execute("is-enabled", new_resource.unit_name).stdout.include?("static")
|
180
181
|
end
|
181
182
|
|
182
183
|
private
|
183
184
|
|
184
185
|
def unit_path
|
185
186
|
if new_resource.user
|
186
|
-
"/etc/systemd/user/#{new_resource.
|
187
|
+
"/etc/systemd/user/#{new_resource.unit_name}"
|
187
188
|
else
|
188
|
-
"/etc/systemd/system/#{new_resource.
|
189
|
+
"/etc/systemd/system/#{new_resource.unit_name}"
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
@@ -23,9 +23,10 @@ require "chef/exceptions"
|
|
23
23
|
class Chef
|
24
24
|
class Provider
|
25
25
|
class WindowsPath < Chef::Provider
|
26
|
-
|
27
26
|
include Chef::Mixin::WindowsEnvHelper if Chef::Platform.windows?
|
28
27
|
|
28
|
+
provides :windows_path
|
29
|
+
|
29
30
|
def load_current_resource
|
30
31
|
@current_resource = Chef::Resource::WindowsPath.new(new_resource.name)
|
31
32
|
@current_resource.path(new_resource.path)
|
@@ -37,12 +38,10 @@ class Chef
|
|
37
38
|
# the PATH environment variable. Ruby expects these to be expanded.
|
38
39
|
#
|
39
40
|
path = expand_path(new_resource.path)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
value path.tr("/", '\\')
|
45
|
-
end
|
41
|
+
declare_resource(:env, "path") do
|
42
|
+
action :modify
|
43
|
+
delim ::File::PATH_SEPARATOR
|
44
|
+
value path.tr("/", '\\')
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
@@ -75,14 +75,22 @@ class Chef
|
|
75
75
|
|
76
76
|
def action_create
|
77
77
|
if current_resource.exists
|
78
|
+
Chef::Log.debug "#{new_resource} task exists."
|
78
79
|
if !(task_need_update? || new_resource.force)
|
79
|
-
Chef::Log.info "#{new_resource} task
|
80
|
+
Chef::Log.info "#{new_resource} task doesn't need updating and force not specified - nothing to do"
|
80
81
|
return
|
81
82
|
end
|
82
|
-
#
|
83
|
+
# Setting the attributes of new_resource as current_resource.
|
84
|
+
# This is required to handle update scenarios when the user specifies
|
85
|
+
# only those attributes in the recipe which require update
|
83
86
|
resource_attributes.each do |attribute|
|
84
87
|
new_resource_attribute = new_resource.send(attribute)
|
85
88
|
current_resource_attribute = current_resource.send(attribute)
|
89
|
+
# We accept start_day in mm/dd/yyyy format only. Hence while copying the start_day from system to new_resource.start_day,
|
90
|
+
# we are converting from system date format to mm/dd/yyyy
|
91
|
+
current_resource_attribute = convert_system_date_to_mm_dd_yyyy(current_resource_attribute) if attribute == "start_day" && current_resource_attribute != "N/A"
|
92
|
+
# Convert start_time into 24hr time format
|
93
|
+
current_resource_attribute = DateTime.parse(current_resource_attribute).strftime("%H:%M") if attribute == "start_time" && current_resource_attribute != "N/A"
|
86
94
|
new_resource.send("#{attribute}=", current_resource_attribute ) if current_resource_attribute && new_resource_attribute.nil?
|
87
95
|
end
|
88
96
|
end
|
@@ -95,8 +103,8 @@ class Chef
|
|
95
103
|
options["SD"] = convert_user_date_to_system_date "12/12/2012"
|
96
104
|
else
|
97
105
|
options["SC"] = schedule
|
98
|
-
options["ST"] = new_resource.start_time unless new_resource.start_time.nil?
|
99
|
-
options["SD"] = convert_user_date_to_system_date new_resource.start_day unless new_resource.start_day.nil?
|
106
|
+
options["ST"] = new_resource.start_time unless new_resource.start_time.nil? || new_resource.start_time == "N/A"
|
107
|
+
options["SD"] = convert_user_date_to_system_date new_resource.start_day unless new_resource.start_day.nil? || new_resource.start_day == "N/A"
|
100
108
|
end
|
101
109
|
options["MO"] = new_resource.frequency_modifier if frequency_modifier_allowed
|
102
110
|
options["I"] = new_resource.idle_time unless new_resource.idle_time.nil?
|
@@ -112,20 +120,21 @@ class Chef
|
|
112
120
|
xml_options << "cwd" if new_resource.cwd
|
113
121
|
xml_options << "random_delay" if new_resource.random_delay
|
114
122
|
xml_options << "execution_time_limit" if new_resource.execution_time_limit
|
115
|
-
update_task_xml(xml_options) unless xml_options.empty?
|
116
123
|
|
117
|
-
new_resource
|
118
|
-
|
124
|
+
converge_by("#{new_resource} task created") do
|
125
|
+
update_task_xml(xml_options) unless xml_options.empty?
|
126
|
+
end
|
119
127
|
end
|
120
128
|
|
121
129
|
def action_run
|
122
130
|
if current_resource.exists
|
131
|
+
Chef::Log.debug "#{new_resource} task exists."
|
123
132
|
if current_resource.status == :running
|
124
|
-
Chef::Log.info "#{new_resource} task is currently running, skipping run"
|
133
|
+
Chef::Log.info "#{new_resource} task is currently running, skipping run."
|
125
134
|
else
|
126
|
-
|
127
|
-
|
128
|
-
|
135
|
+
converge_by("run scheduled task #{new_resource}") do
|
136
|
+
run_schtasks "RUN"
|
137
|
+
end
|
129
138
|
end
|
130
139
|
else
|
131
140
|
Chef::Log.warn "#{new_resource} task doesn't exists - nothing to do"
|
@@ -134,10 +143,11 @@ class Chef
|
|
134
143
|
|
135
144
|
def action_delete
|
136
145
|
if current_resource.exists
|
137
|
-
#
|
138
|
-
|
139
|
-
|
140
|
-
|
146
|
+
Chef::Log.debug "#{new_resource} task exists."
|
147
|
+
converge_by("delete scheduled task #{new_resource}") do
|
148
|
+
# always need to force deletion
|
149
|
+
run_schtasks "DELETE", "F" => ""
|
150
|
+
end
|
141
151
|
else
|
142
152
|
Chef::Log.warn "#{new_resource} task doesn't exists - nothing to do"
|
143
153
|
end
|
@@ -145,12 +155,13 @@ class Chef
|
|
145
155
|
|
146
156
|
def action_end
|
147
157
|
if current_resource.exists
|
158
|
+
Chef::Log.debug "#{new_resource} task exists."
|
148
159
|
if current_resource.status != :running
|
149
160
|
Chef::Log.debug "#{new_resource} is not running - nothing to do"
|
150
161
|
else
|
151
|
-
|
152
|
-
|
153
|
-
|
162
|
+
converge_by("#{new_resource} task ended") do
|
163
|
+
run_schtasks "END"
|
164
|
+
end
|
154
165
|
end
|
155
166
|
else
|
156
167
|
Chef::Log.warn "#{new_resource} task doesn't exist - nothing to do"
|
@@ -159,12 +170,13 @@ class Chef
|
|
159
170
|
|
160
171
|
def action_enable
|
161
172
|
if current_resource.exists
|
173
|
+
Chef::Log.debug "#{new_resource} task exists."
|
162
174
|
if current_resource.enabled
|
163
175
|
Chef::Log.debug "#{new_resource} already enabled - nothing to do"
|
164
176
|
else
|
165
|
-
|
166
|
-
|
167
|
-
|
177
|
+
converge_by("#{new_resource} task enabled") do
|
178
|
+
run_schtasks "CHANGE", "ENABLE" => ""
|
179
|
+
end
|
168
180
|
end
|
169
181
|
else
|
170
182
|
Chef::Log.fatal "#{new_resource} task doesn't exist - nothing to do"
|
@@ -174,10 +186,11 @@ class Chef
|
|
174
186
|
|
175
187
|
def action_disable
|
176
188
|
if current_resource.exists
|
189
|
+
Chef::Log.info "#{new_resource} task exists."
|
177
190
|
if current_resource.enabled
|
178
|
-
|
179
|
-
|
180
|
-
|
191
|
+
converge_by("#{new_resource} task disabled") do
|
192
|
+
run_schtasks "CHANGE", "DISABLE" => ""
|
193
|
+
end
|
181
194
|
else
|
182
195
|
Chef::Log.warn "#{new_resource} already disabled - nothing to do"
|
183
196
|
end
|
@@ -192,8 +205,14 @@ class Chef
|
|
192
205
|
def run_schtasks(task_action, options = {})
|
193
206
|
cmd = "schtasks /#{task_action} /TN \"#{new_resource.task_name}\" "
|
194
207
|
options.keys.each do |option|
|
195
|
-
|
196
|
-
|
208
|
+
unless option == "TR"
|
209
|
+
cmd += "/#{option} "
|
210
|
+
cmd += "\"#{options[option].to_s.gsub('"', "\\\"")}\" " unless options[option] == ""
|
211
|
+
end
|
212
|
+
end
|
213
|
+
# Appending Task Run [TR] option at the end since appending causing sometimes to append other options in option["TR"] value
|
214
|
+
if options["TR"]
|
215
|
+
cmd += "/TR \"#{options["TR"]} \" " unless task_action == "DELETE"
|
197
216
|
end
|
198
217
|
Chef::Log.debug("running: ")
|
199
218
|
Chef::Log.debug(" #{cmd}")
|
@@ -210,10 +229,9 @@ class Chef
|
|
210
229
|
current_resource.frequency_modifier != new_resource.frequency_modifier ||
|
211
230
|
current_resource.frequency != new_resource.frequency ||
|
212
231
|
current_resource.idle_time != new_resource.idle_time ||
|
213
|
-
|
214
|
-
|
215
|
-
(new_resource.
|
216
|
-
(new_resource.start_time && start_time_updated?)
|
232
|
+
random_delay_updated? || execution_time_limit_updated? ||
|
233
|
+
(new_resource.start_day && new_resource.start_day != "N/A" && start_day_updated?) ||
|
234
|
+
(new_resource.start_time && new_resource.start_time != "N/A" && start_time_updated?)
|
217
235
|
begin
|
218
236
|
return true if new_resource.day.to_s.casecmp(current_resource.day.to_s) != 0 ||
|
219
237
|
new_resource.months.to_s.casecmp(current_resource.months.to_s) != 0
|
@@ -224,6 +242,37 @@ class Chef
|
|
224
242
|
false
|
225
243
|
end
|
226
244
|
|
245
|
+
# Comparing random_delay values using ISO8601::Duration object Ref: https://github.com/arnau/ISO8601/blob/master/lib/iso8601/duration.rb#L18-L23
|
246
|
+
# di = ISO8601::Duration.new(65707200)
|
247
|
+
# ds = ISO8601::Duration.new('P65707200S')
|
248
|
+
# dp = ISO8601::Duration.new('P2Y1MT2H')
|
249
|
+
# di == dp # => true
|
250
|
+
# di == ds # => true
|
251
|
+
def random_delay_updated?
|
252
|
+
if new_resource.random_delay.nil?
|
253
|
+
false
|
254
|
+
elsif current_resource.random_delay.nil? && new_resource.random_delay == "PT0S" # when user sets random_dealy to 0 sec
|
255
|
+
false
|
256
|
+
elsif current_resource.random_delay.nil?
|
257
|
+
true
|
258
|
+
else
|
259
|
+
ISO8601::Duration.new(current_resource.random_delay) != ISO8601::Duration.new(new_resource.random_delay)
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# Comparing execution_time_limit values using Ref: https://github.com/arnau/ISO8601/blob/master/lib/iso8601/duration.rb#L18-L23
|
264
|
+
def execution_time_limit_updated?
|
265
|
+
if new_resource.execution_time_limit.nil?
|
266
|
+
false
|
267
|
+
elsif current_resource.execution_time_limit.nil? && new_resource.execution_time_limit == "PT0S" # when user sets random_dealy to 0 sec
|
268
|
+
false
|
269
|
+
elsif current_resource.execution_time_limit.nil?
|
270
|
+
true
|
271
|
+
else
|
272
|
+
ISO8601::Duration.new(current_resource.execution_time_limit) != ISO8601::Duration.new(new_resource.execution_time_limit)
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
227
276
|
def start_day_updated?
|
228
277
|
current_day = DateTime.strptime(current_resource.start_day, convert_system_date_format_to_ruby_date_format)
|
229
278
|
new_day = parse_day(new_resource.start_day)
|
@@ -274,6 +323,14 @@ class Chef
|
|
274
323
|
@system_short_date_format
|
275
324
|
end
|
276
325
|
|
326
|
+
def convert_system_date_to_mm_dd_yyyy(system_date)
|
327
|
+
system_date_format = convert_system_date_format_to_ruby_date_format
|
328
|
+
unless system_date_format == "%m/%d/%Y"
|
329
|
+
system_date = Date.strptime(system_date, system_date_format).strftime("%m/%d/%Y")
|
330
|
+
end
|
331
|
+
system_date
|
332
|
+
end
|
333
|
+
|
277
334
|
def update_task_xml(options = [])
|
278
335
|
# random_delay xml element is different for different frequencies
|
279
336
|
random_delay_xml_element = {
|
@@ -311,12 +368,12 @@ class Chef
|
|
311
368
|
end
|
312
369
|
|
313
370
|
options.each do |option|
|
314
|
-
Chef::Log.debug
|
371
|
+
Chef::Log.debug "Removing former #{option} if any"
|
315
372
|
doc.root.elements.delete(xml_element_mapping[option])
|
316
373
|
option_value = new_resource.send("#{option}")
|
317
374
|
|
318
375
|
if option_value
|
319
|
-
Chef::Log.debug "Setting #option as #option_value"
|
376
|
+
Chef::Log.debug "Setting #{option} as #{option_value}"
|
320
377
|
split_xml_path = xml_element_mapping[option].split("/") # eg. if xml_element_mapping[option] = "Actions/Exec/WorkingDirectory"
|
321
378
|
element_name = split_xml_path.last # element_name = "WorkingDirectory"
|
322
379
|
cwd_element = REXML::Element.new(element_name)
|
@@ -338,7 +395,6 @@ class Chef
|
|
338
395
|
options["RP"] = new_resource.password if new_resource.password
|
339
396
|
options["IT"] = "" if new_resource.interactive_enabled
|
340
397
|
options["XML"] = temp_task_file
|
341
|
-
|
342
398
|
run_schtasks("DELETE", "F" => "")
|
343
399
|
run_schtasks("CREATE", options)
|
344
400
|
ensure
|
@@ -47,7 +47,7 @@ class Chef
|
|
47
47
|
if new_resource.make_cache
|
48
48
|
notifies :run, "execute[yum clean metadata #{new_resource.repositoryid}]", :immediately if new_resource.clean_metadata || new_resource.clean_headers
|
49
49
|
notifies :run, "execute[yum-makecache-#{new_resource.repositoryid}]", :immediately
|
50
|
-
notifies :create, "ruby_block[
|
50
|
+
notifies :create, "ruby_block[package-cache-reload-#{new_resource.repositoryid}]", :immediately
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -63,9 +63,14 @@ class Chef
|
|
63
63
|
only_if { new_resource.enabled }
|
64
64
|
end
|
65
65
|
|
66
|
-
# reload internal Chef yum cache
|
67
|
-
declare_resource(:ruby_block, "
|
68
|
-
|
66
|
+
# reload internal Chef yum/dnf cache
|
67
|
+
declare_resource(:ruby_block, "package-cache-reload-#{new_resource.repositoryid}") do
|
68
|
+
if ( platform?("fedora") && node["platform_version"].to_i >= 22 ) ||
|
69
|
+
( platform_family?("rhel") && node["platform_version"].to_i >= 8 )
|
70
|
+
block { Chef::Provider::Package::Dnf::PythonHelper.instance.restart }
|
71
|
+
else
|
72
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
73
|
+
end
|
69
74
|
action :nothing
|
70
75
|
end
|
71
76
|
end
|
@@ -79,11 +84,16 @@ class Chef
|
|
79
84
|
|
80
85
|
declare_resource(:file, "/etc/yum.repos.d/#{new_resource.repositoryid}.repo") do
|
81
86
|
action :delete
|
82
|
-
notifies :create, "ruby_block[
|
87
|
+
notifies :create, "ruby_block[package-cache-reload-#{new_resource.repositoryid}]", :immediately
|
83
88
|
end
|
84
89
|
|
85
|
-
declare_resource(:ruby_block, "
|
86
|
-
|
90
|
+
declare_resource(:ruby_block, "package-cache-reload-#{new_resource.repositoryid}") do
|
91
|
+
if ( platform?("fedora") && node["platform_version"].to_i >= 22 ) ||
|
92
|
+
( platform_family?("rhel") && node["platform_version"].to_i >= 8 )
|
93
|
+
block { Chef::Provider::Package::Dnf::PythonHelper.instance.restart }
|
94
|
+
else
|
95
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
96
|
+
end
|
87
97
|
action :nothing
|
88
98
|
end
|
89
99
|
end
|
@@ -95,8 +105,13 @@ class Chef
|
|
95
105
|
only_if { new_resource.enabled }
|
96
106
|
end
|
97
107
|
|
98
|
-
declare_resource(:ruby_block, "
|
99
|
-
|
108
|
+
declare_resource(:ruby_block, "package-cache-reload-#{new_resource.repositoryid}") do
|
109
|
+
if ( platform?("fedora") && node["platform_version"].to_i >= 22 ) ||
|
110
|
+
( platform_family?("rhel") && node["platform_version"].to_i >= 8 )
|
111
|
+
block { Chef::Provider::Package::Dnf::PythonHelper.instance.restart }
|
112
|
+
else
|
113
|
+
block { Chef::Provider::Package::Yum::YumCache.instance.reload }
|
114
|
+
end
|
100
115
|
action :run
|
101
116
|
end
|
102
117
|
end
|