Trying to understand user/group resources


#1

I’ve been doing some experimentation with the user/group resources and I’m
confused by some of the behavior. Here is a snippet that I fed to chef-solo:

group “mwhiteley” do
gid 1000
end

user “mwhiteley” do
comment "Matt Whiteley"
uid 1000
gid "mwhiteley"
home "/home/mwhiteley"
shell "/bin/zsh"
end

I then ran chef-solo starting from various states:

  • neither exists
    before:
    after:
    /etc/passwd:mwhiteley:x:1000:1000:Matt Whiteley:/home/mwhiteley:/bin/zsh
    /etc/group:mwhiteley:x:1000:

  • both created perfectly

  • user exists
    before:
    /etc/passwd:mwhiteley:x:1000:100:Matt Whiteley:/home/mwhiteley:/bin/zsh
    after:
    /etc/passwd:mwhiteley:x:1000:1000:Matt Whiteley:/home/mwhiteley:/bin/zsh
    /etc/group:mwhiteley:x:1000:

  • group created, user[gid] changed

  • group exists
    before:
    /etc/group:mwhiteley:x:500:
    after:
    /etc/passwd:mwhiteley:x:1000:500:Matt Whiteley:/home/mwhiteley:/bin/zsh
    /etc/group:mwhiteley:x:500:

  • user created, group[gid] not changed

  • both exist
    before:
    /etc/passwd:mwhiteley:x:500:500::/home/mwhiteley:/bin/bash
    /etc/group:mwhiteley:x:500:
    after:
    /etc/passwd:mwhiteley:x:1000:500:Matt Whiteley:/home/mwhiteley:/bin/zsh
    /etc/group:mwhiteley:x:500:

  • user[uid] changed, group[gid] not changed

I would like to know if this is a bug or if I just need to understand rules
about what will or won’t be changed when encountering pre-existing resources.

I also noticed on the http://wiki.opscode.com/display/chef/Resources page the
group[gid] isn’t quoted while the similarly numeric user[uid] is quoted. When I
placed quotes on the group[gid] I got the following error:
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/…/lib/chef/mixin/params_validate.rb:140:in
`_pv_kind_of’: Option gid must be a kind of Integer! You passed “1000”.
(Chef::Exceptions::ValidationFailed)

I appreciate someone pointing out my misunderstanding.

thanks,

Matt Whiteley mattwhiteley@gmail.com


#2

Hi,

Le 28/04/2010 00:10, mattwhiteley@gmail.com a écrit :

I’ve been doing some experimentation with the user/group resources and I’m
confused by some of the behavior. Here is a snippet that I fed to chef-solo:

[…]
I also noticed on the http://wiki.opscode.com/display/chef/Resources page the
group[gid] isn’t quoted while the similarly numeric user[uid] is quoted. When I
placed quotes on the group[gid] I got the following error:
/usr/lib/ruby/gems/1.8/gems/chef-0.8.10/bin/…/lib/chef/mixin/params_validate.rb:140:in
`_pv_kind_of’: Option gid must be a kind of Integer! You passed “1000”.
(Chef::Exceptions::ValidationFailed)

I can’t tell for the first question but as I said on irc I submitted a
patch to correct this String/Integer discrepancy:
http://tickets.opscode.com/browse/CHEF-1156
I haven’t tried it yet, maybe you can apply the patch manually to see if
it works fine.

Regards


Farzad FARID / Architecte Open Source
Pragmatic Source / http://www.pragmatic-source.com
Tel : +33 9 53 19 21 90 / Mob : +33 6 03 70 65 46