Puppet之master_agent模型

来源:互联网 发布:unity3d itweenpath 编辑:程序博客网 时间:2024/05/23 16:51

Puppet之master_agent模型

Master安装:获取:    puppet-server-3.8.7-1.el7.noarch.rpm、    puppet-3.8.7-1.el7.noarch.rpm、    facter-2.4.6-1.el7.x86_64.rpm使用yum工具安装以上程序包。Agent安装:    puppet-3.8.7-1.el7.noarch.rpm、    facter-2.4.6-1.el7.x86_64.rpm使用yum工具安装以上程序包。这里使用一个master,两个agent,模型搭建前准备hosts文件,三台服务器/etc/hosts均要添加一下内容,生产环境中需要使用DNS服务器来解析
172.16.250.119 node1.magedu.com node1172.16.250.209 node2.magedu.com node2172.16.251.3 master.magedu.com master
Master:启动服务:systemctl start puppetmaster首次启动服务可以使用puppet master --no-daemonize –verbose 来查看CA操作流程Agent:启动服务:首次启动服务可以使用puppet agent –server master.magedu.com --no-daemonize –verbose 来查看CA请求流程在master主机上使用:puppet cert list可列出ca签证请求,使用puppet cert sign –all为所有签证请求签发证书,master端管理证书签署:puppet cert <action> [--all] [<host>]       action:            list :            sign:            revoke:撤销            clean:吊销指定的客户端的证书,并删除与其相关的所有文件;使用puppet cert list –all 列出所有。前面有+符号的代表已签证书cat /var/log/puppet/masterhttp.log可查看详细流程。证书签署完成后,master需要提供主机清单/etc/puppet/manifests/site.pp如下:
node 'node1.magedu.com' {    include nginx}node 'node2.magedu.com' {    include mariadb}
Node模式:        node 'base' {            include ntp         }        node 'HOSTNAME' {            ...puppet code...        }        node /PATTERN/ {            ...puppet code...        } node /PATTERN/ :node /node[0-9]+\.magedu\.com/注意:node内也可以编写资源清单,只是不能被其它agent复用而已。节点间可实现继承,这里不描述。清单配置信息可模块化组织:    databases.d/    tomcatservers.d/    nodes.d/:可通过多个pp文件分别定义各类站点的清单;而后统一导入site.pp,方法如下:    site.pp文件使用中如下配置:           import 'nodes/*.pp'多环境配置:    默认环境是production;puppet 3.4 之前的版本配置多环境的方法: 各环境配置:/etc/puppet/environments/{production,development,testing}
puppet.conf    [master]    environments = production, development, testing    [production]    modulepath=/etc/puppet/environments/production/modules/ manifest=/etc/puppet/environments/production/manifests/site.pp    [development]    modulepath=/etc/puppet/environments/development/modules/    manifest=/etc/puppet/environments/development/manifests/site.pp     [testing]    modulepath=/etc/puppet/environments/testing/modules/    manifest=/etc/puppet/environments/testing/manifests/site.pp 
puppet 3.6之后的版本配置多环境的方法:master端: (1) 配置文件puppet.conf    [master]    environmentpath = $confdir/environments #$confdir默认/etc/puppet (2) 在多环境配置目录下为每个环境准备一个子目录    ENVIRONMENT_NAME/        manifests/            site.pp        modules/在master端把environmentpath配置好,在配置好的目录下新建production, development, testing目录,在对应的目录下编写对应的资源清单提供配置文件,配置模版等。编写模式与master/agent模型的master资源清单及模块相同。agent端:/etc/puppet/puppet.conf
[agent]    environment = { production|development | testing }#指明当前agent环境
在agent端把environment配置好,production 或development 或 testing选一种配置环境,启动服务后,agent跟去master请求对应的环境配置资源清单,因为在生产,开发,测试三种环境中配置从而达到方便应用生产,开发,测试。
原创粉丝点击