自动化运维工具安装部署 chef (九)- 重温安装

周五配置chef workstation遇到了些问题,不得已百度了下,结果发现自己之前写的博客被别人抄的七七八八,结果照着配还不行,索性重新做个试验再写一篇温故一下

服务器列表

cat <<EOF >>/etc/hosts

192.168.10.140 chefserver.shdr.demo chefserver

192.168.10.141 chefworkstation.shdr.demo chefworkstation

192.168.10.142 chefnode.shdr.demo chefnode

EOF

非vagarant环境请略过

-----------------------------------------------------

创建vagrant 文件

cat > Vagrantfile <<EOH

# Put the contents of this snippet in a file named Vagrantfile

Vagrant.configure(2) do |config|

config.vm.provider "virtualbox" do |v|

v.memory = 4096

v.cpus = 2

end

config.vm.box = "bento/ubuntu-16.04"

config.vm.synced_folder ".", "/opt/a2-testing", create: true

config.vm.hostname = 'chef-automate.test'

config.vm.network 'private_network', ip: '192.168.10.140'

config.vm.provision "shell", inline: "apt-get update && apt-get install -y unzip"

config.vm.provision "shell", inline: "sysctl -w vm.max_map_count=262144"

config.vm.provision "shell", inline: "sysctl -w vm.dirty_expire_centisecs=20000"

end

EOH

增加hosts中的dns 记录

echo 192.168.10.140 chefserver.shdr.demo | sudo tee -a /etc/hosts

---------------------------------------------------------

去官网找下载链接

https://downloads.chef.io/

下载chef server

wget https://packages.chef.io/files/stable/chef-server/12.18.14/el/7/chef-server-core-12.18.14-1.el7.x86_64.rpm

我靠还没有wget,我先下个wget

1ece64c3e4ff47f9b64c244d374d9625

速度感人,15k,4小时

8eb7f9d5a6f245fa82c5a1f348c06c09

跑到workstation和node,下workstation和dk

wget https://packages.chef.io/files/stable/chefdk/3.3.23/el/7/chefdk-3.3.23-1.el7.x86_64.rpm

4dd9f3c08ef14814bd570349ac44b3cf

wget https://packages.chef.io/files/stable/chef-workstation/0.2.27/el/7/chef-workstation-0.2.27-1.el6.x86_64.rpm

ef7e1141bc86451da2d1a7a3445dec8d

是不是本地网络有问题啊,找个美国主机,测试下,42m/s,我靠,我国还是发展中国家,ISP还有很长的路要走,盖屏幕睡觉

c27bc9e70bd04954badae320f056966a

一觉醒来都好了,server端安装下包

6739bb8490ad4587ac8f2d76e7d7108c

rpm -ivh chef-server-core-12.18.14-1.el7.x86_64.rpm

603f667cd7c948b692455aca440bbf75

chef-server-ctl reconfigure

f6441c292d0d4c748d4363bc0ffda148

20分钟,终于好了,看了状态

chef-server-ctl status

7e4b296ff01c48d9afdeb27867ae8ddd

创建管理员私钥

chef-server-ctl user-create admin Hao Yu pcdogyu@hotmail.com 'abcd1234' -f /etc/chef/admin.pem

141a79c0d296440cbedbd1214f589da6

安装管理组件

chef-server-ctl install chef-manage

c56d04d16d43459cb4e5077b131eb9aa

3分钟搞定,然后重新配置下

chef-server-ctl reconfigure

chef-server-ctl reconfigure --accept-license

098b03c50d044749ba85b4802af4ef0c

创建组织,公司,管理员,生成私钥

chef-server-ctl org-create shanghai 'Disney, Inc.' --association_user admin --filename /etc/chef/validator.pem

168ef0a193b74125a2be53e5a8dc9015

chef-manage-ctl reconfigure

bb5a3ac2c55644c79a22492456388dbe

访问下https://192.168.10.140 ,ui正常了

767dec5e575e4f93b8d0584c39c43f34

工作站安装workstation

rpm -ivh chef-workstation-0.2.27-1.el6.x86_64.rpm

4fda017bc8844851a57dfbab6a761611

看样子是少一个组件

yum search libxss

yum install libXScrnSaver

1a42f1124f1b45c1a97e16ea19039627

运行chef-workstation-app 验证下,还是有错误,容我修一个错误

18edaa771c874998a77be805a2c859fe

搜索了一下,看起来是ssh的显示问题,先略过

cookbook是ruby,所以要指定下ruby位置

echo 'eval "$(chef shell-init bash)"' >> ~/.bash_profile

source ~/.bash_profile

验证ruby 位置路径和版本

which ruby

ruby -v

360a85fe72ce4b5a93590f65b1e2518f

从webui下载start kit

11887e10defa4ef08c105579ee56449b

把chef-starter.zip复制到~,然后解压缩出来

unzip chef-starter.zip

612a20fd7de24d54a8d99cef2c0d3094

安装下git,把~/chef-repo作为git版本控制的初始目录

git config --global user.name "admin"

git config --global user.email "pcdogyu@hotmail.com"

cd ~/chef-repo/ && git init

mkdir -p ~/chef-repo/.chef

echo '.chef' >> ~/chef-repo/.gitignore

cd ~/chef-repo/ && git add . && git commit -m "initial commit"

git status

e7dee4d2ed074a56930bc5c4aca141fb

确保.chef目录中客户端私钥和rb存在

afcf3426c09f4fcf9991b1e399ab3aed

knife ssl check

afc88a6f53c047b3afd64b8d9c8caf8c

生成ssl证书

knife ssl fetch

列客户端

knife client list

4b4492dda66d4abaaee31f0304f826fa

node 安装dk

rpm -ivh chefdk-3.3.23-1.el7.x86_64.rpm

6a64b6cd68a5455c8006d2784ffa1825

看下版本chef-client -v

e887821b3ed9496c9119f5d8394e3eec

复制客户端私钥从server到node节点

mkdir -pv /etc/chef

scp -p root@chefserver:/etc/chef/admin.pem /etc/chef/

c247d347f4c144deb7984efcfddeebfc

生成服务器证书并且测试连接

knife ssl fetch

knife ssl check

cb437cc452cb4174b8b7b3fae2efdb2b

knife bootstrap 192.168.10.142 -N chefnode

4b0df827c6454a09bdfff21aaead7688

knife node list

c8931b6a49544204b3c0221826e0d7c4

节点已经在库存中了

7170992d214e49c38f71629ff46941be

workstation也加一下

knife bootstrap 192.168.10.141 -N chefworkstation

624da0f1368a4cf58b82b6b7390ce7ce

ba89f5b01bf34597b6f0421ecba7acdd

webui 两台都已经出现了

99f9c0c0d2a44e048e1a498c8daffc5b

安装完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值