On 1/26/15 2:29 PM, Douglas Garstang
wrote:
" type="cite">Yeah the warning is trying to tell you the problem. You're defining multiple resources called `execute[install_public_rsa_doug]` and the resource collection and the way notifies and subscribes is implemented requires unique names. So you're getting resource cloning and you're only notifying one of those blocks. You could add the index to then name and then subscribe to the previous resources: ssh_keys.each_with_index do |k, index| log "k = #{k}" execute "install_public_rsa_#{user_name}_#{index}" do command "su - #{user_name} -c \"echo '#{k}' >> /home/#{user_name}/.ssh/authorized_keys\"" subscribes :run, "execute[#{create_ssh_dir_#{user_name}]" subscribes :run, "execute[#{create_home_#{user_name}]" action :nothing end end You'll be way better off just doing this though: file "/home/#{user_name}" do owner user_name group user_name # or "users" or whatever mode "0600" end file "/home/#{user_name}/.ssh" do owner user_name group user_name mode "0600" end file "/home/#{user_name}/.ssh/authorized_keys" do owner user_name group user_name mode "0600" content ssh_keys.join("\n") end That's idempotent, you don't need the action :nothing or any notifications or subscriptions, you can push new keys out and it'll correctly update, gets the job done with fewer resources, etc. Similarly executing to su is a huge antipattern, so you can replace the rest of that. |
Archive powered by MHonArc 2.6.16.