博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自动化运维工具安装部署 chef (九)- 重温安装
阅读量:7000 次
发布时间:2019-06-27

本文共 2959 字,大约阅读时间需要 9 分钟。

周五配置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

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

去官网找下载链接

下载chef server

wget

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

速度感人,15k,4小时

跑到workstation和node,下workstation和dk

wget

wget

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

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

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

chef-server-ctl reconfigure

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

chef-server-ctl status

创建管理员私钥

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

安装管理组件

chef-server-ctl install chef-manage

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

chef-server-ctl reconfigure

chef-server-ctl reconfigure --accept-license

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

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

chef-manage-ctl reconfigure

访问下 ,ui正常了

工作站安装workstation

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

看样子是少一个组件

yum search libxss

yum install libXScrnSaver

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

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

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

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

source ~/.bash_profile

验证ruby 位置路径和版本

which ruby

ruby -v

从webui下载start kit

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

unzip chef-starter.zip

安装下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

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

knife ssl check

生成ssl证书

knife ssl fetch

列客户端

knife client list

node 安装dk

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

看下版本chef-client -v

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

mkdir -pv /etc/chef

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

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

knife ssl fetch

knife ssl check

knife bootstrap 192.168.10.142 -N chefnode

knife node list

节点已经在库存中了

workstation也加一下

knife bootstrap 192.168.10.141 -N chefworkstation

webui 两台都已经出现了

安装完成

转载地址:http://ojevl.baihongyu.com/

你可能感兴趣的文章