chef 0.7.10 → 0.7.12
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of chef might be problematic. Click here for more details.
- data/distro/debian/etc/init.d/chef-client +175 -0
- data/distro/debian/etc/init.d/chef-indexer +175 -0
- data/distro/debian/etc/init.d/chef-server +120 -0
- data/distro/debian/man/man1/chef-indexer.1 +42 -0
- data/distro/debian/man/man1/chef-server.1 +108 -0
- data/distro/debian/man/man8/chef-client.8 +61 -0
- data/distro/debian/man/man8/chef-solo.8 +58 -0
- data/distro/redhat/etc/chef/client.rb +16 -0
- data/distro/redhat/etc/chef/indexer.rb +10 -0
- data/distro/redhat/etc/chef/server.rb +22 -0
- data/distro/redhat/etc/init.d/chef-client +74 -0
- data/distro/redhat/etc/init.d/chef-indexer +76 -0
- data/distro/redhat/etc/init.d/chef-server +77 -0
- data/lib/chef.rb +1 -1
- data/lib/chef/client.rb +33 -8
- data/lib/chef/compile.rb +34 -2
- data/lib/chef/cookbook.rb +29 -2
- data/lib/chef/cookbook_loader.rb +61 -49
- data/lib/chef/couchdb.rb +7 -3
- data/lib/chef/mixin/command.rb +67 -32
- data/lib/chef/mixin/convert_to_class_name.rb +48 -0
- data/lib/chef/mixin/find_preferred_file.rb +5 -14
- data/lib/chef/mixin/from_file.rb +14 -0
- data/lib/chef/mixin/generate_url.rb +2 -1
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +77 -0
- data/lib/chef/platform.rb +1 -1
- data/lib/chef/provider.rb +63 -2
- data/lib/chef/provider/cron.rb +75 -25
- data/lib/chef/provider/deploy.rb +281 -0
- data/lib/chef/provider/deploy/revision.rb +70 -0
- data/lib/chef/provider/deploy/timestamped.rb +33 -0
- data/lib/chef/provider/git.rb +194 -0
- data/lib/chef/provider/group.rb +2 -2
- data/lib/chef/provider/group/gpasswd.rb +50 -0
- data/lib/chef/provider/group/groupadd.rb +2 -16
- data/lib/chef/provider/group/usermod.rb +57 -0
- data/lib/chef/provider/ifconfig.rb +3 -3
- data/lib/chef/provider/mount.rb +0 -4
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/package.rb +2 -2
- data/lib/chef/provider/package/apt.rb +4 -4
- data/lib/chef/provider/package/dpkg.rb +9 -13
- data/lib/chef/provider/package/freebsd.rb +6 -6
- data/lib/chef/provider/package/macports.rb +4 -4
- data/lib/chef/provider/package/portage.rb +3 -3
- data/lib/chef/provider/package/rpm.rb +4 -4
- data/lib/chef/provider/package/rubygems.rb +10 -4
- data/lib/chef/provider/package/yum.rb +6 -6
- data/lib/chef/provider/remote_file.rb +14 -7
- data/lib/chef/provider/service.rb +8 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +8 -63
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/simple.rb +115 -0
- data/lib/chef/provider/subversion.rb +145 -0
- data/lib/chef/provider/template.rb +2 -0
- data/lib/chef/provider/user.rb +2 -2
- data/lib/chef/recipe.rb +9 -75
- data/lib/chef/resource.rb +131 -7
- data/lib/chef/resource/cron.rb +36 -0
- data/lib/chef/resource/deploy.rb +360 -0
- data/lib/chef/resource/deploy_revision.rb +35 -0
- data/lib/chef/resource/git.rb +36 -0
- data/lib/chef/resource/group.rb +2 -0
- data/lib/chef/resource/scm.rb +129 -0
- data/lib/chef/resource/subversion.rb +33 -0
- data/lib/chef/resource/timestamped_deploy.rb +31 -0
- data/lib/chef/resource_collection.rb +32 -4
- data/lib/chef/runner.rb +35 -28
- metadata +40 -11
@@ -0,0 +1,70 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
class Provider
|
21
|
+
class Deploy
|
22
|
+
class Revision < Chef::Provider::Deploy
|
23
|
+
|
24
|
+
def all_releases
|
25
|
+
sorted_releases
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def release_created(release)
|
31
|
+
sorted_releases { |r| r << release }
|
32
|
+
end
|
33
|
+
|
34
|
+
def release_deleted(release)
|
35
|
+
sorted_releases { |r| r.delete(release)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def release_slug
|
39
|
+
scm_provider.revision_slug
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def sorted_releases
|
45
|
+
cache = load_cache
|
46
|
+
if block_given?
|
47
|
+
yield cache
|
48
|
+
save_cache(cache)
|
49
|
+
end
|
50
|
+
cache
|
51
|
+
end
|
52
|
+
|
53
|
+
def load_cache
|
54
|
+
begin
|
55
|
+
JSON.parse(Chef::FileCache.load("revision-deploys/#{new_resource.name}"))
|
56
|
+
rescue
|
57
|
+
Chef::Exceptions::FileNotFound
|
58
|
+
save_cache([])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def save_cache(cache)
|
63
|
+
Chef::FileCache.store("revision-deploys/#{new_resource.name}", cache.to_json)
|
64
|
+
cache
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2009 Daniel DeLeo
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
class Chef
|
20
|
+
class Provider
|
21
|
+
class Deploy
|
22
|
+
class Timestamped < Chef::Provider::Deploy
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def release_slug
|
27
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Daniel DeLeo (<dan@kallistec.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
|
20
|
+
require 'chef/log'
|
21
|
+
require 'chef/provider'
|
22
|
+
require 'chef/mixin/command'
|
23
|
+
require 'fileutils'
|
24
|
+
|
25
|
+
class Chef
|
26
|
+
class Provider
|
27
|
+
class Git < Chef::Provider
|
28
|
+
|
29
|
+
include Chef::Mixin::Command
|
30
|
+
|
31
|
+
def load_current_resource
|
32
|
+
@current_resource = Chef::Resource::Git.new(@new_resource.name)
|
33
|
+
if current_revision = find_current_revision
|
34
|
+
@current_resource.revision current_revision
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def action_checkout
|
39
|
+
clone
|
40
|
+
checkout
|
41
|
+
enable_submodules
|
42
|
+
end
|
43
|
+
|
44
|
+
def action_export
|
45
|
+
action_checkout
|
46
|
+
FileUtils.rm_rf(::File.join(@new_resource.destination,".git"))
|
47
|
+
end
|
48
|
+
|
49
|
+
def action_sync
|
50
|
+
if !::File.exist?(@new_resource.destination) || Dir.entries(@new_resource.destination) == ['.','..']
|
51
|
+
action_checkout
|
52
|
+
else
|
53
|
+
sync
|
54
|
+
enable_submodules
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def find_current_revision
|
59
|
+
if ::File.exist?(::File.join(cwd, ".git"))
|
60
|
+
status, result, error_message = output_of_command("git rev-parse HEAD", run_options(:cwd=>cwd))
|
61
|
+
|
62
|
+
# 128 is returned when we're not in a git repo. this is fine
|
63
|
+
unless [0,128].include?(status.exitstatus)
|
64
|
+
handle_command_failures(status, "STDOUT: #{result}\nSTDERR: #{error_message}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
sha_hash?(result) ? result : nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def clone
|
71
|
+
remote = @new_resource.remote
|
72
|
+
|
73
|
+
args = []
|
74
|
+
args << "-o #{remote}" unless remote == 'origin'
|
75
|
+
args << "--depth #{@new_resource.depth}" if @new_resource.depth
|
76
|
+
|
77
|
+
Chef::Log.info "Cloning repo #{@new_resource.repository} to #{@new_resource.destination}"
|
78
|
+
|
79
|
+
clone_cmd = "#{git} clone #{args.join(' ')} #{@new_resource.repository} #{@new_resource.destination}"
|
80
|
+
run_command(run_options(:command => clone_cmd))
|
81
|
+
end
|
82
|
+
|
83
|
+
def checkout
|
84
|
+
sha_ref = revision_sha
|
85
|
+
Chef::Log.info "Checking out branch: #{@new_resource.revision} reference: #{sha_ref}"
|
86
|
+
# checkout into a local branch rather than a detached HEAD
|
87
|
+
run_command(run_options(:command => "#{git} checkout -b deploy #{sha_ref}", :cwd => @new_resource.destination))
|
88
|
+
end
|
89
|
+
|
90
|
+
def enable_submodules
|
91
|
+
if @new_resource.enable_submodules
|
92
|
+
Chef::Log.info "Enabling git submodules"
|
93
|
+
command = "#{git} submodule init && #{git} submodule update"
|
94
|
+
run_command(run_options(:command => command, :cwd => @new_resource.destination))
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def sync
|
99
|
+
revision = revision_sha
|
100
|
+
sync_command = []
|
101
|
+
|
102
|
+
# Use git-config to setup a remote tracking branches. Could use
|
103
|
+
# git-remote but it complains when a remote of the same name already
|
104
|
+
# exists, git-config will just silenty overwrite the setting every
|
105
|
+
# time. This could cause wierd-ness in the remote cache if the url
|
106
|
+
# changes between calls, but as long as the repositories are all
|
107
|
+
# based from each other it should still work fine.
|
108
|
+
if @new_resource.remote != 'origin'
|
109
|
+
Chef::Log.info "Configuring remote tracking branches for repository #{@new_resource.repository} "+
|
110
|
+
"at remote #{@new_resource.remote}"
|
111
|
+
sync_command << "#{git} config remote.#{@new_resource.remote}.url #{@new_resource.repository}"
|
112
|
+
sync_command << "#{git} config remote.#{@new_resource.remote}.fetch +refs/heads/*:refs/remotes/#{@new_resource.remote}/*"
|
113
|
+
end
|
114
|
+
|
115
|
+
# since we're in a local branch already, just reset to specified revision rather than merge
|
116
|
+
sync_command << "#{git} fetch #{@new_resource.remote} && #{git} reset --hard #{revision}"
|
117
|
+
Chef::Log.info "Fetching updates from #{new_resource.remote} and resetting to revison #{revision}"
|
118
|
+
run_command(run_options(:command => sync_command.join(" && "), :cwd => @new_resource.destination))
|
119
|
+
end
|
120
|
+
|
121
|
+
def revision_sha
|
122
|
+
@revision_sha ||= begin
|
123
|
+
assert_revision_not_remote
|
124
|
+
|
125
|
+
if sha_hash?(@new_resource.revision)
|
126
|
+
@revision_sha = @new_resource.revision
|
127
|
+
else
|
128
|
+
resolved_reference = remote_resolve_reference
|
129
|
+
@revision_sha = extract_revision(resolved_reference)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
alias :revision_slug :revision_sha
|
135
|
+
|
136
|
+
def remote_resolve_reference
|
137
|
+
command = scm('ls-remote', @new_resource.repository, @new_resource.revision)
|
138
|
+
Chef::Log.debug("Executing #{command}")
|
139
|
+
begin
|
140
|
+
status, result, error_message = output_of_command(command, run_options)
|
141
|
+
handle_command_failures(status, "STDOUT: #{result}\nSTDERR: #{error_message}")
|
142
|
+
rescue RuntimeError => e
|
143
|
+
raise RuntimeError, e.message + "\n" + "Could not access the remote Git repository. "+
|
144
|
+
"If this is a private repository, please verify that the deploy key for your application " +
|
145
|
+
"has been added to your remote Git account."
|
146
|
+
end
|
147
|
+
result
|
148
|
+
end
|
149
|
+
|
150
|
+
private
|
151
|
+
|
152
|
+
def run_options(run_opts={})
|
153
|
+
run_opts[:user] = @new_resource.user if @new_resource.user
|
154
|
+
run_opts[:environment] = {"GIT_SSH" => @new_resource.ssh_wrapper} if @new_resource.ssh_wrapper
|
155
|
+
run_opts
|
156
|
+
end
|
157
|
+
|
158
|
+
def cwd
|
159
|
+
@new_resource.destination
|
160
|
+
end
|
161
|
+
|
162
|
+
def scm(*args)
|
163
|
+
[git, *args].compact.join(" ")
|
164
|
+
end
|
165
|
+
|
166
|
+
def git
|
167
|
+
'git'
|
168
|
+
end
|
169
|
+
|
170
|
+
def sha_hash?(string)
|
171
|
+
string =~ /^[0-9a-f]{40}$/
|
172
|
+
end
|
173
|
+
|
174
|
+
def assert_revision_not_remote
|
175
|
+
if @new_resource.revision =~ /^origin\//
|
176
|
+
reference = @new_resource.revision
|
177
|
+
error_text = "Deploying remote branches is not supported. " +
|
178
|
+
"Specify the remote branch as a local branch for " +
|
179
|
+
"the git repository you're deploying from " +
|
180
|
+
"(ie: '#{reference.gsub('origin/', '')}' rather than '#{reference}')."
|
181
|
+
raise RuntimeError, error_text
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def extract_revision(resolved_reference)
|
186
|
+
unless resolved_reference =~ /^([0-9a-f]{40})\s+(\S+)/
|
187
|
+
raise "Unable to resolve reference for '#{resolved_reference}' on repository '#{@new_resource.repository}'."
|
188
|
+
end
|
189
|
+
$1
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
data/lib/chef/provider/group.rb
CHANGED
@@ -27,8 +27,8 @@ class Chef
|
|
27
27
|
include Chef::Mixin::Command
|
28
28
|
attr_accessor :group_exists
|
29
29
|
|
30
|
-
def initialize(node, new_resource)
|
31
|
-
super(node, new_resource)
|
30
|
+
def initialize(node, new_resource, collection=nil, definitions=nil, cookbook_loader=nil)
|
31
|
+
super(node, new_resource, collection, definitions, cookbook_loader)
|
32
32
|
@group_exists = true
|
33
33
|
end
|
34
34
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#
|
2
|
+
# Author:: AJ Christensen (<aj@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 OpsCode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/provider/group/groupadd'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Provider
|
23
|
+
class Group
|
24
|
+
class Gpasswd < Chef::Provider::Group::Groupadd
|
25
|
+
|
26
|
+
def load_current_resource
|
27
|
+
super
|
28
|
+
|
29
|
+
raise Chef::Exceptions::Group, "Could not find binary /usr/bin/gpasswd for #{@new_resource}" unless ::File.exists?("/usr/bin/gpasswd")
|
30
|
+
end
|
31
|
+
|
32
|
+
def modify_group_members
|
33
|
+
unless @new_resource.members.empty?
|
34
|
+
if(@new_resource.append)
|
35
|
+
@new_resource.members.each do |member|
|
36
|
+
Chef::Log.debug("#{@new_resource}: appending member #{member} to group #{@new_resource.group_name}")
|
37
|
+
run_command(:command => "gpasswd -a #{member} #{@new_resource.group_name}")
|
38
|
+
end
|
39
|
+
else
|
40
|
+
Chef::Log.debug("#{@new_resource}: setting group members to #{@new_resource.members.join(', ')}")
|
41
|
+
run_command(:command => "gpasswd -M #{@new_resource.members.join(',')} #{@new_resource.group_name}")
|
42
|
+
end
|
43
|
+
else
|
44
|
+
Chef::Log.debug("#{@new_resource}: not changing group members, the group has no members")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -26,8 +26,7 @@ class Chef
|
|
26
26
|
|
27
27
|
[ "/usr/sbin/groupadd",
|
28
28
|
"/usr/sbin/groupmod",
|
29
|
-
"/usr/sbin/groupdel"
|
30
|
-
"/usr/bin/gpasswd" ].each do |required_binary|
|
29
|
+
"/usr/sbin/groupdel" ].each do |required_binary|
|
31
30
|
raise Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{@new_resource}" unless ::File.exists?(required_binary)
|
32
31
|
end
|
33
32
|
end
|
@@ -54,21 +53,8 @@ class Chef
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def modify_group_members
|
57
|
-
|
58
|
-
if(@new_resource.append)
|
59
|
-
@new_resource.members.each do |member|
|
60
|
-
Chef::Log.debug("#{@new_resource}: appending member #{member} to group #{@new_resource.group_name}")
|
61
|
-
run_command(:command => "gpasswd -a #{member} #{@new_resource.group_name}")
|
62
|
-
end
|
63
|
-
else
|
64
|
-
Chef::Log.debug("#{@new_resource}: setting group members to #{@new_resource.members.join(', ')}")
|
65
|
-
run_command(:command => "gpasswd -M #{@new_resource.members.join(',')} #{@new_resource.group_name}")
|
66
|
-
end
|
67
|
-
else
|
68
|
-
Chef::Log.debug("#{@new_resource}: not changing group members, the group has no members")
|
69
|
-
end
|
56
|
+
raise Chef::Exceptions::Group, "you must override modify_group_members in #{self.to_s}"
|
70
57
|
end
|
71
|
-
|
72
58
|
# Little bit of magic as per Adam's useradd provider to pull the assign the command line flags
|
73
59
|
#
|
74
60
|
# ==== Returns
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
# Author:: AJ Christensen (<aj@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2008 OpsCode, Inc.
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'chef/provider/group/groupadd'
|
20
|
+
|
21
|
+
class Chef
|
22
|
+
class Provider
|
23
|
+
class Group
|
24
|
+
class Usermod < Chef::Provider::Group::Groupadd
|
25
|
+
|
26
|
+
def load_current_resource
|
27
|
+
super
|
28
|
+
|
29
|
+
raise Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod for #{@new_resource}" unless ::File.exists?("/usr/sbin/usermod")
|
30
|
+
end
|
31
|
+
|
32
|
+
def modify_group_members
|
33
|
+
case node[:platform]
|
34
|
+
when "openbsd", "netbsd"
|
35
|
+
append_flags = "-G"
|
36
|
+
when "solaris"
|
37
|
+
append_flags = "-a -G"
|
38
|
+
end
|
39
|
+
|
40
|
+
unless @new_resource.members.empty?
|
41
|
+
if(@new_resource.append)
|
42
|
+
@new_resource.members.each do |member|
|
43
|
+
Chef::Log.debug("#{@new_resource}: appending member #{member} to group #{@new_resource.group_name}")
|
44
|
+
run_command(:command => "usermod #{append_flags} #{@new_resource.group_name} #{member}" )
|
45
|
+
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise Chef::Exceptions::Group, "setting group members directly is not supported by #{self.to_s}"
|
49
|
+
end
|
50
|
+
else
|
51
|
+
Chef::Log.debug("#{@new_resource}: not changing group members, the group has no members")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|