- From: <
>
- To:
- Subject: [chef] Hosts in users databags
- Date: Tue, 9 Jul 2013 13:13:26 -0700 (PDT)
Hi.
I need to improve my cookbook with use more attributes from databags. If
anyone
can help me, I would appreciate it very much.
I have some structure in users databags like this:
{
"id": "stpik",
"ssh_keys": "ssh-rsa
AAAAB3NzaC1yc2EAAAABIwAAAQEA07GRR4vlBauJPDyEZhBg7l/YXRafbEWcH+fAa5SjKph4bJUaJiHv3WRETTTcnGElWPPQyQPBU7vQpUtcassV6gF2/EeFAeBsRReBfroNWGzqD63fFjwgS3CwewPlm5y3dhpy9vNUfPcG1ekbnPCnl66xSazBYI4j4SmCn5iGhZ8tt7tHP+IT8QVpHpVU9qUsBueSGNU68JzNmVQwH/5rh8ItFGrQfKfU3pYi7DaGP4Gj4r05jFlI+AkVwvTHg6amtjSMX2+7CRNqK2VGQrCWIaRX2PR6NEZVqBpTi/C0sdrtewU1oRhuqOV9YJnSw==
",
"groups": ["admins"],
"hosts": ["prod1", "prod2.example.com"]
}
and some ruby at recipe:
users = Array.new
ssh_array = Array.new
search(:ssh_users, 'groups:us') do |u|
users << u['id']
ssh_array << u['ssh_keys'] + ' >> ' + u['id']
template "/home/us/.ssh/authorized_keys" do
source "authorized_keys.erb"
owner "ess"
group "ess"
mode "0600"
variables :ssh_keys => ssh_array
end
end
The question is how I can use hosts to deliver users only to defined hosts or
if there empty then to all?
- [chef] Hosts in users databags, nowarry, 07/09/2013
Archive powered by MHonArc 2.6.16.