chef 12.17.44-universal-mingw32 → 12.18.31-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +3 -2
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +17 -17
- data/distro/common/html/knife_environment.html +4 -8
- data/distro/common/man/man1/knife-environment.1 +4 -16
- data/distro/powershell/chef/chef.psm1 +139 -24
- data/lib/chef/application.rb +5 -4
- data/lib/chef/application/windows_service_manager.rb +6 -4
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/data_collector.rb +24 -13
- data/lib/chef/data_collector/messages.rb +8 -6
- data/lib/chef/data_collector/messages/helpers.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/platform_introspection.rb +2 -2
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +5 -5
- data/lib/chef/file_access_control/unix.rb +5 -5
- data/lib/chef/formatters/error_description.rb +1 -1
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/json_input.rb +2 -2
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/mixin/command.rb +1 -0
- data/lib/chef/mixin/deep_merge.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +58 -3
- data/lib/chef/mixin/which.rb +5 -9
- data/lib/chef/mixin/wide_string.rb +1 -1
- data/lib/chef/node.rb +1 -1
- data/lib/chef/node/attribute.rb +4 -5
- data/lib/chef/node_map.rb +18 -2
- data/lib/chef/platform/provider_handler_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -0
- data/lib/chef/platform/resource_handler_map.rb +2 -2
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/group.rb +41 -46
- data/lib/chef/provider/group/aix.rb +12 -19
- data/lib/chef/provider/group/dscl.rb +46 -43
- data/lib/chef/provider/group/gpasswd.rb +7 -7
- data/lib/chef/provider/group/groupadd.rb +29 -34
- data/lib/chef/provider/group/groupmod.rb +26 -31
- data/lib/chef/provider/group/pw.rb +28 -31
- data/lib/chef/provider/group/suse.rb +9 -9
- data/lib/chef/provider/group/usermod.rb +10 -11
- data/lib/chef/provider/group/windows.rb +18 -20
- data/lib/chef/provider/ifconfig.rb +52 -63
- data/lib/chef/provider/ifconfig/aix.rb +23 -28
- data/lib/chef/provider/ifconfig/debian.rb +23 -22
- data/lib/chef/provider/ifconfig/redhat.rb +12 -12
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +4 -2
- data/lib/chef/provider/package.rb +16 -7
- data/lib/chef/provider/package/chocolatey.rb +3 -1
- data/lib/chef/provider/package/dnf.rb +183 -0
- data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
- data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
- data/lib/chef/provider/package/dnf/version.rb +56 -0
- data/lib/chef/provider/package/easy_install.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +3 -3
- data/lib/chef/provider/package/windows.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/route.rb +186 -184
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/support/yum_repo.erb +10 -3
- data/lib/chef/provider/user.rb +17 -20
- data/lib/chef/provider/user/aix.rb +23 -24
- data/lib/chef/provider/user/dscl.rb +56 -53
- data/lib/chef/provider/user/linux.rb +13 -16
- data/lib/chef/provider/user/pw.rb +26 -30
- data/lib/chef/provider/user/solaris.rb +11 -12
- data/lib/chef/provider/user/useradd.rb +20 -22
- data/lib/chef/provider/user/windows.rb +19 -22
- data/lib/chef/provider_resolver.rb +4 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +7 -0
- data/lib/chef/resource/chocolatey_package.rb +1 -0
- data/lib/chef/resource/dnf_package.rb +64 -0
- data/lib/chef/resource/file/verification.rb +6 -4
- data/lib/chef/resource/yum_package.rb +18 -14
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_reporter.rb +11 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/scan_access_control.rb +4 -4
- data/lib/chef/util/dsc/resource_store.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/memory.rb +1 -1
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/sid.rb +2 -2
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
- data/spec/functional/resource/dnf_package_spec.rb +686 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/user/useradd_spec.rb +10 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
- data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
- data/spec/integration/recipes/resource_load_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -3
- data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
- data/spec/support/lib/chef/resource/cat.rb +1 -0
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
- data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
- data/spec/support/lib/chef/resource/with_state.rb +2 -0
- data/spec/support/lib/chef/resource/zen_master.rb +1 -0
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
- data/spec/unit/data_collector_spec.rb +56 -0
- data/spec/unit/decorator/lazy_spec.rb +1 -1
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +3 -4
- data/spec/unit/node_spec.rb +23 -2
- data/spec/unit/platform_spec.rb +1 -0
- data/spec/unit/provider/group/dscl_spec.rb +29 -29
- data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
- data/spec/unit/provider/group/groupadd_spec.rb +31 -30
- data/spec/unit/provider/group/groupmod_spec.rb +16 -16
- data/spec/unit/provider/group/pw_spec.rb +11 -11
- data/spec/unit/provider/group/suse_spec.rb +5 -5
- data/spec/unit/provider/group/usermod_spec.rb +15 -15
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
- data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
- data/spec/unit/provider/ifconfig_spec.rb +18 -19
- data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
- data/spec/unit/provider/package/msu_spec.rb +1 -1
- data/spec/unit/provider/route_spec.rb +21 -21
- data/spec/unit/provider/user/dscl_spec.rb +54 -57
- data/spec/unit/provider/user/linux_spec.rb +5 -5
- data/spec/unit/provider/user/pw_spec.rb +26 -22
- data/spec/unit/provider/user/windows_spec.rb +4 -4
- data/spec/unit/provider/user_spec.rb +19 -21
- data/spec/unit/provider_resolver_spec.rb +1 -0
- data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
- data/spec/unit/resource/dnf_package_spec.rb +99 -0
- data/spec/unit/resource/remote_file_spec.rb +2 -2
- data/spec/unit/resource/yum_package_spec.rb +20 -0
- data/spec/unit/resource_reporter_spec.rb +24 -0
- data/spec/unit/resource_spec.rb +2 -0
- data/spec/unit/runner_spec.rb +1 -0
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/gemfile_util.rb +2 -2
- data/tasks/templates/prerelease.md.erb +1 -10
- data/tasks/templates/release.md.erb +1 -9
- metadata +24 -5
- data/lib/chef/platform/handler_map.rb +0 -40
@@ -30,46 +30,42 @@ class Chef
|
|
30
30
|
super
|
31
31
|
|
32
32
|
requirements.assert(:all_actions) do |a|
|
33
|
-
a.assertion { ::File.
|
34
|
-
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/pw for #{
|
33
|
+
a.assertion { ::File.exist?("/usr/sbin/pw") }
|
34
|
+
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/pw for #{new_resource}"
|
35
35
|
# No whyrun alternative: this component should be available in the base install of any given system that uses it
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
# Create the group
|
40
40
|
def create_group
|
41
|
-
command = "pw groupadd"
|
42
|
-
|
43
|
-
|
44
|
-
unless @new_resource.members.empty?
|
41
|
+
command = [ "pw", "groupadd", set_options ]
|
42
|
+
unless new_resource.members.empty?
|
45
43
|
# pw group[add|mod] -M is used to set the full membership list on a
|
46
44
|
# new or existing group. Because pw groupadd does not support the -m
|
47
45
|
# and -d options used by manage_group, we treat group creation as a
|
48
46
|
# special case and use -M.
|
49
|
-
Chef::Log.debug("#{
|
50
|
-
command += "
|
47
|
+
Chef::Log.debug("#{new_resource} setting group members: #{new_resource.members.join(',')}")
|
48
|
+
command += [ "-M", new_resource.members.join(",") ]
|
51
49
|
end
|
52
50
|
|
53
|
-
|
51
|
+
shell_out_compact!(command)
|
54
52
|
end
|
55
53
|
|
56
54
|
# Manage the group when it already exists
|
57
55
|
def manage_group
|
58
|
-
command = "pw groupmod"
|
59
|
-
command << set_options
|
60
56
|
member_options = set_members_options
|
61
57
|
if member_options.empty?
|
62
|
-
|
58
|
+
shell_out_compact!("pw", "groupmod", set_options)
|
63
59
|
else
|
64
60
|
member_options.each do |option|
|
65
|
-
|
61
|
+
shell_out_compact!("pw", "groupmod", set_options, option)
|
66
62
|
end
|
67
63
|
end
|
68
64
|
end
|
69
65
|
|
70
66
|
# Remove the group
|
71
67
|
def remove_group
|
72
|
-
|
68
|
+
shell_out_compact!("pw", "groupdel", new_resource.group_name)
|
73
69
|
end
|
74
70
|
|
75
71
|
# Little bit of magic as per Adam's useradd provider to pull and assign the command line flags
|
@@ -77,10 +73,11 @@ class Chef
|
|
77
73
|
# ==== Returns
|
78
74
|
# <string>:: A string containing the option and then the quoted value
|
79
75
|
def set_options
|
80
|
-
opts =
|
81
|
-
if
|
82
|
-
Chef::Log.debug("#{
|
83
|
-
opts << "
|
76
|
+
opts = [ new_resource.group_name ]
|
77
|
+
if new_resource.gid && (current_resource.gid != new_resource.gid)
|
78
|
+
Chef::Log.debug("#{new_resource}: current gid (#{current_resource.gid}) doesnt match target gid (#{new_resource.gid}), changing it")
|
79
|
+
opts << "-g"
|
80
|
+
opts << new_resource.gid
|
84
81
|
end
|
85
82
|
opts
|
86
83
|
end
|
@@ -91,26 +88,26 @@ class Chef
|
|
91
88
|
members_to_be_added = [ ]
|
92
89
|
members_to_be_removed = [ ]
|
93
90
|
|
94
|
-
if
|
91
|
+
if new_resource.append
|
95
92
|
# Append is set so we will only add members given in the
|
96
93
|
# members list and remove members given in the
|
97
94
|
# excluded_members list.
|
98
|
-
if
|
99
|
-
|
100
|
-
members_to_be_added << member
|
95
|
+
if new_resource.members && !new_resource.members.empty?
|
96
|
+
new_resource.members.each do |member|
|
97
|
+
members_to_be_added << member unless current_resource.members.include?(member)
|
101
98
|
end
|
102
99
|
end
|
103
100
|
|
104
|
-
if
|
105
|
-
|
106
|
-
members_to_be_removed << member if
|
101
|
+
if new_resource.excluded_members && !new_resource.excluded_members.empty?
|
102
|
+
new_resource.excluded_members.each do |member|
|
103
|
+
members_to_be_removed << member if current_resource.members.include?(member)
|
107
104
|
end
|
108
105
|
end
|
109
106
|
else
|
110
107
|
# Append is not set so we're resetting the membership of
|
111
108
|
# the group to the given members.
|
112
|
-
members_to_be_added =
|
113
|
-
|
109
|
+
members_to_be_added = new_resource.members.dup
|
110
|
+
current_resource.members.each do |member|
|
114
111
|
# No need to re-add a member if it's present in the new
|
115
112
|
# list of members
|
116
113
|
if members_to_be_added.include? member
|
@@ -122,13 +119,13 @@ class Chef
|
|
122
119
|
end
|
123
120
|
|
124
121
|
unless members_to_be_added.empty?
|
125
|
-
Chef::Log.debug("#{
|
126
|
-
opts << "
|
122
|
+
Chef::Log.debug("#{new_resource} adding group members: #{members_to_be_added.join(',')}")
|
123
|
+
opts << [ "-m", members_to_be_added.join(",") ]
|
127
124
|
end
|
128
125
|
|
129
126
|
unless members_to_be_removed.empty?
|
130
|
-
Chef::Log.debug("#{
|
131
|
-
opts << "
|
127
|
+
Chef::Log.debug("#{new_resource} removing group members: #{members_to_be_removed.join(',')}")
|
128
|
+
opts << [ "-d", members_to_be_removed.join(",") ]
|
132
129
|
end
|
133
130
|
|
134
131
|
opts
|
@@ -33,21 +33,21 @@ class Chef
|
|
33
33
|
def define_resource_requirements
|
34
34
|
super
|
35
35
|
requirements.assert(:all_actions) do |a|
|
36
|
-
a.assertion { ::File.
|
37
|
-
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/groupmod for #{
|
36
|
+
a.assertion { ::File.exist?("/usr/sbin/groupmod") }
|
37
|
+
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/groupmod for #{new_resource.name}"
|
38
38
|
# No whyrun alternative: this component should be available in the base install of any given system that uses it
|
39
39
|
end
|
40
40
|
|
41
41
|
requirements.assert(:create, :manage, :modify) do |a|
|
42
42
|
a.assertion do
|
43
43
|
begin
|
44
|
-
to_add(
|
44
|
+
to_add(new_resource.members).all? { |member| Etc.getpwnam(member) }
|
45
45
|
rescue
|
46
46
|
false
|
47
47
|
end
|
48
48
|
end
|
49
|
-
a.failure_message Chef::Exceptions::Group, "Could not add users #{to_add(
|
50
|
-
a.whyrun "Could not find one of these users: #{to_add(
|
49
|
+
a.failure_message Chef::Exceptions::Group, "Could not add users #{to_add(new_resource.members).join(', ')} to #{new_resource.group_name}: one of these users does not exist"
|
50
|
+
a.whyrun "Could not find one of these users: #{to_add(new_resource.members).join(', ')}. Assuming it will be created by a prior step"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -62,19 +62,19 @@ class Chef
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def to_add(members)
|
65
|
-
members -
|
65
|
+
members - current_resource.members
|
66
66
|
end
|
67
67
|
|
68
68
|
def add_member(member)
|
69
|
-
|
69
|
+
shell_out_compact!("groupmod", "-A", member, new_resource.group_name)
|
70
70
|
end
|
71
71
|
|
72
72
|
def to_remove(members)
|
73
|
-
|
73
|
+
current_resource.members - members
|
74
74
|
end
|
75
75
|
|
76
76
|
def remove_member(member)
|
77
|
-
|
77
|
+
shell_out_compact!("groupmod", "-R", member, new_resource.group_name)
|
78
78
|
end
|
79
79
|
|
80
80
|
end
|
@@ -34,19 +34,19 @@ class Chef
|
|
34
34
|
super
|
35
35
|
|
36
36
|
requirements.assert(:all_actions) do |a|
|
37
|
-
a.assertion { ::File.
|
38
|
-
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod for #{
|
37
|
+
a.assertion { ::File.exist?("/usr/sbin/usermod") }
|
38
|
+
a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/usermod for #{new_resource}"
|
39
39
|
# No whyrun alternative: this component should be available in the base install of any given system that uses it
|
40
40
|
end
|
41
41
|
|
42
42
|
requirements.assert(:modify, :manage) do |a|
|
43
|
-
a.assertion {
|
43
|
+
a.assertion { new_resource.members.empty? || new_resource.append }
|
44
44
|
a.failure_message Chef::Exceptions::Group, "setting group members directly is not supported by #{self}, must set append true in group"
|
45
45
|
# No whyrun alternative - this action is simply not supported.
|
46
46
|
end
|
47
47
|
|
48
48
|
requirements.assert(:all_actions) do |a|
|
49
|
-
a.assertion {
|
49
|
+
a.assertion { new_resource.excluded_members.empty? }
|
50
50
|
a.failure_message Chef::Exceptions::Group, "excluded_members is not supported by #{self}"
|
51
51
|
# No whyrun alternative - this action is simply not supported.
|
52
52
|
end
|
@@ -57,17 +57,16 @@ class Chef
|
|
57
57
|
# This provider only supports adding members with
|
58
58
|
# append. Only if the action is create we will go
|
59
59
|
# ahead and add members.
|
60
|
-
|
61
|
-
members.each do |member|
|
62
|
-
add_member(member)
|
63
|
-
end
|
64
|
-
else
|
60
|
+
unless new_resource.action.include?(:create)
|
65
61
|
raise Chef::Exceptions::UnsupportedAction, "Setting members directly is not supported by #{self}"
|
66
62
|
end
|
63
|
+
members.each do |member|
|
64
|
+
add_member(member)
|
65
|
+
end
|
67
66
|
end
|
68
67
|
|
69
68
|
def add_member(member)
|
70
|
-
|
69
|
+
shell_out_compact!("usermod", append_flags, new_resource.group_name, member)
|
71
70
|
end
|
72
71
|
|
73
72
|
def remove_member(member)
|
@@ -81,7 +80,7 @@ class Chef
|
|
81
80
|
when "openbsd", "netbsd", "aix", "solaris2", "smartos", "omnios"
|
82
81
|
"-G"
|
83
82
|
when "solaris", "suse", "opensuse"
|
84
|
-
"-a -G"
|
83
|
+
[ "-a", "-G" ]
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
@@ -30,26 +30,26 @@ class Chef
|
|
30
30
|
|
31
31
|
def initialize(new_resource, run_context)
|
32
32
|
super
|
33
|
-
@net_group = Chef::Util::Windows::NetGroup.new(
|
33
|
+
@net_group = Chef::Util::Windows::NetGroup.new(new_resource.group_name)
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_current_resource
|
37
|
-
@current_resource = Chef::Resource::Group.new(
|
38
|
-
|
37
|
+
@current_resource = Chef::Resource::Group.new(new_resource.name)
|
38
|
+
current_resource.group_name(new_resource.group_name)
|
39
39
|
|
40
40
|
members = nil
|
41
41
|
begin
|
42
42
|
members = @net_group.local_get_members
|
43
|
-
rescue
|
43
|
+
rescue
|
44
44
|
@group_exists = false
|
45
|
-
Chef::Log.debug("#{
|
45
|
+
Chef::Log.debug("#{new_resource} group does not exist")
|
46
46
|
end
|
47
47
|
|
48
48
|
if members
|
49
|
-
|
49
|
+
current_resource.members(members)
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
current_resource
|
53
53
|
end
|
54
54
|
|
55
55
|
def create_group
|
@@ -58,10 +58,10 @@ class Chef
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def manage_group
|
61
|
-
if
|
61
|
+
if new_resource.append
|
62
62
|
members_to_be_added = [ ]
|
63
|
-
|
64
|
-
members_to_be_added << member if !
|
63
|
+
new_resource.members.each do |member|
|
64
|
+
members_to_be_added << member if !has_current_group_member?(member) && validate_member!(member)
|
65
65
|
end
|
66
66
|
|
67
67
|
# local_add_members will raise ERROR_MEMBER_IN_ALIAS if a
|
@@ -69,19 +69,19 @@ class Chef
|
|
69
69
|
@net_group.local_add_members(members_to_be_added) unless members_to_be_added.empty?
|
70
70
|
|
71
71
|
members_to_be_removed = [ ]
|
72
|
-
|
73
|
-
|
72
|
+
new_resource.excluded_members.each do |member|
|
73
|
+
lookup_account_name(member)
|
74
74
|
members_to_be_removed << member if has_current_group_member?(member)
|
75
75
|
end
|
76
76
|
@net_group.local_delete_members(members_to_be_removed) unless members_to_be_removed.empty?
|
77
77
|
else
|
78
|
-
@net_group.local_set_members(
|
78
|
+
@net_group.local_set_members(new_resource.members)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
def has_current_group_member?(member)
|
83
83
|
member_sid = lookup_account_name(member)
|
84
|
-
|
84
|
+
current_resource.members.include?(member_sid)
|
85
85
|
end
|
86
86
|
|
87
87
|
def remove_group
|
@@ -97,12 +97,10 @@ class Chef
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def lookup_account_name(account_name)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
""
|
105
|
-
end
|
100
|
+
Chef::ReservedNames::Win32::Security.lookup_account_name(locally_qualified_name(account_name))[1].to_s
|
101
|
+
rescue Chef::Exceptions::Win32APIError
|
102
|
+
Chef::Log.warn("SID for '#{locally_qualified_name(account_name)}' could not be found")
|
103
|
+
""
|
106
104
|
end
|
107
105
|
|
108
106
|
end
|
@@ -58,7 +58,7 @@ class Chef
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def load_current_resource
|
61
|
-
@current_resource = Chef::Resource::Ifconfig.new(
|
61
|
+
@current_resource = Chef::Resource::Ifconfig.new(new_resource.name)
|
62
62
|
|
63
63
|
@ifconfig_success = true
|
64
64
|
@interfaces = {}
|
@@ -69,27 +69,26 @@ class Chef
|
|
69
69
|
@int_name = line[0..9].strip
|
70
70
|
@interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp }
|
71
71
|
else
|
72
|
-
@interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? (
|
73
|
-
@interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? (
|
74
|
-
@interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? (
|
75
|
-
@interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? (
|
76
|
-
@interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? (
|
72
|
+
@interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet addr:/
|
73
|
+
@interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Bcast:/
|
74
|
+
@interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Mask:/
|
75
|
+
@interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/
|
76
|
+
@interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
79
|
+
next unless @interfaces.key?(new_resource.device)
|
80
|
+
@interface = @interfaces.fetch(new_resource.device)
|
81
|
+
|
82
|
+
current_resource.target(new_resource.target)
|
83
|
+
current_resource.device(new_resource.device)
|
84
|
+
current_resource.inet_addr(@interface["inet_addr"])
|
85
|
+
current_resource.hwaddr(@interface["hwaddr"])
|
86
|
+
current_resource.bcast(@interface["bcast"])
|
87
|
+
current_resource.mask(@interface["mask"])
|
88
|
+
current_resource.mtu(@interface["mtu"])
|
89
|
+
current_resource.metric(@interface["metric"])
|
91
90
|
end
|
92
|
-
|
91
|
+
current_resource
|
93
92
|
end
|
94
93
|
|
95
94
|
def define_resource_requirements
|
@@ -104,14 +103,12 @@ class Chef
|
|
104
103
|
|
105
104
|
def action_add
|
106
105
|
# check to see if load_current_resource found interface in ifconfig
|
107
|
-
unless
|
108
|
-
unless
|
106
|
+
unless current_resource.inet_addr
|
107
|
+
unless new_resource.device == loopback_device
|
109
108
|
command = add_command
|
110
|
-
converge_by
|
111
|
-
|
112
|
-
|
113
|
-
)
|
114
|
-
Chef::Log.info("#{@new_resource} added")
|
109
|
+
converge_by("run #{command.join(' ')} to add #{new_resource}") do
|
110
|
+
shell_out_compact!(command)
|
111
|
+
Chef::Log.info("#{new_resource} added")
|
115
112
|
end
|
116
113
|
end
|
117
114
|
end
|
@@ -122,31 +119,25 @@ class Chef
|
|
122
119
|
def action_enable
|
123
120
|
# check to see if load_current_resource found ifconfig
|
124
121
|
# enables, but does not manage config files
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
)
|
132
|
-
Chef::Log.info("#{@new_resource} enabled")
|
133
|
-
end
|
134
|
-
end
|
122
|
+
return if current_resource.inet_addr
|
123
|
+
return if new_resource.device == loopback_device
|
124
|
+
command = enable_command
|
125
|
+
converge_by("run #{command.join(' ')} to enable #{new_resource}") do
|
126
|
+
shell_out_compact!(command)
|
127
|
+
Chef::Log.info("#{new_resource} enabled")
|
135
128
|
end
|
136
129
|
end
|
137
130
|
|
138
131
|
def action_delete
|
139
132
|
# check to see if load_current_resource found the interface
|
140
|
-
if
|
133
|
+
if current_resource.device
|
141
134
|
command = delete_command
|
142
|
-
converge_by
|
143
|
-
|
144
|
-
|
145
|
-
)
|
146
|
-
Chef::Log.info("#{@new_resource} deleted")
|
135
|
+
converge_by("run #{command.join(' ')} to delete #{new_resource}") do
|
136
|
+
shell_out_compact!(command)
|
137
|
+
Chef::Log.info("#{new_resource} deleted")
|
147
138
|
end
|
148
139
|
else
|
149
|
-
Chef::Log.debug("#{
|
140
|
+
Chef::Log.debug("#{new_resource} does not exist - nothing to do")
|
150
141
|
end
|
151
142
|
delete_config
|
152
143
|
end
|
@@ -154,21 +145,19 @@ class Chef
|
|
154
145
|
def action_disable
|
155
146
|
# check to see if load_current_resource found the interface
|
156
147
|
# disables, but leaves config files in place.
|
157
|
-
if
|
148
|
+
if current_resource.device
|
158
149
|
command = disable_command
|
159
|
-
converge_by
|
160
|
-
|
161
|
-
|
162
|
-
)
|
163
|
-
Chef::Log.info("#{@new_resource} disabled")
|
150
|
+
converge_by("run #{command.join(' ')} to disable #{new_resource}") do
|
151
|
+
shell_out_compact!(command)
|
152
|
+
Chef::Log.info("#{new_resource} disabled")
|
164
153
|
end
|
165
154
|
else
|
166
|
-
Chef::Log.debug("#{
|
155
|
+
Chef::Log.debug("#{new_resource} does not exist - nothing to do")
|
167
156
|
end
|
168
157
|
end
|
169
158
|
|
170
159
|
def can_generate_config?
|
171
|
-
|
160
|
+
!@config_template.nil? && !@config_path.nil?
|
172
161
|
end
|
173
162
|
|
174
163
|
def resource_for_config(path)
|
@@ -182,40 +171,40 @@ class Chef
|
|
182
171
|
config = resource_for_config(@config_path)
|
183
172
|
config.content(template.result(b))
|
184
173
|
config.run_action(:create)
|
185
|
-
|
174
|
+
new_resource.updated_by_last_action(true) if config.updated?
|
186
175
|
end
|
187
176
|
|
188
177
|
def delete_config
|
189
178
|
return unless can_generate_config?
|
190
179
|
config = resource_for_config(@config_path)
|
191
180
|
config.run_action(:delete)
|
192
|
-
|
181
|
+
new_resource.updated_by_last_action(true) if config.updated?
|
193
182
|
end
|
194
183
|
|
195
184
|
private
|
196
185
|
|
197
186
|
def add_command
|
198
|
-
command = "ifconfig
|
199
|
-
command
|
200
|
-
command
|
201
|
-
command
|
187
|
+
command = [ "ifconfig", new_resource.device, new_resource.target ]
|
188
|
+
command += [ "netmask", new_resource.mask ] if new_resource.mask
|
189
|
+
command += [ "metric", new_resource.metric ] if new_resource.metric
|
190
|
+
command += [ "mtu", new_resource.mtu ] if new_resource.mtu
|
202
191
|
command
|
203
192
|
end
|
204
193
|
|
205
194
|
def enable_command
|
206
|
-
command = "ifconfig
|
207
|
-
command
|
208
|
-
command
|
209
|
-
command
|
195
|
+
command = [ "ifconfig", new_resource.device, new_resource.target ]
|
196
|
+
command += [ "netmask", new_resource.mask ] if new_resource.mask
|
197
|
+
command += [ "metric", new_resource.metric ] if new_resource.metric
|
198
|
+
command += [ "mtu", new_resource.mtu ] if new_resource.mtu
|
210
199
|
command
|
211
200
|
end
|
212
201
|
|
213
202
|
def disable_command
|
214
|
-
"ifconfig
|
203
|
+
[ "ifconfig", new_resource.device, "down" ]
|
215
204
|
end
|
216
205
|
|
217
206
|
def delete_command
|
218
|
-
"ifconfig
|
207
|
+
[ "ifconfig", new_resource.device, "down" ]
|
219
208
|
end
|
220
209
|
|
221
210
|
def loopback_device
|