本文共 5737 字,大约阅读时间需要 19 分钟。
零基础学习Puppet自动化配置管理系列文档
注意:本实验是在离线情况下安装的,所以需要在本地创建自己的yum仓库,创建方法可参考《》,如何你实在是比较懒或者搞不定rpm包之间的依赖关系,那就去我的github上下载吧:
更多安装细节请参考官网:
以下all-in-one安装方式跟官方安装的有所区别,官方安装可能只需要一条命令就可以安装成功,在我测试下来发现会出现有时候成功,有时候不 成功的现象,所以改成了以下方式安装,而且每次都能成功,条例也比较清晰,为后面拆分puppetmaster能够提供很好的帮助。
puppet-server 3.6.2
puppet 3.6.2
facter 2.0.2
mcollective 2.2.4
rabbitmq-server 3.2.4
foreman 1.5.3
foreman-proxy 1.5.4
系统版本:
[root@foreman02 yum.repos.d]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.5 (Santiago)
网络参数:
[root@foreman02 yum.repos.d]# ip addr1: lo:mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:50:56:a6:5c:70 brd ff:ff:ff:ff:ff:ff inet 192.168.10.159/24 brd 192.168.10.255 scope global eth0 inet6 fe80::250:56ff:fea6:5c70/64 scope link valid_lft forever preferred_lft forever
主机名称:
[root@foreman02 yum.repos.d]# hostname -fforeman02.kisspuppet.com[root@foreman02 yum.repos.d]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.10.159 foreman02.kisspuppet.com foreman02
平台环境:
[root@foreman02 yum.repos.d]# uname -r2.6.32-431.el6.x86_64
yum仓库:
[root@foreman02 yum.repos.d]# cat foreman153.repo [foreman]name=Foremanbaseurl=ftp://192.168.10.254/blog/foremanenabled=1gpgcheck=0[puppet]name=puppetbaseurl=ftp://192.168.10.254/blog/puppet-el6enabled=1gpgcheck=0[rhel]name=RHELbaseurl=ftp://192.168.10.254/rhel6.5enabled=1gpgcheck=0
网络安全环境:
[root@foreman02 ~]# /etc/init.d/iptables statusiptables: Firewall is not running.[root@foreman02 ~]# getenforce Disabled
3.1、安装puppetmaster,并生成CA和证书
[root@foreman02 ~]# yum install foreman-installer[root@foreman02 ~]# yum install puppet-server puppet facter[root@foreman02 ~]# vim /etc/puppet/puppet.conf[master] certname = foreman02.kisspuppet.com[root@foreman02 ~]# /etc/init.d/puppetmaster startStarting puppetmaster: [ OK ][root@foreman02 ~]# puppet cert --list --all+ "foreman02.kisspuppet.com" (SHA256) 1D:7E:90:F5:16:7D:01:67:77:37:EE:31:3F:46:AD:0A:47:80:B6:DF:6A:5E:25:A8:DE:BA:78:45:C9:09:D6:BD (alt names: "DNS:foreman02.kisspuppet.com", "DNS:puppet", "DNS:puppet.kisspuppet.com")[root@foreman02 ~]# /etc/init.d/puppetmaster stopStopping puppetmaster: [ OK ]
3.2、安装foreman及依赖包
[root@foreman02 ~]# yum install foreman mod_passenger mod_ssl ruby193-rubygem-passenger-native mysql mysql-server foreman-mysql2
3.3、通过foreman-installer安装foreman
foreman默认安装选择的数据库为postgresql,这里选用mysql进行安装。
[root@foreman02 ~]# foreman-installer --foreman-db-adapter mysql2 --foreman-db-type mysql --no-enable-puppet --no-enable-foreman-proxy --foreman-configure-epel-repo=falseInstalling Done [100%] [...................] Success! * Foreman is running at https://foreman02.kisspuppet.com Default credentials are 'admin:changeme' The full log is at /var/log/foreman-installer/foreman-installer.log
安装完成之后,通过火狐或者谷歌浏览器访问看是否安装成功
3.4、安装foreman-proxy及依赖包
[root@foreman02 ~]# yum install tftp-server syslinux foreman-proxy
3.5、安装foreman-proxy,并通过foreman-installer重新安装foreman和puppetmaster
注意:以下方式是安装后会代理TFTP, DNS, DHCP, Puppet, and Puppet CA,并且puppetmaster会以apache+passenger的方式安装运行。
[root@foreman02 ~]# foreman-installer --enable-foreman --enable-foreman-proxy --enable-puppet --puppet-server=true --foreman-proxy-puppetrun=true --foreman-proxy-puppetca=true --foreman-proxy-dhcp=true --foreman-proxy-tftp=true --foreman-proxy-dns=true --foreman-proxy-dns-interface=eth0 --foreman-proxy-dns-zone=kisspuppet.com --foreman-proxy-dns-reverse=10.168.192.in-addr.arpa --foreman-proxy-dns-forwarders=8.8.8.8 --foreman-proxy-dns-forwarders=8.8.4.4 --foreman-configure-epel-repo=false --foreman-proxy-register-in-foreman=false Installing Done [100%] [...................] Success! * Foreman is running at https://foreman02.kisspuppet.com Default credentials are 'admin:changeme' * Foreman Proxy is running at https://foreman02.kisspuppet.com:8443 * Puppetmaster is running at port 8140 The full log is at /var/log/foreman-installer/foreman-installer.log
如果只代理puppet和puppetCA,可以通过以下方式安装
[root@foreman02 ~]# foreman-installer --enable-foreman --enable-foreman-proxy --enable-puppet --puppet-server=true --foreman-proxy-puppetrun=true --foreman-proxy-puppetca=true --foreman-configure-epel-repo=false --foreman-proxy-register-in-foreman=false
[root@foreman02 ~]# /etc/init.d/httpd statushttpd (pid 25433) is running...[root@foreman02 ~]# /etc/init.d/foreman-proxy statusforeman-proxy (pid 25605) is running...[root@foreman02 ~]# netstat -naltp | grep 8443tcp 0 0 0.0.0.0:8443 0.0.0.0:* LISTEN 25605/ruby [root@foreman02 ~]# netstat -naltp | grep 80tcp 0 0 :::80 :::* LISTEN 25433/httpd [root@foreman02 ~]# netstat -naltp | grep 8140tcp 0 0 :::8140 :::* LISTEN 25433/httpd
如果要管理puppet、puppetca等软件,是需要通过foreman-proxy去代理才能够正常使用的,关于代理的开启和关闭可以修改它的配置文件/etc/foreman-proxy/settings.yml