目的
在 el7 服务器上安装 puppet server 5 版本
额外的软件下载地址
wget http://hcc-mirror.unl.edu/puppetlabs/puppet5/el/7/x86_64/puppetserver-5.3.9-1.el7.noarch.rpm
wget http://hcc-mirror.unl.edu/puppetlabs/puppet5/el/7/x86_64/puppet-agent-5.5.8-1.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/updates/x86_64/Packages/copy-jdk-configs-3.3-11.el7_9.noarch.rpm
wget http://mirror.centos.org/centos/7/updates/x86_64/Packages/java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64.rpm
wget http://mirror.centos.org/centos/7/updates/x86_64/Packages/tzdata-java-2022g-1.el7.noarch.rpm
puppetserver install
centos7 只需要可以访问最新 7.9.2009 updates 软件源
yum install -y copy-jdk-configs cups-libs jpackage-utils lksctp-tools pcsc-lite-libs tzdata-java
rpm -ivh puppetserver-5.3.9-1.el7.noarch.rpm puppet-agent-5.5.8-1.el7.x86_64.rpm
server config
调整 jdk size
/etc/sysconfig/puppetserver
JAVA_ARGS="-Xms6g -Xmx6g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
顺手更新一下 ruby 版本
JRUBY_JAR="/opt/puppetlabs/server/apps/puppetserver/jruby-9k.jar"
添加 auto sign
/etc/puppetlabs/puppetserver/conf.d/autosign.conf
*.vclound.com
添加服务器地址
/etc/puppetlabs/puppet/puppet.conf
[master]
vardir = /opt/puppetlabs/server/data/puppetserver
logdir = /var/log/puppetlabs/puppetserver
rundir = /var/run/puppetlabs/puppetserver
pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid
codedir = /etc/puppetlabs/code
server = puppet5-uq2pu.vclound.com
server startup
systemctl restart puppetserver
# systemctl status puppetserver
puppetserver.service - puppetserver Service
Loaded: loaded (/usr/lib/systemd/system/puppetserver.service; disabled)
Active: active (running) since 三 2024-01-03 02:31:41 UTC; 38min ago
Process: 11255 ExecStop=/opt/puppetlabs/server/apps/puppetserver/bin/puppetserver stop (code=exited, status=0/SUCCESS)
Process: 11270 ExecStart=/opt/puppetlabs/server/apps/puppetserver/bin/puppetserver start (code=exited, status=0/SUCCESS)
Main PID: 11277 (java)
CGroup: /system.slice/puppetserver.service
└─11277 /usr/bin/java -Xms6g -Xmx6g .... <-- 验证一下内存分配
验证一下服务端口
# netstat -ntl | grep 8140
tcp6 0 0 :::8140 :::* LISTEN
测试模板
随便来个文件测试一下
/etc/puppetlabs/code/environments/production/manifests/node/test.pp
node 'tsdb-zxjzd.vclound.com' {
file { '/tmp/abc':
ensure => file,
mode => '0644',
owner => root,
group => root,
content => "add",
}
}
客户端执行
参考上述方法安装 puppet-agent
参考上述方法配置服务器 (server = puppet5-uq2pu.vclound.com)
客户端测试运行
测试 puppet
# /opt/puppetlabs/bin/puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Caching catalog for tsdb-zxjzd.vclound.com
Info: Applying configuration version '1704250370'
Notice: /Stage[main]/Main/Node[tsdb-zxjzd.vclound.com]/File[/tmp/abc]/ensure: defined content as '{md5}34ec78fcc91ffb1e54cd85e4a0924332'
Info: Creating state file /opt/puppetlabs/puppet/cache/state/state.yaml
Notice: Applied catalog in 0.02 seconds
执行 puppet
# /opt/puppetlabs/bin/puppet agent
验收文件
# cat /tmp/abc
add