Skip to content

Instantly share code, notes, and snippets.

@trekr5
Created March 9, 2015 14:12
Show Gist options
  • Save trekr5/0ddc5b632c54e7bf568b to your computer and use it in GitHub Desktop.
Save trekr5/0ddc5b632c54e7bf568b 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'
apt_package "ruby1.9.3" do
action :install
end
gem_package "ruby-shadow" do
action :install
end
execute "sudo apt-get install whois" do
command "sudo apt-get install whois"
p "whois installed"
end
encrypted_pass = system('/bin/bash', '-c', "mkpasswd -m sha-512 #{plain_pass}")
#encrypted_pass = %x(mkpasswd -m sha-512 "#{plain_pass}")
#p encrypted_pass
# encrypted_pass = `bash -c #{escaped_command}"`
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 encrypted_pass
end
# bash 'set password' do
# user 'root'
# code <<-EOF
# usermod --password "#{encrypted_pass}" svc_goagent
# EOF
# 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