[~/chef-test/chef-repo]$ knife cookbook create ope-user -o site-cookbooks
** Creating cookbook ope-user
** Creating README for cookbook: ope-user
** Creating CHANGELOG for cookbook: ope-user
** Creating metadata for cookbook: ope-user
[~/chef-test/chef-repo]$
$ openssl passwd -1 "password"
$1$TRAdSjI8$GlggEMZ/zThS/gyuBF3uR1
#
# Cookbook Name:: ope-user
# Recipe:: default
#
# Copyright 2014, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
user "ope" do
comment "ope user"
home "/home/ope"
shell "/bin/bash"
password "$1$TRAdSjI8$GlggEMZ/zThS/gyuBF3uR1"
supports :manage_home => true
end
group "ope" do
members ['ope']
action :create
end
group "wheel" do
members ['ope']
action :modify
append true
end
// melody.json
{
"run_list" : [
"recipe[hello]",
"recipe[ope-user]"
]
}
[~/chef-test/chef-repo]$ knife solo cook melody
Running Chef on melody...
Checking Chef version...
Uploading the kitchen...
Generating solo config...
Running Chef...
Starting Chef Client, version 11.8.2
Compiling Cookbooks...
Converging 4 resources
Recipe: hello::default
* log[Hello Knife!] action write
Recipe: ope-user::default
* user[ope] action create
- create user user[ope]
* group[ope] action create
- alter group group[ope]
- replace group members with new list of members
* group[wheel] action modify
- modify group group[wheel]
- add missing member(s): ope
Chef Client finished, 4 resources updated
[~/chef-test/chef-repo]$ ssh melody
Last login: Sun Feb 16 11:03:59 2014 from 192.168.38.1
[vagrant@vagrant-centos-6 ~]$ su ope
パスワード:
[ope@vagrant-centos-6 vagrant]$ whoami
ope
[ope@vagrant-centos-6 vagrant]$ groups
ope wheel
[ope@vagrant-centos-6 vagrant]$
うまく行ったので commit する
[~/chef-test/chef-repo]$ git add .
[~/chef-test/chef-repo]$ git commit -m "add ope-user"