如何在CentOS 8 / RHEL 8上安装Puppet
Puppet是一个开源配置管理工具,可帮助我们自动化IT基础架构,包括配置,配置管理,从中央位置修补数百个客户端系统。
Puppet适用于Linux,Mac,BSD,Solaris和Windows操作系统。 它是用“ Ruby”语言编写的,并根据Apache许可发布,
本指南可帮助您在CentOS 8 / RHEL 8上安装Puppet。
建筑
Pupper是在代理主控体系结构中配置的。 在此体系结构中,受管节点将木偶代理软件作为后台服务运行。 另一方面,一个或多个服务器运行主应用程序,即。 木偶服务器。
人偶代理定期将事实发送到人偶主服务器并请求目录。 主节点使用其有权访问的信息源来编译并返回该特定节点的目录。
环境
在这里,我们将在服务器/代理架构中配置一个人偶。
木偶大师
主机名: puppetserver.itzgeek.local
IP地址: 192.168.0.10
操作系统: CentOS的8
client客户端
主机名: client.itzgeek.local
IP地址: 192.168.0.20
操作系统: CentOS的8
先决条件
安装NTP
主节点和客户端节点的时序应与NTP服务器准确同步,因为Puppet服务器将充当证书颁发机构。
如果您需要设置NTP服务器,则:
读: 如何使用Chrony配置NTP服务器
如果您需要设置NTP客户端,则:
读: 如何使用Chrony配置NTP客户端
如果需要,也可以更改系统时区。
读:如何在CentOS 8 / RHEL 8中更改时区
域名解析
Puppet代理使用主机名与Puppet服务器通信。 因此,请确保代理节点可以在/ etc / hosts文件或DNS服务器的帮助下解析Puppet服务器的主机名。
安装和配置Puppet服务器
Puppet Server是在主节点上运行的服务器软件。 Puppet服务器控制受管节点(puppet-agent)的配置。
添加存储库
要安装Puppet服务器,我们需要通过安装存储库配置软件包来添加Puppet存储库。
rpm -Uvh https://yum.puppet.com/puppet6-release-el-8.noarch.rpm
安装人偶
使用以下命令安装Puppet服务器。
yum install -y puppetserver
内存分配
默认情况下,Puppet Server配置为使用2GB内存。 您可以根据连接到它的节点数来更改内存分配。
对于此演示,我将分配512MB的内存。
要更改内存分配的值,请编辑以下文件。
vi /etc/sysconfig/puppetserver
更改值。
从:
JAVA_ARGS="-Xms2g -Xmx2g -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
至:
对于512MB,请使用以下设置。
JAVA_ARGS="-Xms512m -Xmx512m -Djruby.logger.class=com.puppetlabs.jruby_utils.jruby.Slf4jLogger"
配置人偶服务器
人偶的配置文件由两个部分组成,这些部分名为 [master] 和 [main] 分别用于Pupper服务器和代理。
vi /etc/puppetlabs/puppet/puppet.conf
根据您的环境修改文件。 Pupper代理可以使用dns_alt_names中提到的任何主机名与Pupper服务器连接。
# Pupper Server Configuration [master] dns_alt_names = puppetserver,puppetserver.itzgeek.local # Puppet Agent Configuration [main] certname = puppetserver.itzgeek.local server = puppetserver.itzgeek.local runinterval = 30m
启动Puppet服务器
生成Puppet服务器的根和中间签名CA。
puppetserver ca setup
Output: Generation succeeded. Find your files in /etc/puppetlabs/puppet/ssl/ca
如果未找到puppetserver:命令,请在终端中运行源/etc/profile.d/puppet-agent.sh或从当前会话注销并重新登录。
启动并启用Puppet服务器。
systemctl start puppetserver
systemctl enable puppetserver
防火墙功能
Puppet服务器侦听端口8140。因此,请配置防火墙,以使代理可以连接到主服务器。
firewall-cmd --permanent --add-port=8140/tcp
firewall-cmd --reload
安装和配置Puppet代理
添加存储库
要安装Puppet代理,我们需要在所有节点上添加puppet存储库。
rpm -Uvh https://yum.puppet.com/puppet6-release-el-8.noarch.rpm
安装代理
使用以下命令在您的客户端上安装人偶代理。
dnf install -y puppet-agent
编辑人偶配置文件并设置人偶服务器信息。
根据您的Puppet服务器主机名设置服务器值。 在我的情况下,服务器是puppetserver.itzgeek.local,而certname是我的客户端主机名(client.itzgeek.local)。
vi /etc/puppetlabs/puppet/puppet.conf
设置如下。
[main] server = puppetserver.itzgeek.local certname = client.itzgeek.local runinterval = 30m
您可以根据需要更改runinterval的值。 此设置控制代理在两个目录请求之间等待的时间。 您可以以秒(10或10s),分钟(10m)和小时(1h)设置值。
在节点上启动人偶代理,并使其在系统引导时自动启动。
puppet resource service puppet ensure=running enable=true
Output: Notice: /Service[puppet]/ensure: ensure changed 'stopped' to 'running' service { 'puppet': ensure => 'running', enable => 'true', provider => 'systemd', }
如果找到puppet:命令,请在终端中运行源/etc/profile.d/puppet-agent.sh或从当前会话中注销并重新登录。
在主服务器上签署代理节点证书
我们必须批准来自每个节点的证书请求。 代理节点尝试运行时将首次请求证书。
在代理节点上运行以下命令以建立初始连接。 您可以忽略警告/错误。
puppet agent -t
登录到Pupper服务器并运行以下命令以查看未解决的请求。
puppetserver ca list
Output: Requested Certificates: client.itzgeek.local (SHA256) 06:D8:8E:AE:CA:0B:B1:E7:90:B5:B9:1B:75:3C:95:69:D8:EF:27:0A:5D:CC:45:BB:15:34:64:D2:6B:2C:CA:98
运行puppet cert sign命令对请求进行签名。
puppetserver ca sign --certname client.itzgeek.local
Output: Successfully signed certificate request for client.itzgeek.local
Puppet服务器现在可以与客户端计算机通信并控制该节点。
如果您有来自节点的多个签名请求,则可以在一个命令中对所有请求进行签名。
puppetserver ca sign --all
有时,您可能需要吊销特定节点的证书以将其读回。
将
puppetserver ca revoke --certname AGENT_NAME
您可以使用以下命令列出所有已签名和未签名的请求。
puppetserver ca list --all
Output: Signed Certificates: puppetserver.itzgeek.local (SHA256) E6:2C:6C:1E:9B:C6:AA:D9:84:09:F3:67:45:1B:36:C6:1F:FB:46:5F:92:64:37:19:E3:74:0C:0D:29:D5:C5:F6 alt names: ["DNS:puppetserver.itzgeek.local", "DNS:puppetserver", "DNS:puppetserver.itzgeek.local"] authorization extensions: [pp_cli_auth: true] client.itzgeek.local (SHA256) EF:D8:1A:F2:E9:56:A3:1F:DA:A9:8D:9B:71:02:D8:52:F1:44:98:92:A7:5F:DE:FC:5F:55:37:97:EC:9C:9A:96
验证Puppet客户端
Puppet服务器签署了您的客户端证书后,请在客户端计算机上运行以下命令进行测试。
puppet agent --test
Output: Info: Using configured environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Retrieving locales Info: Caching catalog for client.itzgeek.local Info: Applying configuration version '1591351483' Notice: Applied catalog in 0.01 seconds
结论
是啊我希望您已经学会了如何在CentOS 8 / RHEL 8上安装Puppet。作为进一步的阅读,请学习如何创建一个简单的清单文件来在客户端节点上创建文件和目录。 请在评论部分分享您的反馈。