Last active
November 22, 2016 07:31
-
-
Save MacoTasu/94b7e97671f9c8aca7caeb04bc96ccac to your computer and use it in GitHub Desktop.
this is cookbook that in order to create sudores user by centos, depend on https://github.com/nownabe/itamae-plugin-resource-authorized_keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
SUDO_GID=27 | |
node.validate! do | |
{ | |
sudoers: { | |
users: array_of({ | |
name: string, | |
password: string, | |
github_name: string, | |
}), | |
}, | |
} | |
end | |
for user_node in node['sudoers']['users'] do | |
user user_node['name'] do | |
# パスワードをSHA512にしたもの | |
password user_node['password'] | |
shell "/bin/bash" | |
create_home true | |
action :create | |
end | |
execute "add wheel" do | |
only_if "id #{user_node['name']}" | |
not_if "getent group #{SUDO_GID} | grep #{user_node['name']}" | |
command "usermod #{user_node['name']} -aG #{SUDO_GID}" | |
end | |
authorized_keys "#{user_node['name']}" do | |
github "#{user_node['github_name']}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
example node json