class Users
Public Instance Methods
deploy()
click to toggle source
# File lib/dust/recipes/users.rb, line 4 def deploy @config.each do |user, options| # just create the user, without any arguments options = {} if options.nil? or options.is_a? TrueClass next unless @node.manage_user(user, options) # don't deploy anything if the user just has been removed unless options['remove'] deploy_ssh_keys(user, options['ssh_keys']) if options['ssh_keys'] deploy_authorized_keys(user, options['authorized_keys']) if options['authorized_keys'] end end end
Private Instance Methods
create_ssh_dir(user)
click to toggle source
# File lib/dust/recipes/users.rb, line 52 def create_ssh_dir(user) ssh_dir = @node.get_home(user) + '/.ssh' @node.mkdir(ssh_dir) @node.chown("#{user}:#{@node.get_gid(user)}", ssh_dir) @node.chcon({ 'type' => 'ssh_home_t' }, ssh_dir) ssh_dir end
deploy_ssh_keys(user, key_dir)
click to toggle source
deploys ssh keys to users homedir
# File lib/dust/recipes/users.rb, line 22 def deploy_ssh_keys(user, key_dir) ssh_dir = create_ssh_dir(user) @node.messages.add("deploying ssh keys for #{user}\n") Dir["#{@template_path}/#{key_dir}/*"].each do |file| destination = "#{ssh_dir}/#{File.basename(file)}" @node.scp(file, destination, :indent => 2) @node.chown("#{user}:#{@node.get_gid(user)}", destination) # chmod private key if File.basename(file) =~ /^(id_rsa|id_dsa|id_ecdsa)$/ msg = @node.messages.add('setting private key access to 0600', :indent => 3) msg.parse_result(@node.chmod('0600', destination, :quiet => true)) end end end