Lin Hong's TECH Blog! 刀不磨要生锈,人不学习要落后 - Thinking ahead

[原创]Chef Client 注册client

2016-05-24

怎样用Knife注册追加一个node为chef client?

Knife注册追加一个node为chef client

knife bootstrap chefclient -x chefnodeadmin -P password –sudo

chefclient:client名(一般是用IP地址)

chefnodeadmin(client的用户)

password (client的用户的密码)

sudo (sudo追加)

Case 01: knife bootstratp’s wrong password

chefworkstation

[root@workstation chef-repo]# knife bootstrap chefclient -x chefnodeadmin -P zaq12wsx --sudo
Doing old-style registration with the validation key at /root/chef-repo/.chef/1stchef-validator.pem...
Delete your validation key in order to use your user credentials instead

Connecting to chefclient
chefnodeadmin@chefclient's password: 
chefnodeadmin@chefclient's password: 
chefclient knife sudo password: 
Enter your password: 
chefclient 
chefclient Sorry, try again.
chefclient knife sudo password: 
chefclient 
chefclient Sorry, try again.
chefclient knife sudo password: 
chefclient 
chefclient Sorry, try again.
chefclient sudo: 3 incorrect password attempts
[root@workstation chef-repo]# 

a.ssh connect’s password

b.sudo id’s password(if wrong password, try 3 times)

case 02: client’s id has not sudoer priviledge.

chefclient

[root@chefclient ~]# id chefnodeadmin
uid=1060(chefnodeadmin) gid=100(users) groups=100(users)
[root@chefclient ~]# grep chefnodeadmin /etc/sudoers
chefnodeadmin	ALL=(ALL) 	ALL
[root@chefclient ~]# ls -ltr /etc/sudoers
-r--r-----. 1 root root 4238 May 25 12:14 /etc/sudoers
[root@chefclient ~]# chmod 755 /etc/sudoers
[root@chefclient ~]# vi /etc/sudoers
[root@chefclient ~]# chmod 440 /etc/sudoers
[root@chefclient ~]# grep chefnodeadmin /etc/sudoers
#chefnodeadmin	ALL=(ALL) 	ALL
[root@chefclient ~]# 
[root@chefclient ~]# ls -ltr /etc/sudoers
-r--r-----. 1 root root 4239 May 25 12:18 /etc/sudoers
[root@chefclient ~]# 

chefworkstation

[root@workstation chef-repo]# knife bootstrap chefclient -x chefnodeadmin -P zaq12wsx --sudo
Doing old-style registration with the validation key at /root/chef-repo/.chef/1stchef-validator.pem...
Delete your validation key in order to use your user credentials instead

Connecting to chefclient
chefclient knife sudo password: 
Enter your password: 
chefclient 
chefclient chefnodeadmin is not in the sudoers file.  This incident will be reported.
[root@workstation chef-repo]# 

case 03:

chefclient:

[root@chefclient ~]# ls -ltr /etc/sudoers
-r--r-----. 1 root root 4239 May 25 12:18 /etc/sudoers
[root@chefclient ~]# grep chefnodeadmin /etc/sudoers
#chefnodeadmin	ALL=(ALL) 	ALL
[root@chefclient ~]# chmod 755 /etc/sudoers
[root@chefclient ~]# vi /etc/sudoers
[root@chefclient ~]# grep chefnodeadmin /etc/sudoers
chefnodeadmin	ALL=(ALL) 	ALL
[root@chefclient ~]# chmod 440 /etc/sudoers
[root@chefclient ~]# ls -ltr /etc/sudoers
-r--r-----. 1 root root 4238 May 25 12:23 /etc/sudoers
[root@chefclient ~]# 
[root@chefclient ~]# rpm -qa | grep -i chef
chef-12.9.41-1.el7.x86_64
[root@chefclient ~]# rpm -e chef-12.9.41-1.el7.x86_64
[root@chefclient ~]# rpm -qa | grep -i chef
[root@chefclient ~]# 

chefworkstation:

[root@workstation chef-repo]# knife bootstrap chefclient -x chefnodeadmin -P xsw23edc --sudo
Doing old-style registration with the validation key at /root/chef-repo/.chef/1stchef-validator.pem...
Delete your validation key in order to use your user credentials instead

Connecting to chefclient
chefclient knife sudo password: 
Enter your password: 
chefclient 
chefclient -----> Installing Chef Omnibus (-v 12)
chefclient downloading https://omnitruck-direct.chef.io/chef/install.sh
chefclient   to file /tmp/install.sh.4997/install.sh
chefclient trying curl...
chefclient el 7 x86_64
chefclient Getting information for chef stable 12 for el...
chefclient downloading https://omnitruck-direct.chef.io/stable/chef/metadata?v=12&p=el&pv=7&m=x86_64
chefclient   to file /tmp/install.sh.5003/metadata.txt
chefclient trying curl...
chefclient sha1	4def83368a1349959fdaf0633c4d288d5ae229ce
chefclient sha256	6f00c7bdf96a3fb09494e51cd44f4c2e5696accd356fc6dc1175d49ad06fa39f
chefclient url	https://packages.chef.io/stable/el/7/chef-12.10.24-1.el7.x86_64.rpm
chefclient version	12.10.24
chefclient downloaded metadata file looks valid...
chefclient downloading https://packages.chef.io/stable/el/7/chef-12.10.24-1.el7.x86_64.rpm
chefclient   to file /tmp/install.sh.5003/chef-12.10.24-1.el7.x86_64.rpm
chefclient trying curl...
chefclient Comparing checksum with sha256sum...
chefclient Installing chef 12
chefclient installing with rpm...
chefclient warning: /tmp/install.sh.5003/chef-12.10.24-1.el7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 83ef826a: NOKEY
chefclient Preparing...                          ################################# [100%]
chefclient Updating / installing...
chefclient    1:chef-12.10.24-1.el7              ################################# [100%]
chefclient Thank you for installing Chef!
chefclient Starting the first Chef Client run...
chefclient Starting Chef Client, version 12.10.24
chefclient resolving cookbooks for run list: []
chefclient Synchronizing Cookbooks:
chefclient Installing Cookbook Gems:
chefclient Compiling Cookbooks...
chefclient [2016-05-25T12:33:44-04:00] WARN: Node chefclient has an empty run list.
chefclient Converging 0 resources
chefclient 
chefclient Running handlers:
chefclient Running handlers complete
chefclient Chef Client finished, 0/0 resources updated in 02 seconds
[root@workstation chef-repo]# 

a.it will download&install the chef client’s package if there is NOT chef client in client.



Comments