別途投稿しているChef検証(1)~(3) の環境整理のためのページです。
環境まとめ
Chef Server
ユーザ名: inohana
組織名: ise
作業ディレクトリ: /etc/opscode/ise
inohana@ino-ubuntu:/etc/opscode/ise$ pwd
/etc/opscode/ise
inohana@ino-ubuntu:/etc/opscode/ise$ ls -la
total 16
drwxrwxrwx 2 root root 4096 Mar 2 04:41 .
drwxr-xr-x 4 root root 4096 Mar 10 07:55 ..
-rw-r--r-- 1 root root 1678 Mar 2 04:38 inohana.pem
-rw-r--r-- 1 root root 1678 Mar 2 04:41 ise-validator.pem
# chef-server-ctl コマンドを使用。
inohana@ino-ubuntu:~$ sudo chef-server-ctl user-list
inohana
pivotal
inohana@ino-ubuntu:~$ sudo chef-server-ctl org-list
ise
inohana@ino-ubuntu:~$
Chef Workstation
cookbookを開発するユーザ名: chefuser01
Chef Workstation で使用する リポジトリ: chef-repo
inohana@ino-ubuntu:~/chef-repo$ pwd
/home/inohana/chef-repo
Chef Workstation 上の chef-repo と Chef Server を紐づける設定
- Chef Server のユーザと組織の鍵を配置。
- 設定ファイル(knife.rb)を作成。
- knife.rb には Chef Server のユーザ名、組織名が記載されている。
inohana@ino-ubuntu:~/chef-repo/.chef$ pwd
/home/inohana/chef-repo/.chef
inohana@ino-ubuntu:~/chef-repo/.chef$ ls -la
total 24
drwxr-xr-x 3 inohana root 4096 Mar 2 05:01 .
drwxrwxr-x 5 inohana inohana 4096 Mar 10 04:44 ..
-rw------- 1 inohana root 1678 Mar 2 04:53 inohana.pem
-rw------- 1 inohana root 1678 Mar 2 04:53 ise-validator.pem
-rw-r--r-- 1 inohana root 667 Mar 2 05:01 knife.rb
drwxr-xr-x 2 inohana root 4096 Mar 2 05:01 trusted_certs
inohana@ino-ubuntu:~/chef-repo/.chef$ cat knife.rb
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name 'inohana' # <- ユーザ名
client_key "#{current_dir}/inohana.pem" # <- ユーザの鍵
validation_client_name 'ise-validator' # <- 組織の鍵の拡張子抜いた文字列を設定
validation_key "#{current_dir}/ise-validator.pem" # <- 組織の鍵
chef_server_url 'https://ino-ubuntu.iselab.local/organizations/ise' # <- 最後を組織名にする
cache_type 'BasicFile'
cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
cookbook_path ["#{current_dir}/../cookbooks"]
inohana@ino-ubuntu:~/chef-repo/.chef$
inohana@ino-ubuntu:~/chef-repo$ pwd
/home/inohana/chef-repo
# Chef Workstation と Chef Server の紐付けが完了したので、knife コマンドで Chef Server 接続が可能となる。
inohana@ino-ubuntu:~/chef-repo$ knife client list
chefn9k
ise-validator
inohana@ino-ubuntu:~/chef-repo$ knife user list
inohana
inohana@ino-ubuntu:~/chef-repo$
# knife コマンドは chef-repo 配下でないと使えない。
inohana@ino-ubuntu:~$ knife client list
WARNING: No knife configuration file found
WARN: Failed to read the private key /etc/chef/client.pem: #<Errno::ENOENT: No such file or directory @ rb_sysopen - /etc/chef/client.pem>
ERROR: Your private key could not be loaded from /etc/chef/client.pem
Check your configuration file and ensure that your private key is readable
Chef Node(Client)
Chef Workstation から Chef Node に SSH でログインするユーザ名: chefuser01(同上)
Chef Workstation から Chef Node に対して Bootstrap することにより Client(今回の場合はCisco Nexus9K) が Chef Node として Chef Server に登録できる。
証明書関連
- Chef Server でユーザ作成、pemファイル作成 → Chef Workstationへコピー
- Chef Server で組織作成、pemファイル作成 → Chef Workstationへコピー
- Chef Workstation の knife.rb に鍵情報を記述
- Chef Node でユーザ作成
- Chef Node と Chef Server で鍵交換
- どちらかで rsa