- From: Steffen Gebert <
>
- To:
- Subject: [chef] Notifications and data
- Date: Tue, 27 Dec 2011 14:03:25 +0100
Hi,
I have some trouble with "notifies".. hope it's easy to explain to a
chef-starter :)
I've modified the "users" cookbook [1] to set an empty password and (usermod
-p "") and forcing password change on next login (chage -d 0).
Therefore I've extended the cookbook inside the
>
search(:users, 'groups:sysadmin') do |u|
loop with the following block:
>
script "set_empty_password" do
>
interpreter "bash"
>
user "root"
>
action :nothing
>
>
code <<-EOH
>
echo Running for #{u[:id]}
>
# set empty password
>
usermod -p "" #{u[:id]}
>
# force password change on next login
>
chage -d 0 #{u[:id]}
>
EOH
>
end
To notify it upon user creation, I've added
>
notifies :run, "script[set_empty_password]", :immediately
to the following block:
>
user u['id'] do
>
uid u['uid']
>
gid u['gid']
>
shell u['shell']
>
comment u['comment']
>
supports :manage_home => true
>
home home_dir
>
notifies :run, "script[set_empty_password]", :immediately
>
notifies :create, "ruby_block[reset group list]", :immediately
>
end
My problem, however, is that in the bash script, #{u[:id]} is always the user
name of the user returned as *last* from search (so for every user it always
modifies the same one). set_empty_password is executed, but with wrong data..
I've uploaded the complete file here:
https://gist.github.com/1523594
Can you tell me the reason for this?
Thanks a lot for your help!
Steffen
- [chef] Notifications and data, Steffen Gebert, 12/27/2011
Archive powered by MHonArc 2.6.16.