CentOS7 puppet安装教程
环境:CentOS 7.3两台
准备工作:
- 因为puppet基于证书验证,保证两台主机的时间相差在1min以内,所以开启NTP服务。
timedatectl set-ntp true
- 设置主机名
hostnamectl set-hostname master #服务端 hostnamectl set-hostname slave #客户端
同时修改/etc/hosts文件如下:
cat /etc/hosts 127.0.0.1 localhost localhost.localdomain master ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 1.1.1.1 master 2.2.2.2 slave
修改/etc/sysconfig/network
cat /etc/sysconfig/network HOSTNAME=master #服务端 # HOSTNAME=slave 客户端
- 关闭filewall,设置selinux等级为0
systemctl stop filewall setenfoce 0
开始安装
1.由于puppet在yum中没有puppet源,所以需要下载相应的扩展rpm包。
wget https://yum.puppetlabs.com/el/7/products/x86_64/puppetlabs-release-7-10.noarch.rpm
rpm -ivh puppetlabs-release-7-10.noarch.rpm
yum -y update
2.安装puppet以及相关组件
yum -y install factor ruby puppet-server #服务端
yum -y install factor ruby puppet #客户端
3.客户端配置
修改/etc/puppet/puppet.conf
cat /etc/puppet/puppet.conf #添加下面三行
certname = slave
server = master
report = true
4.启动puppet
systemctl start puppet puppetmaster #服务端
systemctl start puppet #客户端
5.测试
在客户端测试:
puppet agent --server=master --verbose --no-daemonize --debug
结果为:Notice: Starting Puppet client version 3.8.7 则成功
6.在服务端允许slave证书
puppet cert list --all #前面没加+号的说明还没认证
puppet cert sign slave #认证客户端
7.测试用例
vim /etc/puppet/manifests/site.pp # 在服务端编写
node default {
file { "/tmp/helloworld.txt" :
content => "Hello World!",
}
}
# 客户端
puppet agent --test
提示为:(成功)
本文转自守护我们的幸福 51CTO博客,原文链接:http://blog.51cto.com/12085228/2048288
,如需转载请自行联系原作者