Problem with user provider and passwords

Hello there,
we want to change the password of the only user created in all of our chef
clients (well, the user we use to log in through ssh). In our recipe we have
this:

package “libshadow-ruby1.8”

user “kom” do
comment "Kings of Mambo user"
gid "users"
uid 1000
home "/home/kom"
supports :manage_home => true
shell "/bin/bash"
password ""
not_if "grep 'kom: /etc/shadow"
end

This worked for some time, and I just can’t understand what happened,
because it doesn’t anymore. I changed the 'd part to have a new
password, uploaded to the chef-server, and executed chef-client on a client.
this is the log (yes, we’re still on 0.7.4, hope that’s ok :p, been working
flawlessly and didn’t have the time to worry about upgrades):

[Mon, 01 Feb 2010 11:44:26 +0100] ERROR: user[kom]
(/srv/chef/cache/cookbooks/basics/recipes/user.rb line 6) had an error:
uninitialized constant Shadow::Passwd
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in
const_missing'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/provider/user.rb:73:inload_current_resource’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:55:in
build_provider'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:86:inconverge’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in
each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:inconverge’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:58:in
each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:57:ineach’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:63:in
converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:373:inconverge’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:81:in
run'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:164:inrun_application’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in
loop'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:inrun_application’/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application.rb:57:in
run'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/bin/chef-client:26/usr/bin/chef-client:19:inload’/usr/bin/chef-client:19
[Mon, 01 Feb 2010 11:44:26 +0100] ERROR: NameError
[Mon, 01 Feb 2010 11:44:26 +0100] FATAL: uninitialized constant
Shadow::Passwd

/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in
const_missing' */opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/provider/user.rb:73:inload_current_resource’*
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:55:in
build_provider' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:86:inconverge’
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in
each' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:inconverge’
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:58:in
each' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:57:ineach’
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:63:in
converge' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:373:inconverge’
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:81:in
run' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:164:inrun_application’
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in
loop' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:inrun_application’
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application.rb:57:in
run' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/bin/chef-client:26 /usr/bin/chef-client:19:inload’
/usr/bin/chef-client:19

In the highlighted file, there’s this line:

          shadow_info = Shadow::Passwd.getspnam(@new_resource.username)

A couple of lines before there’s a require ‘shadow’. I installed the shadow
gem (sudo gem install shadow), but nothing changed, and I don’t think that
was the desired action anyway since the Shadow gem is an ActiveRecord
restful server.

The package libshadow-ruby1.8 is already installed (from day 1 of the
installation)

apt-get install libshadow-ruby1.8

Reading package lists… Done
Building dependency tree
Reading state information… Done
libshadow-ruby1.8 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

I’m out of ideas. Can’t find that Shadow::Passwd anywhere. I can change
passwords everywhere manually, but would rather spend the time trying to fix
this. Any idea/tip/help is most welcome.

Thanks!!

Albert Llop

Albert,

It's not the 'shadow' gem you need - it's the C extension named 'libshadow-ruby'. This is available as a package on most system Ruby installations. If you use REE, you might want to try running this cookbook with chef-solo beforehand:

http://github.com/37signals/37s_cookbooks/tree/045bd582565713203a661b2851933ea2b00b79bd/ruby-shadow

Alternatively you can manually install the library in the 'files' directory in the cookbook (I can never find the original download location for this thing).

  • Joshua

On Feb 1, 2010, at 11:52 AM, Albert Llop wrote:

Hello there,
we want to change the password of the only user created in all of our chef clients (well, the user we use to log in through ssh). In our recipe we have this:

package "libshadow-ruby1.8"

user "kom" do
comment "Kings of Mambo user"
gid "users"
uid 1000
home "/home/kom"
supports :manage_home => true
shell "/bin/bash"
password ""
not_if "grep 'kom: /etc/shadow"
end

This worked for some time, and I just can't understand what happened, because it doesn't anymore. I changed the 'd part to have a new password, uploaded to the chef-server, and executed chef-client on a client. this is the log (yes, we're still on 0.7.4, hope that's ok :p, been working flawlessly and didn't have the time to worry about upgrades):

[Mon, 01 Feb 2010 11:44:26 +0100] ERROR: user[kom] (/srv/chef/cache/cookbooks/basics/recipes/user.rb line 6) had an error:
uninitialized constant Shadow::Passwd
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in const_missing'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/provider/user.rb:73:in load_current_resource'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:55:in build_provider'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:86:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:58:in each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:57:in each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:63:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:373:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:81:in run'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:164:in run_application'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in loop'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in run_application'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application.rb:57:in run'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/bin/chef-client:26/usr/bin/chef-client:19:in load'/usr/bin/chef-client:19
[Mon, 01 Feb 2010 11:44:26 +0100] ERROR: NameError
[Mon, 01 Feb 2010 11:44:26 +0100] FATAL: uninitialized constant Shadow::Passwd
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in const_missing' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/provider/user.rb:73:in load_current_resource'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:55:in build_provider' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:86:in converge'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in each' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in converge'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:58:in each' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:57:in each'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:63:in converge' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:373:in converge'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:81:in run' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:164:in run_application'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in loop' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in run_application'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application.rb:57:in run' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/bin/chef-client:26 /usr/bin/chef-client:19:in load'
/usr/bin/chef-client:19

