Puppet - 安装和配置r10K

在Puppet中,我们有一个名为r10k的代码管理工具,它有助于管理与我们可以在Puppet中配置的不同类型环境相关的环境配置,例如开发,测试和生产.这有助于在源代码存储库中存储与环境相关的配置.使用源代码控制repo分支,r10k使用repo中存在的模块在Puppet主机安装和更新环境中创建环境.

Gem文件可用于在任何机器上安装r10k但模块化为了获得最新版本,我们将使用rpm和rpm包管理器.以下是相同的示例.

 
 $ urlgrabber -o/etc/yum.repos.d/timhughes-r10k-epel-6. repo 
 https://copr.fedoraproject.org/coprs/timhughes/yum -y install rubygem-r10k

在/etc/中配置环境puppet/puppet.conf

 
 [main] 
 environmentpath = $ confdir/environments

为r10k配置创建配置文件

cat <<EOF >/etc/r10k.yaml 
# The location to use for storing cached Git repos 
:cachedir: '/var/cache/r10k' 
# A list of git repositories to create 
:sources: 
# This will clone the git repository and instantiate an environment per 
# branch in /etc/puppet/environments 
:opstree: 
#remote: 'https://img01.yuandaxia.cn/Content/img/tutorials/puppet/fullstackpuppet-environment' 
remote: '/var/lib/git/fullstackpuppet-environment.git' 
basedir: '/etc/puppet/environments' 
EOF

安装Puppet Manifest和Module

r10k deploy environment -pv

由于我们需要每15分钟继续更新一次环境,我们将为此创建一个cron作业相同.

cat << EOF > /etc/cron.d/r10k.conf 
SHELL = /bin/bash 
PATH = /sbin:/bin:/usr/sbin:/usr/bin 
H/15 * * * * root r10k deploy environment -p 
EOF

测试安装

为了测试是否一切工作为接受,需要编译Puppet模块的Puppet清单.运行以下命令并获得YAML输出作为结果.

curl --cert /etc/puppet/ssl/certs/puppet.corp.guest.pem \ 
--key /etc/puppet/ssl/private_keys/puppet.corp.guest.pem \ 
--cacert /etc/puppet/ssl/ca/ca_crt.pem \ 
-H 'Accept: yaml' \ 
https://puppet.corp.guest:8140/production/catalog/puppet.corp.guest