Chef-server,workstation,node set-up

148.72.244.143 chefserver.linuxmadeeasy.in
160.153.228.67 chefworkstation.linuxmadeeasy.in
107.180.72.87 chefclient.linuxmadeeasy.in

=============== SERVER ===================

148.72.244.143 chefserver.linuxmadeeasy.in

[root@chefserver ~]# wget https://packages.chef.io/stable/el/7/chef-server-core-12.10.0-1.el7.x86_64.rpm
–2016-11-18 14:06:15– https://packages.chef.io/stable/el/7/chef-server-core-12.10.0-1.el7.x86_64.rpm
Resolving packages.chef.io (packages.chef.io)… 151.101.8.65
Connecting to packages.chef.io (packages.chef.io)|151.101.8.65|:443… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: https://packages.chef.io/files/stable/chef-server/12.10.0/el/7/chef-server-core-12.10.0-1.el7.x86_64.rpm [following]
–2016-11-18 14:06:16– https://packages.chef.io/files/stable/chef-server/12.10.0/el/7/chef-server-core-12.10.0-1.el7.x86_64.rpm
Reusing existing connection to packages.chef.io:443.
HTTP request sent, awaiting response… 200 OK
Length: 343413282 (328M) [application/x-rpm]
Saving to: ‘chef-server-core-12.10.0-1.el7.x86_64.rpm’

100%[=====================================================================================================>] 34,34,13,282 10.4MB/s in 30s

2016-11-18 14:07:04 (10.8 MB/s) – ‘chef-server-core-12.10.0-1.el7.x86_64.rpm’ saved [343413282/343413282]
[root@chefserver ~]# ls -l
total 335372
-rw——-. 1 root root 3596 Nov 16 13:52 anaconda-ks.cfg
-rw-r–r– 1 root root 343413282 Oct 31 13:10 chef-server-core-12.10.0-1.el7.x86_64.rpm

[root@chefserver ~]# rpm -ivh chef-server-core-12.10.0-1.el7.x86_64.rpm
warning: chef-server-core-12.10.0-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:chef-server-core-12.10.0-1.el7 ################################# [100%]

[root@chefserver ~]# chef-server-ctl reconfigure

[root@chefserver ~]# chef-server-ctl status

[root@chefserver ~]# chef-server-ctl user-create admin admin admin mohammedrafi494@gmail.com password -f /etc/chef/admin.pem

[root@chefserver ~]# chef-server-ctl org-create itrules “ITrules, Inc” –association_user admin -f /etc/chef/itrules-validator.pem
[root@chefserver chef]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9999 0.0.0.0:* LISTEN 12321/nginx: master
tcp 0 0 0.0.0.0:9680 0.0.0.0:* LISTEN 12321/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12321/nginx: master
tcp 0 0 127.0.0.1:4369 0.0.0.0:* LISTEN 9854/epmd
tcp 0 0 0.0.0.0:9683 0.0.0.0:* LISTEN 12321/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 9508/sshd
tcp 0 0 127.0.0.1:9463 0.0.0.0:* LISTEN 12252/beam.smp
tcp 0 0 127.0.0.1:15672 0.0.0.0:* LISTEN 12109/beam.smp
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 12201/postgres
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 12321/nginx: master
tcp 0 0 127.0.0.1:16379 0.0.0.0:* LISTEN 12041/redis-server
tcp 0 0 127.0.0.1:43903 0.0.0.0:* LISTEN 12465/beam.smp
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 12606/beam.smp
tcp 0 0 127.0.0.1:4321 0.0.0.0:* LISTEN 12465/beam.smp
tcp 0 0 127.0.0.1:36033 0.0.0.0:* LISTEN 12252/beam.smp
tcp 0 0 127.0.0.1:34561 0.0.0.0:* LISTEN 11977/beam.smp
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN 12302/rails master
tcp 0 0 127.0.0.1:36902 0.0.0.0:* LISTEN 12606/beam.smp
tcp 0 0 127.0.0.1:5672 0.0.0.0:* LISTEN 12109/beam.smp
tcp 0 0 127.0.0.1:25672 0.0.0.0:* LISTEN 12109/beam.smp
tcp6 0 0 :::22 :::* LISTEN 9508/sshd
tcp6 0 0 127.0.0.1:8983 :::* LISTEN 12354/java
tcp6 0 0 ::1:5432 :::* LISTEN 12201/postgres
===================================================================
[root@chefserver ~]# chef-server-ctl install chef-manage
Starting Chef Client, version 12.16.27
resolving cookbooks for run list: [“private-chef::add_ons_wrapper”]
Synchronizing Cookbooks:
– private-chef (0.1.0)
– yum (3.13.0)
– apt (2.9.2)
– enterprise (0.10.1)
– packagecloud (0.2.5)
– runit (1.6.0)
– openssl (6.0.0)
Installing Cookbook Gems:
Compiling Cookbooks…
Converging 4 resources
Recipe: private-chef::add_ons_wrapper
* ruby_block[addon_install_notification_chef-manage] action nothing (skipped due to action :nothing)
* remote_file[/var/opt/opscode/local-mode-cache/chef-manage-2.4.4-1.el7.x86_64.rpm] action create
– create new file /var/opt/opscode/local-mode-cache/chef-manage-2.4.4-1.el7.x86_64.rpm
– update content in file /var/opt/opscode/local-mode-cache/chef-manage-2.4.4-1.el7.x86_64.rpm from none to 270cca
(file sizes exceed 10000000 bytes, diff output suppressed)
* ruby_block[locate_addon_package_chef-manage] action run
– execute the ruby block locate_addon_package_chef-manage
* yum_package[chef-manage] action install
– install version 2.4.4-1.el7 of package chef-manage
* ruby_block[addon_install_notification_chef-manage] action create
– execute the ruby block addon_install_notification_chef-manage

