"user" resourceを使う
$ cd <chef-repo dir>/cookbooks
$ knife cookbook create user_add -o ./
$ cd user_add
$ vi attributes/user_add.rb
default['user'] = "hoge"
$ vi recipes/default.rb
user node['user'] do
home "/home/#{node['user']}"
password "phoge"
shell "/bin/bash"
end
$ cd ../..
$ vi nodes/<server>.json
{
"run_list":[
"recipe[user_add]" # ★
]
}
$ knife solo cook [email protected]
[vagrant@vmchef1 ~]$ sudo cat /etc/passwd | grep hoge
hoge:x:501:502::/home/hoge:/bin/bash ★OK
[vagrant@vmchef1 ~]$ sudo su - hoge
[hoge@vmchef1 ~]$ ★OK