Update nodejs, sudo and users cookbooks
This commit is contained in:
@@ -40,11 +40,6 @@ action :create do
|
||||
users_groups[g] << u['username']
|
||||
end
|
||||
|
||||
# Check if we need to prepend shell with /usr/local/?
|
||||
if platform_family? 'freebsd'
|
||||
u['shell'] = (!::File.exist?(u['shell']) && ::File.exist?("/usr/local#{u['shell']}") ? "/usr/local#{u['shell']}" : '/bin/sh')
|
||||
end
|
||||
|
||||
# Set home to location in data bag,
|
||||
# or a reasonable default ($home_basedir/$user).
|
||||
home_dir = (u['home'] ? u['home'] : "#{home_basedir}/#{u['username']}")
|
||||
@@ -70,7 +65,7 @@ action :create do
|
||||
user u['username'] do
|
||||
uid validate_id(u['uid'])
|
||||
gid validate_id(u['gid']) if u['gid']
|
||||
shell u['shell']
|
||||
shell shell_is_valid?(u['shell']) ? u['shell'] : '/bin/sh'
|
||||
comment u['comment']
|
||||
password u['password'] if u['password']
|
||||
salt u['salt'] if u['salt']
|
||||
@@ -91,6 +86,19 @@ action :create do
|
||||
only_if { !!(u['ssh_keys'] || u['ssh_private_key'] || u['ssh_public_key']) }
|
||||
end
|
||||
|
||||
# loop over the keys and if we have a URL we should add each key
|
||||
# from the url response and append it to the list of keys
|
||||
ssh_keys = []
|
||||
if u['ssh_keys']
|
||||
Array(u['ssh_keys']).each do |key|
|
||||
if key.start_with?('https')
|
||||
ssh_keys += keys_from_url(key)
|
||||
else
|
||||
ssh_keys << key
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
template "#{home_dir}/.ssh/authorized_keys" do
|
||||
source 'authorized_keys.erb'
|
||||
cookbook new_resource.cookbook
|
||||
@@ -98,7 +106,9 @@ action :create do
|
||||
group validate_id(u['gid']) if u['gid']
|
||||
mode '0600'
|
||||
sensitive true
|
||||
variables ssh_keys: u['ssh_keys']
|
||||
# ssh_keys should be a combination of u['ssh_keys'] and any keys
|
||||
# returned from a specified URL
|
||||
variables ssh_keys: ssh_keys
|
||||
only_if { !!(u['ssh_keys']) }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user