红联Linux门户
Linux帮助

在Ubuntu上安装Chef Client 12.13.37并和Chef server关联起来

发布时间:2016-09-16 11:02:56来源:blog.csdn.net/chancein007作者:Winner1031
上一节分享了在Ubuntu上安装最新的Chef WorkStation 12.13.37(http://www.linuxdiyf.com/linux/24208.html),现在这一节给大家分享一下,Ubuntu上安装最新的Chef Client 12.13.37 并和Chef server关联起来。Client的安装相对来说简单一点。首先到下面的地址下载Ubuntu的 Chef Client最新版本,https://downloads.chef.io/chef-client/ubuntu/ 。下载完成后,假设我们在VMWare workstations里面已经安装了一台Ubunt 14的机器,2 台 Chef Client的计算机名为chef-client-01-rodney和chef-client-02-rodney, 用户名为ubuntu,IP地址为192.168.80.7和192.168.80.8,咱们文章以chef-client-01-rodney为例子,chef-client-02-rodney的步骤是一样的,则相应的安装步骤如下。
 
1.配置/etc/hosts
sudo vi /etc/hosts
在hosts文件里面,加入下面的配置
127.0.0.1 localhost localhost.example.com
192.168.80.5 chef-master-rodney.example.com chef-master-rodney
192.168.80.6 chef-workstation-rodney.example.com chef-workstation-rodney
192.168.80.7 chef-client-01-rodney.example.com chef-client-01-rodney
192.168.80.8 chef-client-02-rodney.example.com chef-client-02-rodney
 
2.在Client机器上安装chef client
sudodpkg -ichef_12.13.37-1_amd64.deb
ubuntu@chef-client-02-rodney:~/software$ sudo dpkg -i chef_12.13.37-1_amd64.deb Selecting previously unselected package chef.
(Reading database ... 51147 files and directories currently installed.)
Preparing to unpack chef_12.13.37-1_amd64.deb ...
Unpacking chef (12.13.37-1) ...
Setting up chef (12.13.37-1) ...
Thank you for installing Chef!
 
3.安装完成后,运行下面的命令 sudo chef-client -v
如果运行成功。则完成安装
ubuntu@chef-client-02-rodney:~/software$ sudo chef-client -v
Chef: 12.13.37
 
4.登陆到 chef-workstation的机器
因为我当前的客户端配置的是用私钥登陆,所以需要把chef client node的
私钥拷贝到,chef workstation机器上来
然后在,/home/ubuntu/chef-repo 目录下运行
sudo knife bootstrap chef-client-01-rodney -N chef-client-01-rodney -x ubuntu -p 22 -i .chef/keypaire4salt.pem
注意,client node的私钥 存放在,/home/ubuntu/chef-repo/.chef/keypaire4salt.pem 目录下
如果客户机器用的是,用户名和密码登陆的话,则需要用下面的命令
sudo knife bootstrap chef-client-01-rodney -N chef-client-01-rodney -x ubuntu -p 22 -P password
在我的环境里面出现了下面的错误:
ubuntu@chef-workstation-rodney:~/chef-repo$ sudo knife bootstrap chef-client-01-rodney -N chef-client-02-rodney -x ubuntu -p 22 -i .chef/keypaire4salt.pem
Creating new client for chef-client-021-rodney
Creating new node for chef-client-01-rodney
Connecting to chef-client-01-rodney
chef-client-01-rodney -----> Existing Chef installation detected
chef-client-01-rodney mkdir: cannot create directory ‘/etc/chef’: Permission denied
chef-client-01-rodney sh: 179: cannot create /etc/chef/client.pem: Directory nonexistent
chef-client-01-rodney chmod: cannot access ‘/etc/chef/client.pem’: No such file or directory
chef-client-01-rodney mkdir: cannot create directory ‘/etc/chef’: Permission denied
chef-client-01-rodney sh: 214: cannot create /etc/chef/trusted_certs/chef-master-rodney_objectiva_com.crt: Directory nonexistent
chef-client-01-rodney sh: 244: cannot create /etc/chef/client.rb: Directory nonexistent
chef-client-01-rodney sh: 253: cannot create /etc/chef/first-boot.json: Directory nonexistent
chef-client-01-rodney Starting the first Chef Client run...
chef-client-01-rodney [2016-09-15T15:27:13+00:00] WARN:*****************************************
chef-client-01-rodney [2016-09-15T15:27:13+00:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
chef-client-01-rodney [2016-09-15T15:27:13+00:00] WARN: *****************************************
chef-client-01-rodney [2016-09-15T15:27:13+00:00] FATAL: Cannot load configuration from /etc/chef/first-boot.json
这个时候,登陆到client node,然后创建/etc/chef 文件夹并把权限设置成 777
sudo mkdir -p /etc/chef
sudo chmod 777 /etc/chef
 
5.登陆到Chef server管理网站验证
然后,如果运行成功,则安装就完成了。剩下的另外一台也一样。安装完成后登陆到服务器的管理界面,则可以看到下面的图片:
在Ubuntu上安装Chef Client 12.13.37并和Chef server关联起来
 
本文永久更新地址:http://www.linuxdiyf.com/linux/24209.html