Running handlers:
— Installed Add-On Package: chef-manage
– #::AddonInstallHandler
Running handlers complete
Chef Client finished, 4/5 resources updated in 01 minutes 20 seconds
===================================================================
[root@chefserver ~]# opscode-manage-ctl reconfigure
To use this software, you must agree to the terms of the software license agreement.
Press any key to continue.
Type ‘yes’ to accept the software license agreement, or anything else to cancel.
yes
Starting Chef Client, version 12.4.1
===================================================================
username:admin/ password:password

server1

=======================================================================

160.153.228.67 chefworkstation.linuxmadeeasy.in

[root@chefworkstation ~]# wget https://packages.chef.io/stable/el/7/chefdk-0.19.6-1.el7.x86_64.rpm
–2016-11-18 14:22:11– https://packages.chef.io/stable/el/7/chefdk-0.19.6-1.el7.x86_64.rpm
Resolving packages.chef.io (packages.chef.io)… 151.101.36.65
Connecting to packages.chef.io (packages.chef.io)|151.101.36.65|:443… connected.
HTTP request sent, awaiting response… 301 Moved Permanently
Location: https://packages.chef.io/files/stable/chefdk/0.19.6/el/7/chefdk-0.19.6-1.el7.x86_64.rpm [following]
–2016-11-18 14:22:11– https://packages.chef.io/files/stable/chefdk/0.19.6/el/7/chefdk-0.19.6-1.el7.x86_64.rpm
Reusing existing connection to packages.chef.io:443.
HTTP request sent, awaiting response… 200 OK
Length: 107254395 (102M) [application/x-rpm]
Saving to: ‘chefdk-0.19.6-1.el7.x86_64.rpm’

100%[=====================================================================================================>] 10,72,54,395 9.55MB/s in 10s

2016-11-18 14:22:31 (9.93 MB/s) – ‘chefdk-0.19.6-1.el7.x86_64.rpm’ saved [107254395/107254395]
[root@chefworkstation ~]# ls -l
total 104748
-rw——-. 1 root root 3596 Nov 16 13:52 anaconda-ks.cfg
-rw-r–r– 1 root root 107254395 Oct 17 13:22 chefdk-0.19.6-1.el7.x86_64.rpm

[root@chefworkstation ~]# rpm -ivh chefdk-0.19.6-1.el7.x86_64.rpm
warning: chefdk-0.19.6-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:chefdk-0.19.6-1.el7 ################################# [100%]
Thank you for installing Chef Development Kit!

[root@chefworkstation ~]# chef verify
Running verification for component ‘berkshelf’
Running verification for component ‘test-kitchen’
Running verification for component ‘tk-policyfile-provisioner’
Running verification for component ‘chef-client’
Running verification for component ‘chef-dk’
Running verification for component ‘chef-provisioning’
Running verification for component ‘chefspec’
Running verification for component ‘generated-cookbooks-pass-chefspec’
Running verification for component ‘rubocop’
Running verification for component ‘fauxhai’
Running verification for component ‘knife-spork’
Running verification for component ‘kitchen-vagrant’
Running verification for component ‘package installation’
Running verification for component ‘openssl’
Running verification for component ‘inspec’
Running verification for component ‘delivery-cli’
Running verification for component ‘git’
Running verification for component ‘opscode-pushy-client’
Running verification for component ‘chef-sugar’
…………….
———————————————
Verification of component ‘rubocop’ succeeded.
Verification of component ‘knife-spork’ succeeded.
Verification of component ‘openssl’ succeeded.
Verification of component ‘delivery-cli’ succeeded.
Verification of component ‘opscode-pushy-client’ succeeded.
Verification of component ‘berkshelf’ succeeded.
Verification of component ‘tk-policyfile-provisioner’ succeeded.
Verification of component ‘chef-dk’ succeeded.
Verification of component ‘chefspec’ succeeded.
Verification of component ‘fauxhai’ succeeded.
Verification of component ‘inspec’ succeeded.
Verification of component ‘test-kitchen’ succeeded.
Verification of component ‘kitchen-vagrant’ succeeded.
Verification of component ‘git’ succeeded.
Verification of component ‘chef-client’ succeeded.
Verification of component ‘chef-sugar’ succeeded.
Verification of component ‘chef-provisioning’ succeeded.
Verification of component ‘generated-cookbooks-pass-chefspec’ succeeded.
Verification of component ‘package installation’ succeeded.

