chef 12.0.0.alpha.1-x86-mingw32 → 12.0.0.alpha.2-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chef/application.rb +8 -1
- data/lib/chef/application/apply.rb +4 -0
- data/lib/chef/application/client.rb +7 -7
- data/lib/chef/application/solo.rb +21 -13
- data/lib/chef/chef_fs/chef_fs_data_store.rb +60 -6
- data/lib/chef/chef_fs/config.rb +78 -4
- data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +2 -2
- data/lib/chef/chef_fs/data_handler/client_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/container_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +1 -1
- 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 +76 -2
- data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/group_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/node_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +30 -0
- data/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb +17 -0
- data/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb +17 -0
- data/lib/chef/chef_fs/data_handler/role_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/user_data_handler.rb +2 -1
- data/lib/chef/chef_fs/file_system.rb +0 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +5 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb +73 -13
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +44 -5
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/org_entry.rb +34 -0
- data/lib/chef/chef_fs/file_system/organization_invites_entry.rb +58 -0
- data/lib/chef/chef_fs/file_system/organization_members_entry.rb +57 -0
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +13 -4
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/client.rb +8 -2
- data/lib/chef/config.rb +75 -57
- data/lib/chef/config_fetcher.rb +6 -21
- data/lib/chef/dsl/data_query.rb +48 -3
- data/lib/chef/dsl/platform_introspection.rb +42 -0
- data/lib/chef/dsl/reboot_pending.rb +6 -3
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +12 -0
- data/lib/chef/exceptions.rb +2 -0
- data/lib/chef/http/basic_client.rb +14 -0
- data/lib/chef/http/json_output.rb +7 -2
- data/lib/chef/knife.rb +36 -121
- data/lib/chef/knife/bootstrap.rb +68 -54
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +6 -1
- data/lib/chef/knife/bootstrap/chef-aix.erb +5 -0
- data/lib/chef/knife/bootstrap/chef-full.erb +5 -1
- data/lib/chef/knife/core/bootstrap_context.rb +70 -29
- data/lib/chef/knife/search.rb +56 -12
- data/lib/chef/knife/serve.rb +1 -1
- data/lib/chef/local_mode.rb +10 -4
- data/lib/chef/mixin/deep_merge.rb +6 -3
- data/lib/chef/mixin/shell_out.rb +33 -17
- data/lib/chef/null_logger.rb +72 -0
- data/lib/chef/platform.rb +2 -1
- data/lib/chef/platform/provider_mapping.rb +1 -1
- data/lib/chef/platform/rebooter.rb +54 -0
- data/lib/chef/provider/ifconfig.rb +15 -16
- data/lib/chef/provider/link.rb +1 -1
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/mount/solaris.rb +102 -64
- data/lib/chef/provider/package/aix.rb +4 -12
- data/lib/chef/provider/package/ips.rb +8 -12
- data/lib/chef/provider/package/macports.rb +4 -12
- data/lib/chef/provider/package/pacman.rb +2 -6
- data/lib/chef/provider/package/portage.rb +2 -6
- data/lib/chef/provider/package/rpm.rb +4 -12
- data/lib/chef/provider/package/solaris.rb +4 -12
- data/lib/chef/provider/reboot.rb +69 -0
- data/lib/chef/provider/service/debian.rb +10 -10
- data/lib/chef/provider/service/freebsd.rb +89 -73
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/init.rb +6 -4
- data/lib/chef/provider/service/insserv.rb +3 -3
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/simple.rb +6 -4
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +9 -9
- data/lib/chef/provider/service/upstart.rb +6 -6
- data/lib/chef/provider/subversion.rb +6 -6
- data/lib/chef/provider/user/dscl.rb +32 -28
- data/lib/chef/provider/user/windows.rb +6 -6
- data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/recipe.rb +0 -1
- data/lib/chef/resource.rb +3 -5
- data/lib/chef/resource/mount.rb +9 -0
- data/lib/chef/resource/reboot.rb +48 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +25 -0
- data/lib/chef/search/query.rb +122 -14
- data/lib/chef/util/path_helper.rb +54 -6
- data/lib/chef/util/windows/net_user.rb +4 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/file.rb +1 -5
- data/lib/chef/win32/api/net.rb +1 -0
- data/lib/chef/workstation_config_loader.rb +177 -0
- data/spec/functional/http/simple_spec.rb +57 -1
- data/spec/functional/mixin/shell_out_spec.rb +2 -2
- data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +51 -0
- data/spec/functional/rebooter_spec.rb +105 -0
- data/spec/functional/resource/deploy_revision_spec.rb +0 -4
- data/spec/functional/resource/file_spec.rb +26 -3
- data/spec/functional/resource/group_spec.rb +5 -3
- data/spec/functional/resource/link_spec.rb +16 -16
- data/spec/functional/resource/reboot_spec.rb +103 -0
- data/spec/integration/client/client_spec.rb +4 -8
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -2
- data/spec/integration/knife/delete_spec.rb +39 -0
- data/spec/integration/knife/deps_spec.rb +30 -20
- data/spec/integration/knife/download_spec.rb +77 -1
- data/spec/integration/knife/list_spec.rb +221 -0
- data/spec/integration/knife/raw_spec.rb +1 -1
- data/spec/integration/knife/show_spec.rb +2 -2
- data/spec/integration/knife/upload_spec.rb +154 -1
- data/spec/support/pedant/run_pedant.rb +0 -1
- data/spec/support/shared/functional/http.rb +8 -1
- data/spec/support/shared/integration/integration_helper.rb +11 -19
- data/spec/support/shared/unit/platform_introspector.rb +22 -0
- data/spec/unit/application/apply.rb +11 -1
- data/spec/unit/application/solo_spec.rb +19 -3
- data/spec/unit/chef_fs/config_spec.rb +58 -0
- data/spec/unit/config_fetcher_spec.rb +1 -3
- data/spec/unit/config_spec.rb +247 -220
- data/spec/unit/dsl/data_query_spec.rb +165 -23
- data/spec/unit/dsl/reboot_pending_spec.rb +1 -7
- data/spec/unit/encrypted_data_bag_item_spec.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +354 -182
- data/spec/unit/knife/core/bootstrap_context_spec.rb +67 -30
- data/spec/unit/knife_spec.rb +3 -30
- data/spec/unit/mixin/deep_merge_spec.rb +14 -0
- data/spec/unit/mixin/shell_out_spec.rb +134 -64
- data/spec/unit/provider/ifconfig/debian_spec.rb +19 -9
- data/spec/unit/provider/ifconfig/redhat_spec.rb +16 -14
- data/spec/unit/provider/ifconfig_spec.rb +3 -3
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/mount/mount_spec.rb +10 -1
- data/spec/unit/provider/mount/solaris_spec.rb +185 -11
- data/spec/unit/provider/package/aix_spec.rb +5 -17
- data/spec/unit/provider/package/ips_spec.rb +8 -21
- data/spec/unit/provider/package/macports_spec.rb +12 -12
- data/spec/unit/provider/package/pacman_spec.rb +4 -12
- data/spec/unit/provider/package/portage_spec.rb +5 -15
- data/spec/unit/provider/package/rpm_spec.rb +7 -22
- data/spec/unit/provider/package/solaris_spec.rb +5 -16
- data/spec/unit/provider/service/arch_service_spec.rb +8 -14
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +457 -225
- data/spec/unit/provider/service/gentoo_service_spec.rb +2 -2
- data/spec/unit/provider/service/init_service_spec.rb +10 -10
- data/spec/unit/provider/service/insserv_service_spec.rb +3 -4
- data/spec/unit/provider/service/invokercd_service_spec.rb +8 -9
- data/spec/unit/provider/service/macosx_spec.rb +5 -5
- data/spec/unit/provider/service/simple_service_spec.rb +4 -6
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +1 -3
- data/spec/unit/provider/service/systemd_service_spec.rb +20 -20
- data/spec/unit/provider/service/upstart_service_spec.rb +15 -17
- data/spec/unit/provider/subversion_spec.rb +5 -6
- data/spec/unit/provider/user/dscl_spec.rb +2 -1
- data/spec/unit/provider/user/windows_spec.rb +7 -0
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +2 -2
- data/spec/unit/resource/mount_spec.rb +9 -0
- data/spec/unit/resource_spec.rb +0 -4
- data/spec/unit/rest_spec.rb +1 -1
- data/spec/unit/run_context_spec.rb +15 -0
- data/spec/unit/search/query_spec.rb +196 -40
- data/spec/unit/util/path_helper_spec.rb +111 -28
- data/spec/unit/workstation_config_loader_spec.rb +283 -0
- metadata +36 -20
- data/lib/chef/knife/bootstrap/centos5-gems.erb +0 -62
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +0 -44
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +0 -53
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +0 -48
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +0 -46
- data/spec/support/shared/integration/chef_zero_support.rb +0 -130
- data/spec/unit/knife/config_file_selection_spec.rb +0 -135
@@ -58,10 +58,10 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def enable_service()
|
61
|
-
|
61
|
+
shell_out!("/sbin/rc-update add #{@new_resource.service_name} default")
|
62
62
|
end
|
63
63
|
|
64
64
|
def disable_service()
|
65
|
-
|
65
|
+
shell_out!("/sbin/rc-update del #{@new_resource.service_name} default")
|
66
66
|
end
|
67
67
|
end
|
@@ -24,6 +24,8 @@ class Chef
|
|
24
24
|
class Service
|
25
25
|
class Init < Chef::Provider::Service::Simple
|
26
26
|
|
27
|
+
attr_accessor :init_command
|
28
|
+
|
27
29
|
def initialize(new_resource, run_context)
|
28
30
|
super
|
29
31
|
@init_command = "/etc/init.d/#{@new_resource.service_name}"
|
@@ -48,7 +50,7 @@ class Chef
|
|
48
50
|
if @new_resource.start_command
|
49
51
|
super
|
50
52
|
else
|
51
|
-
|
53
|
+
shell_out_with_systems_locale!("#{default_init_command} start")
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -56,7 +58,7 @@ class Chef
|
|
56
58
|
if @new_resource.stop_command
|
57
59
|
super
|
58
60
|
else
|
59
|
-
|
61
|
+
shell_out_with_systems_locale!("#{default_init_command} stop")
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -64,7 +66,7 @@ class Chef
|
|
64
66
|
if @new_resource.restart_command
|
65
67
|
super
|
66
68
|
elsif @new_resource.supports[:restart]
|
67
|
-
|
69
|
+
shell_out_with_systems_locale!("#{default_init_command} restart")
|
68
70
|
else
|
69
71
|
stop_service
|
70
72
|
sleep 1
|
@@ -76,7 +78,7 @@ class Chef
|
|
76
78
|
if @new_resource.reload_command
|
77
79
|
super
|
78
80
|
elsif @new_resource.supports[:reload]
|
79
|
-
|
81
|
+
shell_out_with_systems_locale!("#{default_init_command} reload")
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
@@ -37,12 +37,12 @@ class Chef
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def enable_service()
|
40
|
-
|
41
|
-
|
40
|
+
shell_out!("/sbin/insserv -r -f #{@new_resource.service_name}")
|
41
|
+
shell_out!("/sbin/insserv -d -f #{@new_resource.service_name}")
|
42
42
|
end
|
43
43
|
|
44
44
|
def disable_service()
|
45
|
-
|
45
|
+
shell_out!("/sbin/insserv -r -f #{@new_resource.service_name}")
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -83,7 +83,7 @@ class Chef
|
|
83
83
|
if @new_resource.start_command
|
84
84
|
super
|
85
85
|
else
|
86
|
-
|
86
|
+
shell_out_with_systems_locale!("launchctl load -w '#{@plist}'", :user => @owner_uid, :group => @owner_gid)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
@@ -95,7 +95,7 @@ class Chef
|
|
95
95
|
if @new_resource.stop_command
|
96
96
|
super
|
97
97
|
else
|
98
|
-
|
98
|
+
shell_out_with_systems_locale!("launchctl unload '#{@plist}'", :user => @owner_uid, :group => @owner_gid)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -25,6 +25,8 @@ class Chef
|
|
25
25
|
class Service
|
26
26
|
class Simple < Chef::Provider::Service
|
27
27
|
|
28
|
+
attr_reader :status_load_success
|
29
|
+
|
28
30
|
def load_current_resource
|
29
31
|
@current_resource = Chef::Resource::Service.new(@new_resource.name)
|
30
32
|
@current_resource.service_name(@new_resource.service_name)
|
@@ -83,16 +85,16 @@ class Chef
|
|
83
85
|
end
|
84
86
|
|
85
87
|
def start_service
|
86
|
-
|
88
|
+
shell_out_with_systems_locale!(@new_resource.start_command)
|
87
89
|
end
|
88
90
|
|
89
91
|
def stop_service
|
90
|
-
|
92
|
+
shell_out_with_systems_locale!(@new_resource.stop_command)
|
91
93
|
end
|
92
94
|
|
93
95
|
def restart_service
|
94
96
|
if @new_resource.restart_command
|
95
|
-
|
97
|
+
shell_out_with_systems_locale!(@new_resource.restart_command)
|
96
98
|
else
|
97
99
|
stop_service
|
98
100
|
sleep 1
|
@@ -101,7 +103,7 @@ class Chef
|
|
101
103
|
end
|
102
104
|
|
103
105
|
def reload_service
|
104
|
-
|
106
|
+
shell_out_with_systems_locale!(@new_resource.reload_command)
|
105
107
|
end
|
106
108
|
|
107
109
|
protected
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
alias_method :start_service, :enable_service
|
57
57
|
|
58
58
|
def reload_service
|
59
|
-
|
59
|
+
shell_out_with_systems_locale!("#{default_init_command} refresh #{@new_resource.service_name}")
|
60
60
|
end
|
61
61
|
|
62
62
|
def restart_service
|
@@ -28,7 +28,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
28
28
|
if @new_resource.status_command
|
29
29
|
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
|
30
30
|
|
31
|
-
unless
|
31
|
+
unless shell_out(@new_resource.status_command).error?
|
32
32
|
@current_resource.running(true)
|
33
33
|
else
|
34
34
|
@status_check_success = false
|
@@ -61,7 +61,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
61
61
|
if @new_resource.start_command
|
62
62
|
super
|
63
63
|
else
|
64
|
-
shell_out_with_systems_locale("/bin/systemctl start #{@new_resource.service_name}")
|
64
|
+
shell_out_with_systems_locale!("/bin/systemctl start #{@new_resource.service_name}")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -73,7 +73,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
73
73
|
if @new_resource.stop_command
|
74
74
|
super
|
75
75
|
else
|
76
|
-
shell_out_with_systems_locale("/bin/systemctl stop #{@new_resource.service_name}")
|
76
|
+
shell_out_with_systems_locale!("/bin/systemctl stop #{@new_resource.service_name}")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -82,7 +82,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
82
82
|
if @new_resource.restart_command
|
83
83
|
super
|
84
84
|
else
|
85
|
-
shell_out_with_systems_locale("/bin/systemctl restart #{@new_resource.service_name}")
|
85
|
+
shell_out_with_systems_locale!("/bin/systemctl restart #{@new_resource.service_name}")
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -91,7 +91,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
91
91
|
super
|
92
92
|
else
|
93
93
|
if @current_resource.running
|
94
|
-
shell_out_with_systems_locale("/bin/systemctl reload #{@new_resource.service_name}")
|
94
|
+
shell_out_with_systems_locale!("/bin/systemctl reload #{@new_resource.service_name}")
|
95
95
|
else
|
96
96
|
start_service
|
97
97
|
end
|
@@ -99,18 +99,18 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def enable_service
|
102
|
-
|
102
|
+
shell_out!("/bin/systemctl enable #{@new_resource.service_name}")
|
103
103
|
end
|
104
104
|
|
105
105
|
def disable_service
|
106
|
-
|
106
|
+
shell_out!("/bin/systemctl disable #{@new_resource.service_name}")
|
107
107
|
end
|
108
108
|
|
109
109
|
def is_active?
|
110
|
-
|
110
|
+
shell_out("/bin/systemctl is-active #{@new_resource.service_name} --quiet").exitstatus == 0
|
111
111
|
end
|
112
112
|
|
113
113
|
def is_enabled?
|
114
|
-
|
114
|
+
shell_out("/bin/systemctl is-enabled #{@new_resource.service_name} --quiet").exitstatus == 0
|
115
115
|
end
|
116
116
|
end
|
@@ -97,10 +97,10 @@ class Chef
|
|
97
97
|
Chef::Log.debug("#{@new_resource} you have specified a status command, running..")
|
98
98
|
|
99
99
|
begin
|
100
|
-
if
|
100
|
+
if shell_out!(@new_resource.status_command) == 0
|
101
101
|
@current_resource.running true
|
102
102
|
end
|
103
|
-
rescue
|
103
|
+
rescue
|
104
104
|
@command_success = false
|
105
105
|
@current_resource.running false
|
106
106
|
nil
|
@@ -153,7 +153,7 @@ class Chef
|
|
153
153
|
if @new_resource.start_command
|
154
154
|
super
|
155
155
|
else
|
156
|
-
|
156
|
+
shell_out_with_systems_locale!("/sbin/start #{@job}")
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
@@ -167,7 +167,7 @@ class Chef
|
|
167
167
|
if @new_resource.stop_command
|
168
168
|
super
|
169
169
|
else
|
170
|
-
|
170
|
+
shell_out_with_systems_locale!("/sbin/stop #{@job}")
|
171
171
|
end
|
172
172
|
end
|
173
173
|
end
|
@@ -179,7 +179,7 @@ class Chef
|
|
179
179
|
# Older versions of upstart would fail on restart if the service was currently stopped, check for that. LP:430883
|
180
180
|
else
|
181
181
|
if @current_resource.running
|
182
|
-
|
182
|
+
shell_out_with_systems_locale!("/sbin/restart #{@job}")
|
183
183
|
else
|
184
184
|
start_service
|
185
185
|
end
|
@@ -191,7 +191,7 @@ class Chef
|
|
191
191
|
super
|
192
192
|
else
|
193
193
|
# upstart >= 0.6.3-4 supports reload (HUP)
|
194
|
-
|
194
|
+
shell_out_with_systems_locale!("/sbin/reload #{@job}")
|
195
195
|
end
|
196
196
|
end
|
197
197
|
|
@@ -60,7 +60,7 @@ class Chef
|
|
60
60
|
def action_checkout
|
61
61
|
if target_dir_non_existent_or_empty?
|
62
62
|
converge_by("perform checkout of #{@new_resource.repository} into #{@new_resource.destination}") do
|
63
|
-
|
63
|
+
shell_out!(run_options(command: checkout_command))
|
64
64
|
end
|
65
65
|
else
|
66
66
|
Chef::Log.debug "#{@new_resource} checkout destination #{@new_resource.destination} already exists or is a non-empty directory - nothing to do"
|
@@ -77,7 +77,7 @@ class Chef
|
|
77
77
|
|
78
78
|
def action_force_export
|
79
79
|
converge_by("export #{@new_resource.repository} into #{@new_resource.destination}") do
|
80
|
-
|
80
|
+
shell_out!(run_options(command: export_command))
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -88,7 +88,7 @@ class Chef
|
|
88
88
|
Chef::Log.debug "#{@new_resource} current revision: #{current_rev} target revision: #{revision_int}"
|
89
89
|
unless current_revision_matches_target_revision?
|
90
90
|
converge_by("sync #{@new_resource.destination} from #{@new_resource.repository}") do
|
91
|
-
|
91
|
+
shell_out!(run_options(command: sync_command))
|
92
92
|
Chef::Log.info "#{@new_resource} updated to revision: #{revision_int}"
|
93
93
|
end
|
94
94
|
end
|
@@ -100,14 +100,14 @@ class Chef
|
|
100
100
|
def sync_command
|
101
101
|
c = scm :update, @new_resource.svn_arguments, verbose, authentication, "-r#{revision_int}", @new_resource.destination
|
102
102
|
Chef::Log.debug "#{@new_resource} updated working copy #{@new_resource.destination} to revision #{@new_resource.revision}"
|
103
|
-
|
103
|
+
c
|
104
104
|
end
|
105
105
|
|
106
106
|
def checkout_command
|
107
107
|
c = scm :checkout, @new_resource.svn_arguments, verbose, authentication,
|
108
108
|
"-r#{revision_int}", @new_resource.repository, @new_resource.destination
|
109
109
|
Chef::Log.info "#{@new_resource} checked out #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
|
110
|
-
|
110
|
+
c
|
111
111
|
end
|
112
112
|
|
113
113
|
def export_command
|
@@ -116,7 +116,7 @@ class Chef
|
|
116
116
|
"-r#{revision_int}" << @new_resource.repository << @new_resource.destination
|
117
117
|
c = scm :export, *args
|
118
118
|
Chef::Log.info "#{@new_resource} exported #{@new_resource.repository} at revision #{@new_resource.revision} to #{@new_resource.destination}"
|
119
|
-
|
119
|
+
c
|
120
120
|
end
|
121
121
|
|
122
122
|
# If the specified revision isn't an integer ("HEAD" for example), look
|
@@ -109,18 +109,18 @@ user password using shadow hash.")
|
|
109
109
|
@current_resource = Chef::Resource::User.new(@new_resource.username)
|
110
110
|
@current_resource.username(@new_resource.username)
|
111
111
|
|
112
|
-
user_info = read_user_info
|
113
|
-
if user_info
|
114
|
-
@current_resource.uid(dscl_get(user_info, :uid))
|
115
|
-
@current_resource.gid(dscl_get(user_info, :gid))
|
116
|
-
@current_resource.home(dscl_get(user_info, :home))
|
117
|
-
@current_resource.shell(dscl_get(user_info, :shell))
|
118
|
-
@current_resource.comment(dscl_get(user_info, :comment))
|
119
|
-
@authentication_authority = dscl_get(user_info, :auth_authority)
|
120
|
-
|
121
|
-
if @new_resource.password && dscl_get(user_info, :password) == "********"
|
112
|
+
@user_info = read_user_info
|
113
|
+
if @user_info
|
114
|
+
@current_resource.uid(dscl_get(@user_info, :uid))
|
115
|
+
@current_resource.gid(dscl_get(@user_info, :gid))
|
116
|
+
@current_resource.home(dscl_get(@user_info, :home))
|
117
|
+
@current_resource.shell(dscl_get(@user_info, :shell))
|
118
|
+
@current_resource.comment(dscl_get(@user_info, :comment))
|
119
|
+
@authentication_authority = dscl_get(@user_info, :auth_authority)
|
120
|
+
|
121
|
+
if @new_resource.password && dscl_get(@user_info, :password) == "********"
|
122
122
|
# A password is set. Let's get the password information from shadow file
|
123
|
-
shadow_hash_binary = dscl_get(user_info, :shadow_hash)
|
123
|
+
shadow_hash_binary = dscl_get(@user_info, :shadow_hash)
|
124
124
|
|
125
125
|
# Calling shell_out directly since we want to give an input stream
|
126
126
|
shadow_hash_xml = convert_binary_plist_to_xml(shadow_hash_binary.string)
|
@@ -157,22 +157,26 @@ user password using shadow hash.")
|
|
157
157
|
|
158
158
|
def create_user
|
159
159
|
dscl_create_user
|
160
|
+
# set_password modifies the plist file of the user directly. So update
|
161
|
+
# the password first before making any modifications to the user.
|
162
|
+
set_password
|
160
163
|
dscl_create_comment
|
161
164
|
dscl_set_uid
|
162
165
|
dscl_set_gid
|
163
166
|
dscl_set_home
|
164
167
|
dscl_set_shell
|
165
|
-
set_password
|
166
168
|
end
|
167
169
|
|
168
170
|
def manage_user
|
171
|
+
# set_password modifies the plist file of the user directly. So update
|
172
|
+
# the password first before making any modifications to the user.
|
173
|
+
set_password if diverged_password?
|
169
174
|
dscl_create_user if diverged?(:username)
|
170
175
|
dscl_create_comment if diverged?(:comment)
|
171
176
|
dscl_set_uid if diverged?(:uid)
|
172
177
|
dscl_set_gid if diverged?(:gid)
|
173
178
|
dscl_set_home if diverged?(:home)
|
174
179
|
dscl_set_shell if diverged?(:shell)
|
175
|
-
set_password if diverged_password?
|
176
180
|
end
|
177
181
|
|
178
182
|
#
|
@@ -338,22 +342,18 @@ user password using shadow hash.")
|
|
338
342
|
:input => shadow_info.to_plist, :live_stream => shadow_info_binary)
|
339
343
|
command.run_command
|
340
344
|
|
345
|
+
if @user_info.nil?
|
346
|
+
# User is just created. read_user_info() will read the fresh information
|
347
|
+
# for the user with a cache flush. However with experimentation we've seen
|
348
|
+
# that dscl cache is not immediately updated after the creation of the user
|
349
|
+
# This is odd and needs to be investigated further.
|
350
|
+
sleep 3
|
351
|
+
@user_info = read_user_info
|
352
|
+
end
|
353
|
+
|
341
354
|
# Replace the shadow info in user's plist
|
342
|
-
user_info
|
343
|
-
|
344
|
-
|
345
|
-
#
|
346
|
-
# Before saving the user's plist file we need to wait for dscl to
|
347
|
-
# update its caches and flush them to disk. In order to achieve this
|
348
|
-
# we need to wait first for our changes to get into the dscl cache
|
349
|
-
# and then flush the cache to disk before saving password into the
|
350
|
-
# plist file. 3 seconds is the minimum experimental value for dscl
|
351
|
-
# cache to be updated. We can get rid of this sleep when we find a
|
352
|
-
# trigger to update dscl cache.
|
353
|
-
#
|
354
|
-
sleep 3
|
355
|
-
shell_out("dscacheutil '-flushcache'")
|
356
|
-
save_user_info(user_info)
|
355
|
+
dscl_set(@user_info, :shadow_hash, shadow_info_binary)
|
356
|
+
save_user_info(@user_info)
|
357
357
|
end
|
358
358
|
|
359
359
|
#
|
@@ -554,6 +554,10 @@ user password using shadow hash.")
|
|
554
554
|
def read_user_info
|
555
555
|
user_info = nil
|
556
556
|
|
557
|
+
# We flush the cache here in order to make sure that we read fresh information
|
558
|
+
# for the user.
|
559
|
+
shell_out("dscacheutil '-flushcache'")
|
560
|
+
|
557
561
|
begin
|
558
562
|
user_plist_file = "#{USER_PLIST_DIRECTORY}/#{@new_resource.username}.plist"
|
559
563
|
user_plist_info = run_plutil("convert xml1 -o - #{user_plist_file}")
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'chef/provider/user'
|
20
|
+
require 'chef/exceptions'
|
20
21
|
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
|
21
22
|
require 'chef/util/windows/net_user'
|
22
23
|
end
|
@@ -28,7 +29,7 @@ class Chef
|
|
28
29
|
|
29
30
|
def initialize(new_resource,run_context)
|
30
31
|
super
|
31
|
-
@net_user = Chef::Util::Windows::NetUser.new(@new_resource.
|
32
|
+
@net_user = Chef::Util::Windows::NetUser.new(@new_resource.username)
|
32
33
|
end
|
33
34
|
|
34
35
|
def load_current_resource
|
@@ -37,17 +38,16 @@ class Chef
|
|
37
38
|
user_info = nil
|
38
39
|
begin
|
39
40
|
user_info = @net_user.get_info
|
40
|
-
rescue
|
41
|
-
@user_exists = false
|
42
|
-
Chef::Log.debug("#{@new_resource} does not exist")
|
43
|
-
end
|
44
41
|
|
45
|
-
if user_info
|
46
42
|
@current_resource.uid(user_info[:user_id])
|
47
43
|
@current_resource.gid(user_info[:primary_group_id])
|
48
44
|
@current_resource.comment(user_info[:full_name])
|
49
45
|
@current_resource.home(user_info[:home_dir])
|
50
46
|
@current_resource.shell(user_info[:script_path])
|
47
|
+
rescue Chef::Exceptions::UserIDNotFound => e
|
48
|
+
# e.message should be "The user name could not be found" but checking for that could cause a localization bug
|
49
|
+
@user_exists = false
|
50
|
+
Chef::Log.debug("#{@new_resource} does not exist (#{e.message})")
|
51
51
|
end
|
52
52
|
|
53
53
|
@current_resource
|