-
Chef store all users in the node object under the key etc.
-
Also use lazy evaluation and you don't need a
ruby_block
-
This tree is populated by ohai at start of run, so to update it and be able to access
node['etc']['passwd']['myuser']['uid']
you have to ask ohai to run the etc plugin again like this:
ohai 'reload_passwd' do
action :nothing
plugin 'etc'
end
user 'daemonuser' do
home '/dev/null'
shell '/sbin/nologin'
system true
notifies :reload, 'ohai[reload_passwd]', :immediately
end
ruby_block 'just an example' do
block do
# These variables will now have the new values
puts node['etc']['passwd']['daemonuser']['uid']
puts node['etc']['passwd']['daemonuser']['gid']
end
end