[root@chefworkstation ~]# which ruby
/usr/bin/which: no ruby in (/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

[root@chefworkstation ~]# echo ‘eval “$(chef shell-init bash)”‘ >> ~/.bash_profile

[root@chefworkstation ~]# . ~/.bash_profile

[root@chefworkstation ~]# which ruby
/opt/chefdk/embedded/bin/ruby

[root@chefworkstation ~]# yum -y install git
[root@chefworkstation ~]# chef generate repo chef-repo
Recipe: code_generator::repo
* directory[/root/chef-repo] action create
– create new directory /root/chef-repo
* template[/root/chef-repo/LICENSE] action create_if_missing
– create new file /root/chef-repo/LICENSE
– update content in file /root/chef-repo/LICENSE from none to f750c0
(diff output suppressed by config)
* cookbook_file[/root/chef-repo/.chef-repo.txt] action create_if_missing
– create new file /root/chef-repo/.chef-repo.txt
– update content in file /root/chef-repo/.chef-repo.txt from none to 2bed28
(diff output suppressed by config)
* cookbook_file[/root/chef-repo/README.md] action create_if_missing
– create new file /root/chef-repo/README.md
– update content in file /root/chef-repo/README.md from none to 2b4f46
(diff output suppressed by config)
* cookbook_file[/root/chef-repo/chefignore] action create_if_missing
– create new file /root/chef-repo/chefignore
– update content in file /root/chef-repo/chefignore from none to f728e0
(diff output suppressed by config)
* remote_directory[/root/chef-repo/cookbooks] action create_if_missing
– create new directory /root/chef-repo/cookbooks
Recipe:
* directory[/root/chef-repo/cookbooks/example] action create
– create new directory /root/chef-repo/cookbooks/example
– change mode from ” to ‘0755’
– change owner from ” to ‘root’
– change group from ” to ‘root’
* cookbook_file[/root/chef-repo/cookbooks/example/README.md] action create_if_missing
– create new file /root/chef-repo/cookbooks/example/README.md
– update content in file /root/chef-repo/cookbooks/example/README.md from none to d11a1f
(diff output suppressed by config)
– change mode from ” to ‘0644’
* cookbook_file[/root/chef-repo/cookbooks/example/metadata.rb] action create_if_missing
– create new file /root/chef-repo/cookbooks/example/metadata.rb
– update content in file /root/chef-repo/cookbooks/example/metadata.rb from none to f0778c
(diff output suppressed by config)
– change mode from ” to ‘0644’
* directory[/root/chef-repo/cookbooks/example/attributes] action create
– create new directory /root/chef-repo/cookbooks/example/attributes
– change mode from ” to ‘0755’
– change owner from ” to ‘root’
– change group from ” to ‘root’
* cookbook_file[/root/chef-repo/cookbooks/example/attributes/default.rb] action create_if_missing
– create new file /root/chef-repo/cookbooks/example/attributes/default.rb
– update content in file /root/chef-repo/cookbooks/example/attributes/default.rb from none to 16a397
(diff output suppressed by config)
– change mode from ” to ‘0644’
* directory[/root/chef-repo/cookbooks/example/recipes] action create
– create new directory /root/chef-repo/cookbooks/example/recipes
– change mode from ” to ‘0755’
– change owner from ” to ‘root’
– change group from ” to ‘root’
* cookbook_file[/root/chef-repo/cookbooks/example/recipes/default.rb] action create_if_missing
– create new file /root/chef-repo/cookbooks/example/recipes/default.rb
– update content in file /root/chef-repo/cookbooks/example/recipes/default.rb from none to 8c5dc6
(diff output suppressed by config)
– change mode from ” to ‘0644’

Recipe: code_generator::repo
* remote_directory[/root/chef-repo/data_bags] action create_if_missing
– create new directory /root/chef-repo/data_bags
Recipe:
* cookbook_file[/root/chef-repo/data_bags/README.md] action create_if_missing
– create new file /root/chef-repo/data_bags/README.md
– update content in file /root/chef-repo/data_bags/README.md from none to 9bb9c0
(diff output suppressed by config)
– change mode from ” to ‘0644’
* directory[/root/chef-repo/data_bags/example] action create
– create new directory /root/chef-repo/data_bags/example
– change mode from ” to ‘0755’
– change owner from ” to ‘root’
– change group from ” to ‘root’
* cookbook_file[/root/chef-repo/data_bags/example/example_item.json] action create_if_missing
– create new file /root/chef-repo/data_bags/example/example_item.json
– update content in file /root/chef-repo/data_bags/example/example_item.json from none to 1048ec
(diff output suppressed by config)
– change mode from ” to ‘0644’

Recipe: code_generator::repo
* remote_directory[/root/chef-repo/roles] action create_if_missing
– create new directory /root/chef-repo/roles
Recipe:
* cookbook_file[/root/chef-repo/roles/README.md] action create_if_missing
– create new file /root/chef-repo/roles/README.md
– update content in file /root/chef-repo/roles/README.md from none to c36187
(diff output suppressed by config)
– change mode from ” to ‘0644’
* cookbook_file[/root/chef-repo/roles/example.json] action create_if_missing
– create new file /root/chef-repo/roles/example.json
– update content in file /root/chef-repo/roles/example.json from none to 297ea8
(diff output suppressed by config)
– change mode from ” to ‘0644’

Recipe: code_generator::repo
* remote_directory[/root/chef-repo/environments] action create_if_missing
– create new directory /root/chef-repo/environments
Recipe:
* cookbook_file[/root/chef-repo/environments/README.md] action create_if_missing
– create new file /root/chef-repo/environments/README.md
– update content in file /root/chef-repo/environments/README.md from none to c9ccdf
(diff output suppressed by config)
– change mode from ” to ‘0644’
* cookbook_file[/root/chef-repo/environments/example.json] action create_if_missing
– create new file /root/chef-repo/environments/example.json
– update content in file /root/chef-repo/environments/example.json from none to 59a963
(diff output suppressed by config)
– change mode from ” to ‘0644’

Recipe: code_generator::repo
* cookbook_file[/root/chef-repo/cookbooks/README.md] action create_if_missing
– create new file /root/chef-repo/cookbooks/README.md
– update content in file /root/chef-repo/cookbooks/README.md from none to 86e9ef
(diff output suppressed by config)
* execute[initialize-git] action run
– execute git init .
* template[/root/chef-repo/.gitignore] action create_if_missing
– create new file /root/chef-repo/.gitignore
– update content in file /root/chef-repo/.gitignore from none to 3523c4
(diff output suppressed by config)
===================================
[root@chefworkstation ~]# ls -al ~/chef-repo/
total 28
drwxr-xr-x 7 root root 4096 Nov 18 14:26 .
dr-xr-x—. 7 root root 4096 Nov 18 14:26 ..
-rw-r–r– 1 root root 1133 Nov 18 14:26 chefignore
-rw-r–r– 1 root root 255 Nov 18 14:26 .chef-repo.txt
drwxr-xr-x 3 root root 36 Nov 18 14:26 cookbooks
drwxr-xr-x 3 root root 36 Nov 18 14:26 data_bags
drwxr-xr-x 2 root root 41 Nov 18 14:26 environments
drwxr-xr-x 7 root root 111 Nov 18 14:26 .git
-rw-r–r– 1 root root 106 Nov 18 14:26 .gitignore
-rw-r–r– 1 root root 70 Nov 18 14:26 LICENSE
-rw-r–r– 1 root root 1499 Nov 18 14:26 README.md
drwxr-xr-x 2 root root 41 Nov 18 14:26 roles

[root@chefworkstation ~]# git config –global user.name “admin”

[root@chefworkstation ~]# git config –global user.email “mohammedrafi494@gmail.com”

[root@chefworkstation ~]# cd ~/chef-repo/

[root@chefworkstation chef-repo]#

[root@chefworkstation chef-repo]# git init
Reinitialized existing Git repository in /root/chef-repo/.git/

[root@chefworkstation chef-repo]# mkdir -p ~/chef-repo/.chef

[root@chefworkstation chef-repo]# echo ‘.chef’ >> ~/chef-repo/.gitignore

[root@chefworkstation chef-repo]# cd ~/chef-repo/

[root@chefworkstation chef-repo]# git add .

[root@chefworkstation chef-repo]# git commit -m “initial commit”
[master (root-commit) a8ba070] initial commit
16 files changed, 351 insertions(+)
create mode 100644 .chef-repo.txt
create mode 100644 .gitignore
create mode 100644 LICENSE
create mode 100644 README.md
create mode 100644 chefignore
create mode 100644 cookbooks/README.md
create mode 100644 cookbooks/example/README.md
create mode 100644 cookbooks/example/attributes/default.rb
create mode 100644 cookbooks/example/metadata.rb
create mode 100644 cookbooks/example/recipes/default.rb
create mode 100644 data_bags/README.md
create mode 100644 data_bags/example/example_item.json
create mode 100644 environments/README.md
create mode 100644 environments/example.json
create mode 100644 roles/README.md
create mode 100644 roles/example.json
[root@chefworkstation chef-repo]# git status
# On branch master
nothing to commit, working directory clean

[root@chefworkstation ~]# scp -pr root@148.72.244.143:/etc/chef/admin.pem ~/chef-repo/.chef/
The authenticity of host ‘148.72.244.143 (148.72.244.143)’ can’t be established.
ECDSA key fingerprint is 38:cc:b0:c3:37:c2:53:f3:52:97:bd:0c:82:d8:a6:97.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘148.72.244.143’ (ECDSA) to the list of known hosts.
root@148.72.244.143’s password:
admin.pem 100% 1678 1.6KB/s 00:00
root@chefworkstation ~]# scp -pr root@148.72.244.143:/etc/chef/itrules-validator.pem ~/chef-repo/.chef/
root@148.72.244.143’s password:
itrules-validator.pem 100% 1678 1.6KB/s 00:01

