Using chef to add a user
This is part of my quest to sort out my website. Using chef to add a user.
While I could continue to log into my new EC2 instance as the default
ubuntu
user, I’d prefer to use my own user account. Let’s get chef to create
my user account.
Using the ‘users’ community cookbook
Note: This is cribbed from Managing Users and SSH Keys in a Hybrid World
Add the cookbook (and its dependencies) to Berksfile
:
cookbook 'users'
cookbook 'sudo'
cookbook 'chef-solo-search'
Create a databag
mkdir -p data_bags/users
Configure the new user
Create a file data_bags/users/roger.json
:
{
"id" : "roger",
"comment" : "Roger Lipscombe",
"shell" : "/bin/bash",
"groups" : "sysadmin",
"ssh_keys" : [
"ssh-rsa AAAAB3...== roger"
]
}
Configure the role
In roles/base.rb
, edit it as follows:
run_list(
# ...
'chef-solo-search',
'users::sysadmins'
)
sudoers
- TODO
bash_profile
- TODO