[root@CentOS7 ~]# curl -L https://www.opscode.com/chef/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 23554 100 23554 0 0 35413 0 –:–:– –:–:– –:–:– 35419
el 7 x86_64
Getting information for chef stable for el…
downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=&p=el&pv=7&m=x86_64
to file /tmp/install.sh.1851/metadata.txt
trying wget…
sha1 599b3294c243e362ca77fb89a723c42fc29dae68
sha256 ccf3b233b2e971a9fde360b6c9a3536ad31369c6c0c256b1f7619650c03695ab
url https://packages.chef.io/files/stable/chef/16.1.16/el/7/chef-16.1.16-1.el7.x86_64.rpm
version 16.1.16
downloaded metadata file looks valid…
downloading https://packages.chef.io/files/stable/chef/16.1.16/el/7/chef-16.1.16-1.el7.x86_64.rpm
to file /tmp/install.sh.1851/chef-16.1.16-1.el7.x86_64.rpm
trying wget…
Comparing checksum with sha256sum…
You are installing a package without a version pin. If you are installing
on production servers via an automated process this is DANGEROUS and you will
be upgraded without warning on new releases, even to new major releases.
Letting the version float is only appropriate in desktop, test, development or
CI/CD environments.
Installing chef
installing with rpm…
警告: /tmp/install.sh.1851/chef-16.1.16-1.el7.x86_64.rpm: ヘッダー V4 DSA/SHA1 Signature、鍵 ID 83ef826a: NOKEY
準備しています… ################################# [100%]
更新中 / インストール中…
1:chef-16.1.16-1.el7 ################################# [100%]
Thank you for installing Chef Infra Client! For help getting started visit https://learn.chef.io
[root@CentOS7 ~]#
Your cookbook is ready. Type `cd cookbooks/hello` to enter it.
There are several commands you can run to get started locally developing and testing your cookbook.
Type `delivery local –help` to see a full list of local testing commands.
Why not start by writing an InSpec test? Tests for the default recipe are stored at:
test/integration/default/default_test.rb
If you’d prefer to dive right in, the default recipe can be found at:
recipes/default.rb
[root@CentOS7 chef]#
chef generate コマンド一覧です。
[root@CentOS7 chef]# chef generate
Usage: chef generate GENERATOR [options]
Available generators:
cookbook Generate a single cookbook
recipe Generate a new recipe
attribute Generate an attributes file
template Generate a file template
file Generate a cookbook file
helpers Generate a cookbook helper file in libraries
resource Generate a custom resource
repo Generate a Chef Infra code repository
policyfile Generate a Policyfile for use with the install/push commands
generator Copy ChefDK’s generator cookbook so you can customize it
build-cookbook Generate a build cookbook for use with Chef Workflow (Delivery)
[root@CentOS7 chef]#
recipes ディレクトリに移動します。
[root@CentOS7 chef]# cd cookbooks/hello/recipes/
default.rb ファイルを編集します。
[root@CentOS7 recipes]# vi default.rb
#
# Cookbook:: hello
# Recipe:: default
#
# Copyright:: 2020, The Authors, All Rights Reserved. log “hello world!” ← 追加します。
cookbook を指定して chef-solo コマンドを実行します。
[root@CentOS7 recipes]# chef-solo -o hello
[2020-06-07T11:15:16+09:00] WARN: No config file found or specified on command line. Using command line options instead.
[2020-06-07T11:15:16+09:00] WARN: *****************************************
[2020-06-07T11:15:16+09:00] WARN: Did not find config file: /etc/chef/client.rb. Using command line options instead.
[2020-06-07T11:15:16+09:00] WARN: *****************************************
Starting Chef Infra Client, version 15.11.8
[2020-06-07T11:15:18+09:00] WARN: Run List override has been provided.
[2020-06-07T11:15:18+09:00] WARN: Original Run List: []
[2020-06-07T11:15:18+09:00] WARN: Overridden Run List: [recipe[hello]]
resolving cookbooks for run list: [“hello”]
Synchronizing Cookbooks:
– hello (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks…
Converging 1 resources
Recipe: hello::default
* log[hello world!] action write
[2020-06-07T11:15:18+09:00] WARN: Skipping final node save because override_runlist was given
Running handlers:
Running handlers complete
Chef Infra Client finished, 1/1 resources updated in 01 seconds
[root@CentOS7 recipes]#
[root@CentOS7 chef]# chef generate cookbook cookbooks/bind-utils
recipes ディレクトリに移動します。
[root@CentOS7 chef]# cd cookbooks/bind-utils/recipes/
default.rb ファイルを編集します。
[root@CentOS7 recipes]# vi default.rb
#
# Cookbook:: bind-utils
# Recipe:: default
#
# Copyright:: 2020, The Authors, All Rights Reserved.
package “bind-utils” do
action :install
end
chef-solo コマンドを実行します。
[root@CentOS7 recipes]# chef-solo -o bind-utils
[2020-06-07T12:06:27+09:00] WARN: No config file found or specified on command line. Using command line options instead.
[2020-06-07T12:06:27+09:00] WARN: *****************************************
[2020-06-07T12:06:27+09:00] WARN: Did not find config file: /etc/chef/client.rb. Using command line options instead.
[2020-06-07T12:06:27+09:00] WARN: *****************************************
Starting Chef Infra Client, version 15.11.8
[2020-06-07T12:06:29+09:00] WARN: Run List override has been provided.
[2020-06-07T12:06:29+09:00] WARN: Original Run List: []
[2020-06-07T12:06:29+09:00] WARN: Overridden Run List: [recipe[bind-utils]]
resolving cookbooks for run list: [“bind-utils”]
Synchronizing Cookbooks:
– bind-utils (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks…
Converging 1 resources
Recipe: bind-utils::default
* yum_package[bind-utils] action install
– install version 32:9.11.4-16.P2.el7_8.6.x86_64 of package bind-utils
[2020-06-07T12:06:40+09:00] WARN: Skipping final node save because override_runlist was given
Running handlers:
Running handlers complete
Chef Infra Client finished, 1/1 resources updated in 12 seconds
[root@CentOS7 recipes]#
コメント