部署环境
Linux 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3 (2019-09-02) x86_64 GNU/Linux
设备
master 192.168.1.131 host3.super.org
client1 192.168.1.134 host6.super.org
client2 192.168.1.147 host13.super.org
--master 下载安装
apt update
apt-get install puppet -y
apt-get install puppetmaster -y
--client 下载安装
apt-get install puppet -y
--master
systemctl start puppetmaster.service
netstat -nlp |grep 8140
tcp 0 0 0.0.0.0:8140 0.0.0.0:* LISTEN 100268/rub
--client
puppet agent --server host3.super.org -v --no-daemonize
--master
查看证书
puppet cert list
推送证书
puppet cert sign --all
查看
root@host3:/etc/puppet/code/environments/production# ls /var/lib/puppet/ssl/ca/signed/ -al
total 32
drwxr-xr-x 2 puppet puppet 4096 Dec 31 10:23 .
drwxr-xr-x 5 puppet puppet 4096 Dec 30 10:59 ..
-rw-r--r-- 1 puppet puppet 1956 Dec 30 14:43 host13.super.org.pem
-rw-r--r-- 1 puppet puppet 2004 Dec 30 10:59 host3.super.org.pem
-rw-r--r-- 1 puppet puppet 1956 Dec 30 14:24 host6.super.org.pem
配置nginx测试
--master
正常你的目录层级 应该是 /etc/puppet/code/environments/production/
root@host3:/etc/puppet/code/environments/production# cat manifests/site.pp
node 'host6.super.org'{
include nginx::nginx_web
}
node 'host13.super.org'{
include nginx::nginx_web
}
root@host3:/etc/puppet/code/environments/production/modules# mkdir -pv nginx/{manifests,files,lib,templates,tests,spec}
root@host3:/etc/puppet/code/environments/production/modules# cat nginx/manifests/init.pp
class nginx {
package {'nginx':
ensure => installed,
}
}
root@host3:/etc/puppet/code/environments/production/modules# cat nginx/manifests/nginx_web.pp
class nginx::nginx_web inherits nginx {
file {'/etc/nginx/nginx.conf':
ensure => file,
source => 'puppet:///modules/nginx/nginx-web.conf',
mode => '0644',
owner => 'root',
group => 'root',
notify => Service['nginx'],
require => Package['nginx'],
}
service {'nginx':
ensure => running,
}
}
root@host3:/etc/puppet/code/environments/production/modules# cp /etc/nginx/nginx.conf /usr/share/puppet/modules/nginx/files/nginx-web.conf
root@host3:/etc/puppet/code/environments/production/modules# service puppetmaster restart
--client
root@host6:~# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for host15.super.org
Info: Applying configuration version '1577762968'
Notice: /Stage[main]/Nginx/Package[nginx]/ensure: created
Notice: Applied catalog in 5.35 seconds
root@host6:~# ps aux|grep nginx
root 5927 0.0 0.0 159536 1640 ? Ss 11:29 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 5928 0.0 0.0 159872 3296 ? S 11:29 0:00 nginx: worker process
www-data 5929 0.0 0.0 159872 3296 ? S 11:29 0:00 nginx: worker process
www-data 5930 0.0 0.0 159872 3296 ? S 11:29 0:00 nginx: worker process
www-data 5931 0.0 0.0 159872 3296 ? S 11:29 0:00 nginx: worker process
root 5943 0.0 0.0 11108 928 pts/0 S+ 11:29 0:00 grep --color nginx