In the highlighted file, there's this line:

          shadow_info = Shadow::Passwd.getspnam(@new_resource.username)

A couple of lines before there's a require 'shadow'. I installed the shadow gem (sudo gem install shadow), but nothing changed, and I don't think that was the desired action anyway since the Shadow gem is an ActiveRecord restful server.

The package libshadow-ruby1.8 is already installed (from day 1 of the installation)

apt-get install libshadow-ruby1.8

Reading package lists... Done
Building dependency tree
Reading state information... Done
libshadow-ruby1.8 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

I'm out of ideas. Can't find that Shadow::Passwd anywhere. I can change passwords everywhere manually, but would rather spend the time trying to fix this. Any idea/tip/help is most welcome.

Thanks!!

Albert Llop

Muchas gracias Joshua!

this worked nicely. I'm still wondering how could it work in the first place
so many months ago.

Cheers

Albert Llop
Tech Department
albert@kingsofmambo.com

On 1 February 2010 12:09, Joshua Sierles joshua@37signals.com wrote:

Albert,

It's not the 'shadow' gem you need - it's the C extension named
'libshadow-ruby'. This is available as a package on most system Ruby
installations. If you use REE, you might want to try running this cookbook
with chef-solo beforehand:

http://github.com/37signals/37s_cookbooks/tree/045bd582565713203a661b2851933ea2b00b79bd/ruby-shadow

Alternatively you can manually install the library in the 'files' directory
in the cookbook (I can never find the original download location for this
thing).

  • Joshua

On Feb 1, 2010, at 11:52 AM, Albert Llop wrote:

Hello there,
we want to change the password of the only user created in all of our chef
clients (well, the user we use to log in through ssh). In our recipe we have
this:

package "libshadow-ruby1.8"

user "kom" do
comment "Kings of Mambo user"
gid "users"
uid 1000
home "/home/kom"
supports :manage_home => true
shell "/bin/bash"
password ""
not_if "grep 'kom: /etc/shadow"
end

This worked for some time, and I just can't understand what happened,
because it doesn't anymore. I changed the 'd part to have a new
password, uploaded to the chef-server, and executed chef-client on a client.
this is the log (yes, we're still on 0.7.4, hope that's ok :p, been working
flawlessly and didn't have the time to worry about upgrades):

[Mon, 01 Feb 2010 11:44:26 +0100] ERROR: user[kom]
(/srv/chef/cache/cookbooks/basics/recipes/user.rb line 6) had an error:
uninitialized constant Shadow::Passwd
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in
const_missing'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/provider/user.rb:73:in load_current_resource'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:55:in
build_provider'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:86:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in
each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:58:in
each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:57:in each'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:63:in
converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:373:in converge'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:81:in
run'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:164:in run_application'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in
loop'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in run_application'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application.rb:57:in
run'/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/bin/chef-client:26/usr/bin/chef-client:19:in load'/usr/bin/chef-client:19
[Mon, 01 Feb 2010 11:44:26 +0100] ERROR: NameError
[Mon, 01 Feb 2010 11:44:26 +0100] FATAL: uninitialized constant
Shadow::Passwd

/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:105:in
const_missing' */opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/provider/user.rb:73:in load_current_resource'*
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:55:in
build_provider' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:86:in converge'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in
each' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:85:in converge'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:58:in
each' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/resource_collection.rb:57:in each'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/runner.rb:63:in
converge' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:373:in converge'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/client.rb:81:in
run' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:164:in run_application'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in
loop' /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application/client.rb:162:in run_application'
/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/application.rb:57:in
`run'

/opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/chef-0.7.4/bin/chef-client:26
/usr/bin/chef-client:19:in `load'
/usr/bin/chef-client:19

In the highlighted file, there's this line:

          shadow_info = Shadow::Passwd.getspnam(@new_resource.username)

A couple of lines before there's a require 'shadow'. I installed the shadow
gem (sudo gem install shadow), but nothing changed, and I don't think that
was the desired action anyway since the Shadow gem is an ActiveRecord
restful server.

The package libshadow-ruby1.8 is already installed (from day 1 of the
installation)

apt-get install libshadow-ruby1.8

Reading package lists... Done
Building dependency tree
Reading state information... Done
libshadow-ruby1.8 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

I'm out of ideas. Can't find that Shadow::Passwd anywhere. I can change
passwords everywhere manually, but would rather spend the time trying to fix
this. Any idea/tip/help is most welcome.

Thanks!!

Albert Llop