[root@chefworkstation ~]# vim ~/chef-repo/.chef/knife.rb
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name “admin”
client_key “#{current_dir}/admin.pem”
validation_client_name “itrules-validator”
validation_key “#{current_dir}/itzrules-validator.pem”
chef_server_url “https://chefserver.linuxmadeeasy.in/organizations/itrules”
syntax_check_cache_path “#{ENV[‘HOME’]}/.chef/syntaxcache”
cookbook_path [“#{current_dir}/../cookbooks”]
[root@chefworkstation ~]# cd ~/chef-repo/

[root@chefworkstation chef-repo]# knife client list
ERROR: SSL Validation failure connecting to host: chefserver.linuxmadeeasy.in – SSL_connect returned=1 errno=0 state=error: certificate verify failed
ERROR: Could not establish a secure connection to the server.
Use `knife ssl check` to troubleshoot your SSL configuration.
If your Chef Server uses a self-signed certificate, you can use
`knife ssl fetch` to make knife trust the server’s certificates.

Original Exception: OpenSSL::SSL::SSLError: SSL Error connecting to https://chefserver.linuxmadeeasy.in/organizations/itrules/clients – SSL_connect returned=1 errno=0 state=error: certificate verify failed

[root@chefworkstation chef-repo]# knife ssl fetch
WARNING: Certificates from chefserver.linuxmadeeasy.in will be fetched and placed in your trusted_cert
directory (/root/chef-repo/.chef/trusted_certs).

Knife has no means to verify these are the correct certificates. You should
verify the authenticity of these certificates after downloading.

Adding certificate for chefserver.linuxmadeeasy.in in /root/chef-repo/.chef/trusted_certs/chefserver_linuxmadeeasy_in.crt

[root@chefworkstation chef-repo]# knife client list
itrules-validator

server2

[root@chefworkstation chef-repo]# knife bootstrap chefclient.linuxmadeeasy.in –ssh-user root –ssh-password Ind*963. –node-name chefclient.linuxmadeeasy.in
Creating new client for chefclient.linuxmadeeasy.in
Creating new node for chefclient.linuxmadeeasy.in
Connecting to chefclient.linuxmadeeasy.in
chefclient.linuxmadeeasy.in —–> Installing Chef Omnibus (-v 12)
chefclient.linuxmadeeasy.in downloading https://omnitruck-direct.chef.io/chef/install.sh
chefclient.linuxmadeeasy.in to file /tmp/install.sh.9517/install.sh
chefclient.linuxmadeeasy.in trying wget…
chefclient.linuxmadeeasy.in el 7 x86_64
chefclient.linuxmadeeasy.in Getting information for chef stable 12 for el…
chefclient.linuxmadeeasy.in downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=12&p=el&pv=7&m=x86_64
chefclient.linuxmadeeasy.in to file /tmp/install.sh.9526/metadata.txt
chefclient.linuxmadeeasy.in trying wget…
chefclient.linuxmadeeasy.in sha1 ee2d523b7a3dbd0599e69c68626193351c78f21f
chefclient.linuxmadeeasy.in sha256 4adf75a32f4b417d4c6c764ebb7a5f1c746075da3d3e9a23465ce75f2926d34e
chefclient.linuxmadeeasy.in url https://packages.chef.io/files/stable/chef/12.16.42/el/7/chef-12.16.42-1.el7.x86_64.rpm
chefclient.linuxmadeeasy.in version 12.16.42
chefclient.linuxmadeeasy.in downloaded metadata file looks valid…
chefclient.linuxmadeeasy.in downloading https://packages.chef.io/files/stable/chef/12.16.42/el/7/chef-12.16.42-1.el7.x86_64.rpm
chefclient.linuxmadeeasy.in to file /tmp/install.sh.9526/chef-12.16.42-1.el7.x86_64.rpm
chefclient.linuxmadeeasy.in trying wget…
chefclient.linuxmadeeasy.in Comparing checksum with sha256sum…
chefclient.linuxmadeeasy.in Installing chef 12
chefclient.linuxmadeeasy.in installing with rpm…
chefclient.linuxmadeeasy.in warning: /tmp/install.sh.9526/chef-12.16.42-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
chefclient.linuxmadeeasy.in Preparing… ################################# [100%]
chefclient.linuxmadeeasy.in Updating / installing…
chefclient.linuxmadeeasy.in 1:chef-12.16.42-1.el7 ################################# [100%]
chefclient.linuxmadeeasy.in Thank you for installing Chef!
chefclient.linuxmadeeasy.in Starting the first Chef Client run…
chefclient.linuxmadeeasy.in Starting Chef Client, version 12.16.42
chefclient.linuxmadeeasy.in resolving cookbooks for run list: []
chefclient.linuxmadeeasy.in Synchronizing Cookbooks:
chefclient.linuxmadeeasy.in Installing Cookbook Gems:
chefclient.linuxmadeeasy.in Compiling Cookbooks…
chefclient.linuxmadeeasy.in [2016-11-18T15:31:01-07:00] WARN: Node chefclient.linuxmadeeasy.in has an empty run list.
chefclient.linuxmadeeasy.in Converging 0 resources
chefclient.linuxmadeeasy.in
chefclient.linuxmadeeasy.in Running handlers:
chefclient.linuxmadeeasy.in Running handlers complete
chefclient.linuxmadeeasy.in Chef Client finished, 0/0 resources updated in 08 seconds
[root@chefworkstation chef-repo]# knife client list
chefclient.linuxmadeeasy.in
itrules-validator

server3server4server5

[root@chefworkstation chef-repo]# knife client show chefclient.linuxmadeeasy.in
admin: false
chef_type: client
name: chefclient.linuxmadeeasy.in
validator: false

[root@chefworkstation chef-repo]# knife node show chefclient.linuxmadeeasy.in
Node Name: chefclient.linuxmadeeasy.in
Environment: _default
FQDN: chefclient.linuxmadeeasy.in
IP: 107.180.72.87
Run List:
Roles:
Recipes:
Platform: centos 7.2.1511
Tags:

=============================
[root@chefworkstation ~]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 9500/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 9458/sendmail: acce
tcp6 0 0 :::22 :::* LISTEN 9500/sshd
[root@chefworkstation ~]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
================================
[root@chefworkstation ~]# cd chef-repo/
[root@chefworkstation chef-repo]# ll
total 12
-rw-r–r– 1 root root 1133 Nov 18 14:26 chefignore
drwxr-xr-x 3 root root 36 Nov 18 14:26 cookbooks
drwxr-xr-x 3 root root 36 Nov 18 14:26 data_bags
drwxr-xr-x 2 root root 41 Nov 18 14:26 environments
-rw-r–r– 1 root root 70 Nov 18 14:26 LICENSE
-rw-r–r– 1 root root 1499 Nov 18 14:26 README.md
drwxr-xr-x 2 root root 41 Nov 18 14:26 roles
[root@chefworkstation chef-repo]#

================================================================
[root@chefworkstation chef-repo]# vim hello.rb
package ‘httpd’
service ‘httpd’ do
action [:enable, :start]
end

file ‘/var/www/html/index.html’ do
content ‘Welcome to Apache in Chef’
end

workstation1.png

================================================================
[root@chefworkstation chef-repo]# chef-apply hello.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* yum_package[httpd] action install
– install version 2.4.6-40.el7.centos.4 of package httpd
* service[httpd] action enable
– enable service service[httpd]
* service[httpd] action start
– start service service[httpd]
* file[/var/www/html/index.html] action create
– create new file /var/www/html/index.html
– update content in file /var/www/html/index.html from none to 152204
— /var/www/html/index.html 2016-11-18 15:48:04.750000000 -0700
+++ /var/www/html/.chef-index20161118-20301-15r3atx.html 2016-11-18 15:48:04.749000000 -0700
@@ -1 +1,2 @@
+Welcome to Apache in Chef
================================================================
[root@chefworkstation chef-repo]# service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2016-11-18 15:48:04 MST; 1min 46s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 20663 (httpd)
Status: “Total requests: 2; Current requests/sec: 0; Current traffic: 0 B/sec”
CGroup: /system.slice/httpd.service
├─20663 /usr/sbin/httpd -DFOREGROUND
├─20664 /usr/sbin/httpd -DFOREGROUND
├─20665 /usr/sbin/httpd -DFOREGROUND
├─20666 /usr/sbin/httpd -DFOREGROUND
├─20667 /usr/sbin/httpd -DFOREGROUND
├─20668 /usr/sbin/httpd -DFOREGROUND
└─20673 /usr/sbin/httpd -DFOREGROUND

Nov 18 15:48:04 chefworkstation.linuxmadeeasy.in systemd[1]: Starting The Apache HTTP Server…
Nov 18 15:48:04 chefworkstation.linuxmadeeasy.in systemd[1]: Started The Apache HTTP Server.

[root@chefworkstation chef-repo]# netstat -tlpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 9500/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 9458/sendmail: acce
tcp6 0 0 :::80 :::* LISTEN 20663/httpd
tcp6 0 0 :::22 :::* LISTEN 9500/sshd
============================================================
[root@chefworkstation chef-repo]# cd cookbooks/

[root@chefworkstation cookbooks]# ll
total 4
drwxr-xr-x 4 root root 71 Nov 18 14:26 example
-rw-r–r– 1 root root 3147 Nov 18 14:26 README.md
============================================================
[root@chefworkstation cookbooks]# chef generate cookbook httpd_deploy
Generating cookbook httpd_deploy
– Ensuring correct cookbook file content
– Ensuring delivery configuration
– Ensuring correct delivery build cookbook content

Your cookbook is ready. Type `cd httpd_deploy` 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.

Why not start by writing a test? Tests for the default recipe are stored at:

test/recipes/default_test.rb

If you’d prefer to dive right in, the default recipe can be found at:

recipes/default.rb
============================================================
[root@chefworkstation cookbooks]# tree
.
|– example
| |– attributes
| | `– default.rb
| |– metadata.rb
| |– README.md
| `– recipes
| `– default.rb
|– httpd_deploy
| |– Berksfile
| |– chefignore
| |– metadata.rb
| |– README.md
| |– recipes
| | `– default.rb
| |– spec
| | |– spec_helper.rb
| | `– unit
| | `– recipes
| | `– default_spec.rb
| `– test
| `– recipes
| `– default_test.rb
`– README.md

10 directories, 13 files
================================================================
This is the file structure of the created cookbook, let’s see the use of these files/folders inside the cookbook one by one.

Berksfile : It is the configuration file, which mainly tells BerkShelf what are the cookbook’s dependencies, which can be specified directly inside this file or indirectly through metadata.rb. It also tells Berkshelf where it should look for those dependencies.

Chefignore : It tells Chef which all files should be ignored while uploading a cookbook to the Chef server.

metadata.rb : It contains meta information about you cookbook, such as name, contacts or description. It can also state the cookbook’s dependencies.

README.md : It contains documentation entry point for the repo.

Recipes : Contains the cookbook’s recipes. It starts with executing the file default.rb.

default.rb : The default recipe format.

specs : It will be storing the unit test cases of your libraries.

test : It will be storing the unit test cases of your recipes.
=================================================================
[root@chefworkstation cookbooks]# chef generate template httpd_deploy index.html
Recipe: code_generator::template
* directory[./httpd_deploy/templates/default] action create
– create new directory ./httpd_deploy/templates/default
* template[./httpd_deploy/templates/index.html.erb] action create
– create new file ./httpd_deploy/templates/index.html.erb
– update content in file ./httpd_deploy/templates/index.html.erb from none to e3b0c4
(diff output suppressed by config)
=====================================================================
[root@chefworkstation cookbooks]# tree
.
|– example
| |– attributes
| | `– default.rb
| |– metadata.rb
| |– README.md
| `– recipes
| `– default.rb
|– httpd_deploy
| |– Berksfile
| |– chefignore
| |– metadata.rb
| |– README.md
| |– recipes
| | `– default.rb
| |– spec
| | |– spec_helper.rb
| | `– unit
| | `– recipes
| | `– default_spec.rb
| |– templates
| | |– default
| | `– index.html.erb
| `– test
| `– recipes
| `– default_test.rb
`– README.md

12 directories, 14 files
===========================================
[root@chefworkstation cookbooks]# cat httpd_deploy/templates/index.html.erb

[root@chefworkstation cookbooks]# echo “Welcome to Chef Apache Deployment” >> httpd_deploy/templates/index.html.erb

[root@chefworkstation cookbooks]# cat httpd_deploy/templates/index.html.erb
Welcome to Chef Apache Deployment

[root@chefworkstation cookbooks]# cd httpd_deploy/recipes/
[root@chefworkstation recipes]# pwd
/root/chef-repo/cookbooks/httpd_deploy/recipes
====================================================
[root@chefworkstation recipes]# cat default.rb
#
# Cookbook Name:: httpd_deploy
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.
============================================================
[root@chefworkstation recipes]# vim default.rb
#
# Cookbook Name:: httpd_deploy
# Recipe:: default
#
# Copyright (c) 2016 The Authors, All Rights Reserved.

package ‘httpd’
service ‘httpd’ do
action [:enable, :start]
end

template ‘/var/www/html/index.html’ do
source ‘index.html.erb’
end
============================================================
[root@chefworkstation recipes]# chef-client –local-mode –runlist ‘recipe[httpd_deploy]’
[2016-11-18T16:03:47-07:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /root/chef-repo
One version per cookbook

[2016-11-18T16:03:47-07:00] INFO: Forking chef instance to converge…
Starting Chef Client, version 12.15.19
[2016-11-18T16:03:47-07:00] INFO: *** Chef 12.15.19 ***
[2016-11-18T16:03:47-07:00] INFO: Platform: x86_64-linux
[2016-11-18T16:03:47-07:00] INFO: Chef-client pid: 20812
[2016-11-18T16:03:50-07:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/nodes/admin
[2016-11-18T16:03:50-07:00] INFO: Setting the run_list to [#] from CLI options
[2016-11-18T16:03:50-07:00] INFO: Run List is

]
[2016-11-18T16:03:50-07:00] INFO: Run List expands to [httpd_deploy]
[2016-11-18T16:03:50-07:00] INFO: Starting Chef Run for admin
[2016-11-18T16:03:50-07:00] INFO: Running start handlers
[2016-11-18T16:03:50-07:00] INFO: Start handlers complete.
[2016-11-18T16:03:50-07:00] INFO: HTTP Request Returned 404 Not Found: Object not found:
resolving cookbooks for run list: [“httpd_deploy”]
[2016-11-18T16:03:50-07:00] INFO: Loading cookbooks [httpd_deploy@0.1.0]
Synchronizing Cookbooks:
[2016-11-18T16:03:50-07:00] INFO: Storing updated cookbooks/httpd_deploy/templates/index.html.erb in the cache.
[2016-11-18T16:03:50-07:00] INFO: Storing updated cookbooks/httpd_deploy/metadata.rb in the cache.
[2016-11-18T16:03:50-07:00] INFO: Storing updated cookbooks/httpd_deploy/recipes/default.rb in the cache.
[2016-11-18T16:03:50-07:00] INFO: Storing updated cookbooks/httpd_deploy/chefignore in the cache.
[2016-11-18T16:03:50-07:00] INFO: Storing updated cookbooks/httpd_deploy/README.md in the cache.
– httpd_deploy (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks…
Converging 3 resources
Recipe: httpd_deploy::default
* yum_package[httpd] action install[2016-11-18T16:03:50-07:00] INFO: Processing yum_package[httpd] action install (httpd_deploy::default line 7)
(up to date)
* service[httpd] action enable[2016-11-18T16:03:53-07:00] INFO: Processing service[httpd] action enable (httpd_deploy::default line 8)
(up to date)
* service[httpd] action start[2016-11-18T16:03:53-07:00] INFO: Processing service[httpd] action start (httpd_deploy::default line 8)
(up to date)
* template[/var/www/html/index.html] action create[2016-11-18T16:03:53-07:00] INFO: Processing template[/var/www/html/index.html] action create (httpd_deploy::default line 12)
[2016-11-18T16:03:53-07:00] INFO: template[/var/www/html/index.html] backed up to /root/chef-repo/.chef/local-mode-cache/backup/var/www/html/index.html.chef-20161118160353.795965
[2016-11-18T16:03:53-07:00] INFO: template[/var/www/html/index.html] updated file contents /var/www/html/index.html

– update content in file /var/www/html/index.html from 152204 to 748cbd
— /var/www/html/index.html 2016-11-18 15:48:04.749000000 -0700
+++ /var/www/html/.chef-index20161118-20812-i5u404.html 2016-11-18 16:03:53.793000000 -0700
@@ -1,2 +1,2 @@
-Welcome to Apache in Chef
+Welcome to Chef Apache Deployment
[2016-11-18T16:03:53-07:00] INFO: Chef Run complete in 3.351769476 seconds

Running handlers:
[2016-11-18T16:03:53-07:00] INFO: Running report handlers
Running handlers complete
[2016-11-18T16:03:53-07:00] INFO: Report handlers complete
Chef Client finished, 1/4 resources updated in 06 seconds
=====================================================================

workstation2.png

server6

[root@chefworkstation recipes]# pwd
/root/chef-repo/cookbooks/httpd_deploy/recipes
[root@chefworkstation recipes]# cd ../..
[root@chefworkstation cookbooks]# ls -l
total 8
drwxr-xr-x 4 root root 71 Nov 18 14:26 example
drwxr-xr-x 7 root root 4096 Nov 18 15:56 httpd_deploy
-rw-r–r– 1 root root 3147 Nov 18 14:26 README.md
=====================
[root@chefworkstation cookbooks]# knife cookbook upload learn_chef_httpd
ERROR: Could not find cookbook learn_chef_httpd in your cookbook path, skipping it
Uploaded 0 cookbook.
[root@chefworkstation ~]# chef-client
[2016-11-18T16:17:06-07:00] WARN: *****************************************
[2016-11-18T16:17:06-07:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2016-11-18T16:17:06-07:00] WARN: *****************************************
Starting Chef Client, version 12.15.19
Creating a new client identity for chefworkstation.linuxmadeeasy.in using the validator key.

================================================================================
Chef encountered an error attempting to create the client “chefworkstation.linuxmadeeasy.in”
================================================================================

Platform:
———
x86_64-linux
Running handlers:
[2016-11-18T16:17:09-07:00] ERROR: Running exception handlers
Running handlers complete
[2016-11-18T16:17:09-07:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 02 seconds
[2016-11-18T16:17:09-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-11-18T16:17:09-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-11-18T16:17:09-07:00] ERROR: I can’t write your private key to /etc/chef/client.pem – check permissions?
[2016-11-18T16:17:09-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

=======================================================
[root@chefworkstation chef-repo]# knife bootstrap chefworkstation.linuxmadeeasy.in –ssh-user root –ssh-password Ind*963. –node-name chefworkstation.linuxmadeeasy.in
Creating new client for chefworkstation.linuxmadeeasy.in
Creating new node for chefworkstation.linuxmadeeasy.in
Connecting to chefworkstation.linuxmadeeasy.in
chefworkstation.linuxmadeeasy.in —–> Existing Chef installation detected
chefworkstation.linuxmadeeasy.in Starting the first Chef Client run…
chefworkstation.linuxmadeeasy.in Starting Chef Client, version 12.15.19
chefworkstation.linuxmadeeasy.in resolving cookbooks for run list: []
chefworkstation.linuxmadeeasy.in Synchronizing Cookbooks:
chefworkstation.linuxmadeeasy.in Installing Cookbook Gems:
chefworkstation.linuxmadeeasy.in Compiling Cookbooks…
chefworkstation.linuxmadeeasy.in [2016-11-18T16:25:52-07:00] WARN: Node chefworkstation.linuxmadeeasy.in has an empty run list.
chefworkstation.linuxmadeeasy.in Converging 0 resources
chefworkstation.linuxmadeeasy.in
chefworkstation.linuxmadeeasy.in Running handlers:
chefworkstation.linuxmadeeasy.in Running handlers complete
chefworkstation.linuxmadeeasy.in Chef Client finished, 0/0 resources updated in 08 seconds
[root@chefworkstation chef-repo]# knife node list
chefclient.linuxmadeeasy.in
chefworkstation.linuxmadeeasy.in
[root@chefworkstation chef-repo]# chef-client
Starting Chef Client, version 12.15.19
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks…
[2016-11-18T16:27:40-07:00] WARN: Node chefworkstation.linuxmadeeasy.in has an empty run list.
Converging 0 resources

Running handlers:
Running handlers complete
Chef Client finished, 0/0 resources updated in 08 seconds
[root@chefworkstation chef-repo]# knife cookbook upload –all
Uploading example [1.0.0]
Uploading httpd_deploy [0.1.0]
ERROR: The data in your request was invalid
Response: Field ‘metadata.maintainer’ invalid

==========================================================

107.180.72.87 chefclient.linuxmadeeasy.in

[root@chefclient ~]# chef-client
Starting Chef Client, version 12.16.42
resolving cookbooks for run list: []
Synchronizing Cookbooks:
Installing Cookbook Gems:
Compiling Cookbooks…
[2016-11-18T16:16:30-07:00] WARN: Node chefclient.linuxmadeeasy.in has an empty run list.
Converging 0 resources

Running handlers:
Running handlers complete
Chef Client finished, 0/0 resources updated in 08 seconds

=======================================

[root@chefworkstation chef-repo]# knife node run_list add chefclient.linuxmadeeasy.in “recipe[http_deploy]”
chefclient.linuxmadeeasy.in:
run_list: recipe[http_deploy]

=============================================

[root@chefclient ~]# chef-client
Starting Chef Client, version 12.16.42
resolving cookbooks for run list: [“http_deploy”]

==========================================================================
Error Resolving Cookbooks for Run List:
==========================================================================

Missing Cookbooks:
——————
The following cookbooks are required by the client but don’t exist on the server:
* http_deploy
Expanded Run List:
——————
* http_deploy

Platform:
———
x86_64-linux
Running handlers:
[2016-11-18T16:52:21-07:00] ERROR: Running exception handlers
Running handlers complete
[2016-11-18T16:52:21-07:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 06 seconds
[2016-11-18T16:52:21-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-11-18T16:52:21-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-11-18T16:52:21-07:00] ERROR: 412 “Precondition Failed”
[2016-11-18T16:52:22-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Screenshot from 2016-11-19 05:23:42.png

[root@chefworkstation chef-repo]# knife node list
chefclient.linuxmadeeasy.in
chefworkstation.linuxmadeeasy.in
[root@chefworkstation chef-repo]# knife node delete chefclient.linuxmadeeasy.in
Do you really want to delete chefclient.linuxmadeeasy.in? (Y/N) y
Deleted node[chefclient.linuxmadeeasy.in]
[root@chefworkstation chef-repo]# knife node list
chefworkstation.linuxmadeeasy.in
[root@chefworkstation chef-repo]# knife client delete chefclient.linuxmadeeasy.in
Do you really want to delete chefclient.linuxmadeeasy.in? (Y/N) y
Deleted client[chefclient.linuxmadeeasy.in]
[root@chefworkstation chef-repo]# knife node list
chefworkstation.linuxmadeeasy.in
[root@chefworkstation chef-repo]# knife client list
chefworkstation.linuxmadeeasy.in
itrules-validator

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s