Skip to content

Instantly share code, notes, and snippets.

@thommay
Forked from trekr5/gist:0ddc5b632c54e7bf568b
Last active August 29, 2015 14:16
Show Gist options
  • Save thommay/7ee4556ec46106e391db to your computer and use it in GitHub Desktop.
Save thommay/7ee4556ec46106e391db to your computer and use it in GitHub Desktop.
plain_pass = Chef::EncryptedDataBagItem.load("aws-admin-passwords", "svc_goagent")["password"]
p plain_pass
#if unix box
if node['platform'] == 'ubuntu'
chef_gem "ruby-shadow"
package "whois"
unless node.attribute? "svc_goagent_pass"
require 'digest/sha2'
salt = rand(36**8).to_s(36)
shadow_hash = plain_pass.crypt("$6$" + salt)
node.set['svc_goagent_pass'] = shadow_hash
end
group "sysadmin" do
gid 2000
action :create
end
#create user
user 'svc_goagent' do
supports :manage_home => true
comment 'Go agent user'
uid 6666
gid 2000
home '/home/svc_goagent'
shell '/bin/bash'
password node['svc_goagent_pass']
end
else
user 'svc_goagent' do
supports :manage_home => true
comment 'Go agent user'
# uid 6666
# gid 2000
# home '/home/svc_goagent'
# shell '/bin/bash'
password plain_pass
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment