microwave 0.1004.4 → 0.1004.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +0 -3
- data/lib/chef/client.rb +2 -11
- data/lib/chef/platform.rb +1 -192
- data/lib/chef/providers.rb +0 -68
- data/lib/chef/resources.rb +0 -36
- data/lib/chef/version.rb +1 -1
- metadata +123 -239
- data/lib/chef/provider/breakpoint.rb +0 -31
- data/lib/chef/provider/cron.rb +0 -186
- data/lib/chef/provider/cron/solaris.rb +0 -195
- data/lib/chef/provider/deploy.rb +0 -343
- data/lib/chef/provider/deploy/revision.rb +0 -80
- data/lib/chef/provider/deploy/timestamped.rb +0 -33
- data/lib/chef/provider/env.rb +0 -152
- data/lib/chef/provider/env/windows.rb +0 -75
- data/lib/chef/provider/erl_call.rb +0 -101
- data/lib/chef/provider/git.rb +0 -243
- data/lib/chef/provider/group.rb +0 -133
- data/lib/chef/provider/group/aix.rb +0 -70
- data/lib/chef/provider/group/dscl.rb +0 -121
- data/lib/chef/provider/group/gpasswd.rb +0 -53
- data/lib/chef/provider/group/groupadd.rb +0 -81
- data/lib/chef/provider/group/pw.rb +0 -84
- data/lib/chef/provider/group/suse.rb +0 -53
- data/lib/chef/provider/group/usermod.rb +0 -57
- data/lib/chef/provider/group/windows.rb +0 -79
- data/lib/chef/provider/ifconfig.rb +0 -134
- data/lib/chef/provider/log.rb +0 -54
- data/lib/chef/provider/mdadm.rb +0 -91
- data/lib/chef/provider/mount.rb +0 -114
- data/lib/chef/provider/mount/mount.rb +0 -240
- data/lib/chef/provider/mount/windows.rb +0 -81
- data/lib/chef/provider/ohai.rb +0 -42
- data/lib/chef/provider/package.rb +0 -163
- data/lib/chef/provider/package/apt.rb +0 -135
- data/lib/chef/provider/package/dpkg.rb +0 -115
- data/lib/chef/provider/package/easy_install.rb +0 -136
- data/lib/chef/provider/package/freebsd.rb +0 -125
- data/lib/chef/provider/package/macports.rb +0 -105
- data/lib/chef/provider/package/pacman.rb +0 -101
- data/lib/chef/provider/package/portage.rb +0 -135
- data/lib/chef/provider/package/rpm.rb +0 -104
- data/lib/chef/provider/package/rubygems.rb +0 -465
- data/lib/chef/provider/package/solaris.rb +0 -130
- data/lib/chef/provider/package/yum.rb +0 -1128
- data/lib/chef/provider/package/zypper.rb +0 -144
- data/lib/chef/provider/route.rb +0 -193
- data/lib/chef/provider/ruby_block.rb +0 -34
- data/lib/chef/provider/script.rb +0 -55
- data/lib/chef/provider/service.rb +0 -122
- data/lib/chef/provider/service/arch.rb +0 -116
- data/lib/chef/provider/service/debian.rb +0 -130
- data/lib/chef/provider/service/freebsd.rb +0 -154
- data/lib/chef/provider/service/gentoo.rb +0 -53
- data/lib/chef/provider/service/init.rb +0 -71
- data/lib/chef/provider/service/insserv.rb +0 -52
- data/lib/chef/provider/service/redhat.rb +0 -60
- data/lib/chef/provider/service/simple.rb +0 -120
- data/lib/chef/provider/service/solaris.rb +0 -85
- data/lib/chef/provider/service/systemd.rb +0 -102
- data/lib/chef/provider/service/upstart.rb +0 -198
- data/lib/chef/provider/service/windows.rb +0 -146
- data/lib/chef/provider/subversion.rb +0 -197
- data/lib/chef/provider/user.rb +0 -186
- data/lib/chef/provider/user/dscl.rb +0 -280
- data/lib/chef/provider/user/pw.rb +0 -113
- data/lib/chef/provider/user/useradd.rb +0 -137
- data/lib/chef/provider/user/windows.rb +0 -124
- data/lib/chef/resource/apt_package.rb +0 -34
- data/lib/chef/resource/bash.rb +0 -33
- data/lib/chef/resource/breakpoint.rb +0 -35
- data/lib/chef/resource/cron.rb +0 -188
- data/lib/chef/resource/csh.rb +0 -33
- data/lib/chef/resource/deploy.rb +0 -380
- data/lib/chef/resource/deploy_revision.rb +0 -40
- data/lib/chef/resource/dpkg_package.rb +0 -34
- data/lib/chef/resource/easy_install_package.rb +0 -57
- data/lib/chef/resource/erl_call.rb +0 -83
- data/lib/chef/resource/freebsd_package.rb +0 -35
- data/lib/chef/resource/gem_package.rb +0 -53
- data/lib/chef/resource/git.rb +0 -46
- data/lib/chef/resource/group.rb +0 -70
- data/lib/chef/resource/ifconfig.rb +0 -134
- data/lib/chef/resource/log.rb +0 -62
- data/lib/chef/resource/macports_package.rb +0 -29
- data/lib/chef/resource/mdadm.rb +0 -82
- data/lib/chef/resource/mount.rb +0 -134
- data/lib/chef/resource/ohai.rb +0 -40
- data/lib/chef/resource/package.rb +0 -80
- data/lib/chef/resource/pacman_package.rb +0 -33
- data/lib/chef/resource/perl.rb +0 -33
- data/lib/chef/resource/portage_package.rb +0 -33
- data/lib/chef/resource/python.rb +0 -33
- data/lib/chef/resource/route.rb +0 -135
- data/lib/chef/resource/rpm_package.rb +0 -34
- data/lib/chef/resource/ruby.rb +0 -33
- data/lib/chef/resource/ruby_block.rb +0 -40
- data/lib/chef/resource/scm.rb +0 -147
- data/lib/chef/resource/script.rb +0 -60
- data/lib/chef/resource/service.rb +0 -160
- data/lib/chef/resource/solaris_package.rb +0 -36
- data/lib/chef/resource/subversion.rb +0 -36
- data/lib/chef/resource/timestamped_deploy.rb +0 -31
- data/lib/chef/resource/user.rb +0 -130
- data/lib/chef/resource/yum_package.rb +0 -63
data/lib/chef/provider/group.rb
DELETED
@@ -1,133 +0,0 @@
|
|
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'
|
20
|
-
require 'chef/mixin/command'
|
21
|
-
require 'chef/resource/group'
|
22
|
-
require 'etc'
|
23
|
-
|
24
|
-
class Chef
|
25
|
-
class Provider
|
26
|
-
class Group < Chef::Provider
|
27
|
-
include Chef::Mixin::Command
|
28
|
-
attr_accessor :group_exists
|
29
|
-
|
30
|
-
def initialize(new_resource, run_context)
|
31
|
-
super
|
32
|
-
@group_exists = true
|
33
|
-
end
|
34
|
-
|
35
|
-
def load_current_resource
|
36
|
-
@current_resource = Chef::Resource::Group.new(@new_resource.name)
|
37
|
-
@current_resource.group_name(@new_resource.group_name)
|
38
|
-
|
39
|
-
group_info = nil
|
40
|
-
begin
|
41
|
-
group_info = Etc.getgrnam(@new_resource.group_name)
|
42
|
-
rescue ArgumentError => e
|
43
|
-
@group_exists = false
|
44
|
-
Chef::Log.debug("#{@new_resource} group does not exist")
|
45
|
-
end
|
46
|
-
|
47
|
-
if group_info
|
48
|
-
@new_resource.gid(group_info.gid) unless @new_resource.gid
|
49
|
-
@current_resource.gid(group_info.gid)
|
50
|
-
@current_resource.members(group_info.mem)
|
51
|
-
end
|
52
|
-
|
53
|
-
@current_resource
|
54
|
-
end
|
55
|
-
|
56
|
-
# Check to see if a group needs any changes
|
57
|
-
#
|
58
|
-
# ==== Returns
|
59
|
-
# <true>:: If a change is required
|
60
|
-
# <false>:: If a change is not required
|
61
|
-
def compare_group
|
62
|
-
return true if @new_resource.gid != @current_resource.gid
|
63
|
-
|
64
|
-
if(@new_resource.append)
|
65
|
-
@new_resource.members.each do |member|
|
66
|
-
next if @current_resource.members.include?(member)
|
67
|
-
return true
|
68
|
-
end
|
69
|
-
else
|
70
|
-
return true if @new_resource.members != @current_resource.members
|
71
|
-
end
|
72
|
-
|
73
|
-
return false
|
74
|
-
end
|
75
|
-
|
76
|
-
def action_create
|
77
|
-
case @group_exists
|
78
|
-
when false
|
79
|
-
$testrun || create_group
|
80
|
-
Chef::Log.info("#{@new_resource} created")
|
81
|
-
@new_resource.updated_by_last_action(true)
|
82
|
-
else
|
83
|
-
if compare_group
|
84
|
-
$testrun || manage_group
|
85
|
-
Chef::Log.info("#{@new_resource} altered")
|
86
|
-
@new_resource.updated_by_last_action(true)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def action_remove
|
92
|
-
if @group_exists
|
93
|
-
$testrun || remove_group
|
94
|
-
@new_resource.updated_by_last_action(true)
|
95
|
-
Chef::Log.info("#{@new_resource} removed")
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def action_manage
|
100
|
-
if @group_exists && compare_group
|
101
|
-
$testrun || manage_group
|
102
|
-
@new_resource.updated_by_last_action(true)
|
103
|
-
Chef::Log.info("#{@new_resource} managed")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def action_modify
|
108
|
-
if @group_exists
|
109
|
-
if compare_group
|
110
|
-
$testrun || manage_group
|
111
|
-
@new_resource.updated_by_last_action(true)
|
112
|
-
Chef::Log.info("#{@new_resource} modified")
|
113
|
-
end
|
114
|
-
else
|
115
|
-
raise Chef::Exceptions::Group, "Cannot modify #{@new_resource} - group does not exist!"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def create_group
|
120
|
-
raise NotImplementedError, "subclasses of Chef::Provider::Group should define #create_group"
|
121
|
-
end
|
122
|
-
|
123
|
-
def manage_group
|
124
|
-
raise NotImplementedError, "subclasses of Chef::Provider::Group should define #manage_group"
|
125
|
-
end
|
126
|
-
|
127
|
-
def remove_group
|
128
|
-
raise NotImplementedError, "subclasses of Chef::Provider::Group should define #remove_group"
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Doug MacEachern (<dougm@vmware.com>)
|
3
|
-
# Copyright:: Copyright (c) 2010 VMware, 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/usermod'
|
20
|
-
|
21
|
-
class Chef
|
22
|
-
class Provider
|
23
|
-
class Group
|
24
|
-
class Aix < Chef::Provider::Group::Usermod
|
25
|
-
|
26
|
-
def required_binaries
|
27
|
-
[ "/usr/bin/mkgroup",
|
28
|
-
"/usr/bin/chgroup",
|
29
|
-
"/usr/sbin/rmgroup" ]
|
30
|
-
end
|
31
|
-
|
32
|
-
def create_group
|
33
|
-
command = "mkgroup"
|
34
|
-
command << set_options << " #{@new_resource.group_name}"
|
35
|
-
run_command(:command => command)
|
36
|
-
modify_group_members
|
37
|
-
end
|
38
|
-
|
39
|
-
def manage_group
|
40
|
-
command = "chgroup"
|
41
|
-
options = set_options
|
42
|
-
#Usage: chgroup [-R load_module] "attr=value" ... group
|
43
|
-
if options.size > 0
|
44
|
-
command << options << " #{@new_resource.group_name}"
|
45
|
-
run_command(:command => command)
|
46
|
-
end
|
47
|
-
modify_group_members
|
48
|
-
end
|
49
|
-
|
50
|
-
def remove_group
|
51
|
-
run_command(:command => "rmgroup #{@new_resource.group_name}")
|
52
|
-
end
|
53
|
-
|
54
|
-
def set_options
|
55
|
-
opts = ""
|
56
|
-
{ :gid => "id" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
|
57
|
-
if @current_resource.send(field) != @new_resource.send(field)
|
58
|
-
if @new_resource.send(field)
|
59
|
-
Chef::Log.debug("#{@new_resource} setting #{field.to_s} to #{@new_resource.send(field)}")
|
60
|
-
opts << " '#{option}=#{@new_resource.send(field)}'"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
opts
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Dreamcat4 (<dreamcat4@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2009 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
|
-
class Chef
|
20
|
-
class Provider
|
21
|
-
class Group
|
22
|
-
class Dscl < Chef::Provider::Group
|
23
|
-
|
24
|
-
def dscl(*args)
|
25
|
-
host = "."
|
26
|
-
stdout_result = ""; stderr_result = ""; cmd = "dscl #{host} -#{args.join(' ')}"
|
27
|
-
status = popen4(cmd) do |pid, stdin, stdout, stderr|
|
28
|
-
stdout.each { |line| stdout_result << line }
|
29
|
-
stderr.each { |line| stderr_result << line }
|
30
|
-
end
|
31
|
-
return [cmd, status, stdout_result, stderr_result]
|
32
|
-
end
|
33
|
-
|
34
|
-
def safe_dscl(*args)
|
35
|
-
result = dscl(*args)
|
36
|
-
return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 )
|
37
|
-
raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") unless result[1].exitstatus == 0
|
38
|
-
raise(Chef::Exceptions::Group,"dscl error: #{result.inspect}") if result[2] =~ /No such key: /
|
39
|
-
return result[2]
|
40
|
-
end
|
41
|
-
|
42
|
-
# This is handled in providers/group.rb by Etc.getgrnam()
|
43
|
-
# def group_exists?(group)
|
44
|
-
# groups = safe_dscl("list /Groups")
|
45
|
-
# !! ( groups =~ Regexp.new("\n#{group}\n") )
|
46
|
-
# end
|
47
|
-
|
48
|
-
# get a free GID greater than 200
|
49
|
-
def get_free_gid(search_limit=1000)
|
50
|
-
gid = nil; next_gid_guess = 200
|
51
|
-
groups_gids = safe_dscl("list /Groups gid")
|
52
|
-
while(next_gid_guess < search_limit + 200)
|
53
|
-
if groups_gids =~ Regexp.new("#{Regexp.escape(next_gid_guess.to_s)}\n")
|
54
|
-
next_gid_guess += 1
|
55
|
-
else
|
56
|
-
gid = next_gid_guess
|
57
|
-
break
|
58
|
-
end
|
59
|
-
end
|
60
|
-
return gid || raise("gid not found. Exhausted. Searched #{search_limit} times")
|
61
|
-
end
|
62
|
-
|
63
|
-
def gid_used?(gid)
|
64
|
-
return false unless gid
|
65
|
-
groups_gids = safe_dscl("list /Groups gid")
|
66
|
-
!! ( groups_gids =~ Regexp.new("#{Regexp.escape(gid.to_s)}\n") )
|
67
|
-
end
|
68
|
-
|
69
|
-
def set_gid
|
70
|
-
@new_resource.gid(get_free_gid) if [nil,""].include? @new_resource.gid
|
71
|
-
raise(Chef::Exceptions::Group,"gid is already in use") if gid_used?(@new_resource.gid)
|
72
|
-
safe_dscl("create /Groups/#{@new_resource.group_name} PrimaryGroupID #{@new_resource.gid}")
|
73
|
-
end
|
74
|
-
|
75
|
-
def set_members
|
76
|
-
unless @new_resource.append
|
77
|
-
Chef::Log.debug("#{@new_resource} removing group members #{@current_resource.members.join(' ')}") unless @current_resource.members.empty?
|
78
|
-
safe_dscl("create /Groups/#{@new_resource.group_name} GroupMembers ''") # clear guid list
|
79
|
-
safe_dscl("create /Groups/#{@new_resource.group_name} GroupMembership ''") # clear user list
|
80
|
-
end
|
81
|
-
unless @new_resource.members.empty?
|
82
|
-
Chef::Log.debug("#{@new_resource} setting group members #{@new_resource.members.join(', ')}")
|
83
|
-
safe_dscl("append /Groups/#{@new_resource.group_name} GroupMembership #{@new_resource.members.join(' ')}")
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def load_current_resource
|
88
|
-
super
|
89
|
-
raise Chef::Exceptions::Group, "Could not find binary /usr/bin/dscl for #{@new_resource}" unless ::File.exists?("/usr/bin/dscl")
|
90
|
-
end
|
91
|
-
|
92
|
-
def create_group
|
93
|
-
dscl_create_group
|
94
|
-
set_gid
|
95
|
-
set_members
|
96
|
-
end
|
97
|
-
|
98
|
-
def manage_group
|
99
|
-
if @new_resource.group_name && (@current_resource.group_name != @new_resource.group_name)
|
100
|
-
dscl_create_group
|
101
|
-
end
|
102
|
-
if @new_resource.gid && (@current_resource.gid != @new_resource.gid)
|
103
|
-
set_gid
|
104
|
-
end
|
105
|
-
if @new_resource.members && (@current_resource.members != @new_resource.members)
|
106
|
-
set_members
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def dscl_create_group
|
111
|
-
safe_dscl("create /Groups/#{@new_resource.group_name}")
|
112
|
-
safe_dscl("create /Groups/#{@new_resource.group_name} Password '*'")
|
113
|
-
end
|
114
|
-
|
115
|
-
def remove_group
|
116
|
-
safe_dscl("delete /Groups/#{@new_resource.group_name}")
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,53 +0,0 @@
|
|
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
|
-
require 'chef/mixin/shell_out'
|
21
|
-
|
22
|
-
class Chef
|
23
|
-
class Provider
|
24
|
-
class Group
|
25
|
-
class Gpasswd < Chef::Provider::Group::Groupadd
|
26
|
-
|
27
|
-
include Chef::Mixin::ShellOut
|
28
|
-
|
29
|
-
def load_current_resource
|
30
|
-
super
|
31
|
-
|
32
|
-
raise Chef::Exceptions::Group, "Could not find binary /usr/bin/gpasswd for #{@new_resource}" unless ::File.exists?("/usr/bin/gpasswd")
|
33
|
-
end
|
34
|
-
|
35
|
-
def modify_group_members
|
36
|
-
unless @new_resource.members.empty?
|
37
|
-
if(@new_resource.append)
|
38
|
-
@new_resource.members.each do |member|
|
39
|
-
Chef::Log.debug("#{@new_resource} appending member #{member} to group #{@new_resource.group_name}")
|
40
|
-
shell_out!("gpasswd -a #{member} #{@new_resource.group_name}")
|
41
|
-
end
|
42
|
-
else
|
43
|
-
Chef::Log.debug("#{@new_resource} setting group members to #{@new_resource.members.join(', ')}")
|
44
|
-
shell_out!("gpasswd -M #{@new_resource.members.join(',')} #{@new_resource.group_name}")
|
45
|
-
end
|
46
|
-
else
|
47
|
-
Chef::Log.debug("#{@new_resource} not changing group members, the group has no members")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,81 +0,0 @@
|
|
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
|
-
class Chef
|
20
|
-
class Provider
|
21
|
-
class Group
|
22
|
-
class Groupadd < Chef::Provider::Group
|
23
|
-
|
24
|
-
def required_binaries
|
25
|
-
[ "/usr/sbin/groupadd",
|
26
|
-
"/usr/sbin/groupmod",
|
27
|
-
"/usr/sbin/groupdel" ]
|
28
|
-
end
|
29
|
-
|
30
|
-
def load_current_resource
|
31
|
-
super
|
32
|
-
required_binaries.each do |required_binary|
|
33
|
-
raise Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{@new_resource}" unless ::File.exists?(required_binary)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Create the group
|
38
|
-
def create_group
|
39
|
-
command = "#{$testrun_command}groupadd"
|
40
|
-
command << set_options
|
41
|
-
run_command(:command => command)
|
42
|
-
$testrun || modify_group_members
|
43
|
-
end
|
44
|
-
|
45
|
-
# Manage the group when it already exists
|
46
|
-
def manage_group
|
47
|
-
command = "#{$testrun_command}groupmod"
|
48
|
-
command << set_options
|
49
|
-
run_command(:command => command)
|
50
|
-
$testrun || modify_group_members
|
51
|
-
end
|
52
|
-
|
53
|
-
# Remove the group
|
54
|
-
def remove_group
|
55
|
-
run_command(:command => "groupdel #{@new_resource.group_name}")
|
56
|
-
end
|
57
|
-
|
58
|
-
def modify_group_members
|
59
|
-
raise Chef::Exceptions::Group, "you must override modify_group_members in #{self.to_s}"
|
60
|
-
end
|
61
|
-
# Little bit of magic as per Adam's useradd provider to pull the assign the command line flags
|
62
|
-
#
|
63
|
-
# ==== Returns
|
64
|
-
# <string>:: A string containing the option and then the quoted value
|
65
|
-
def set_options
|
66
|
-
opts = ""
|
67
|
-
{ :gid => "-g" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
|
68
|
-
if @current_resource.send(field) != @new_resource.send(field)
|
69
|
-
if @new_resource.send(field)
|
70
|
-
opts << " #{option} '#{@new_resource.send(field)}'"
|
71
|
-
Chef::Log.debug("#{@new_resource} set #{field.to_s} to #{@new_resource.send(field)}")
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
opts << " #{@new_resource.group_name}"
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|