diff options
author | Matt Wrock <matt@mattwrock.com> | 2015-10-08 13:08:16 -0700 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2015-10-08 13:08:16 -0700 |
commit | bc5c350bbf4b339a3a89c685372780ded2d46f12 (patch) | |
tree | 6649ad5e347d3ae647c33762b751ebad83d0de73 | |
parent | cdbd244f7d1de53c7228f6758866c083ae71a3c3 (diff) | |
download | chef-bc5c350bbf4b339a3a89c685372780ded2d46f12.tar.gz |
ignore gid on windows and warn to use group
-rw-r--r-- | lib/chef/provider/user/windows.rb | 10 | ||||
-rw-r--r-- | spec/functional/resource/user/windows_spec.rb | 8 |
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index e282a11d45..87310a4acf 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -35,6 +35,10 @@ class Chef end def load_current_resource + if @new_resource.gid + Chef::Log.warn("The 'gid' attribute is not implemented by the Windows platform. Please use the 'group' resource to assign a user th a group.") + end + @current_resource = Chef::Resource::User.new(@new_resource.name) @current_resource.username(@new_resource.username) user_info = nil @@ -42,7 +46,6 @@ class Chef user_info = @net_user.get_info @current_resource.uid(user_info[:user_id]) - @current_resource.gid(user_info[:primary_group_id]) @current_resource.comment(user_info[:full_name]) @current_resource.home(user_info[:home_dir]) @current_resource.shell(user_info[:script_path]) @@ -60,12 +63,12 @@ class Chef # === Returns # <true>:: If a change is required # <false>:: If the users are identical - def compare_user + def compare_user unless @net_user.validate_credentials(@new_resource.password) Chef::Log.debug("#{@new_resource} password has changed") return true end - [ :uid, :gid, :comment, :home, :shell ].any? do |user_attrib| + [ :uid, :comment, :home, :shell ].any? do |user_attrib| !@new_resource.send(user_attrib).nil? && @new_resource.send(user_attrib) != @current_resource.send(user_attrib) end end @@ -100,7 +103,6 @@ class Chef field_list = { 'comment' => 'full_name', 'home' => 'home_dir', - 'gid' => 'primary_group_id', 'uid' => 'user_id', 'shell' => 'script_path', 'password' => 'password' diff --git a/spec/functional/resource/user/windows_spec.rb b/spec/functional/resource/user/windows_spec.rb index 5e68478b34..5e3a9090d4 100644 --- a/spec/functional/resource/user/windows_spec.rb +++ b/spec/functional/resource/user/windows_spec.rb @@ -66,6 +66,14 @@ describe Chef::Provider::User::Windows, :windows_only do new_resource.run_action(:create) expect(new_resource).to be_updated_by_last_action end + + context 'with a gid specified' do + it 'warns unsupported' do + expect(Chef::Log).to receive(:warn).with(/not implemented/) + new_resource.gid('agroup') + new_resource.run_action(:create) + end + end end describe 'action :remove' do |