puppet 权威指南

img_4e6f00c5f7630483d600df14926bdc2d.png
image.png

puppet硬件需求


img_be7b653f7673ab94ed759e02613f4483.png
image.png

搭建本地镜像源
搭建svn+apache ,搭建dnsmasq

/etc/puppet
auth.conf 认证
autosign.conf 自动签名
fileserver.conf 同步静态文件
manifests.......module
puppet.conf
tagmail.conf
namespaceauth.conf

puppet.conf main,master,agent


img_5830b9c48e32675bfbc98cc7c0525707.png
image.png

img_13ea53540e7179683e72a1f547df2cdf.png
image.png

img_36a273a4687691ccadfee108791a8c60.png
image.png

img_9e28bee0ba226494f8b5586c10135b45.png
image.png

img_33a0cb0bfb02f762757effa0a5eeb3c3.png
image.png

生成配置文件puppet.conf puppet master --genconfig
服务端常用配置项


img_b9bcbdfb3710f8818c4ab83696ce533e.png
image.png

auth.conf访问控制


img_5507043d63c4e520a5ee0dcc0baff354.png
image.png

img_bd55a51c3596af2c61fb467e9a7c298b.png
image.png

img_5d1619cd93ef039b69e58c63d32d6f9c.png
image.png

img_d1892d10618f8b07e8abdf917cd3f5c6.png
image.png

acl控制


img_02ee2491e31b4fe35e08e5d6d705e44b.png
image.png

fileserver.conf 挂载点 使用方式


img_c6db02722557726c24572d7005e3f3ac.png
image.png

img_db0aabcc53c305f382f98416fbad50fb.png
image.png

puppet help puppet help ca
puppet master puppet agent puppet cert puppet module puppet resource puppet describe puppet parser validate


site.pp是导航文件:/etc/puppet/manifests/site.pp
notify == echo:notify{"hello world"} 放在site.pp
启动服务端: xx 2>&1
nohup puppet master --verbose --no-daemonize>>master.log 2>&1 &
iptables -t filter -A INPUT -p tcp -m state -state NEW --dport 8140 -j ACCEPT
puppet agent --server xxxx --test
puppet cert --sign xxxx

site.pp中节点格式


img_1503d87a6cf55d608aea602f9857c54c.png
image.png

img_3c4ff44d72d5fda1a070bcf8cb676dfd.png
image.png

img_d69a682524f81dbd56be87604c778c6f.png
image.png

img_ac4af4b8a31c3b49ad4ceb769c16037e.png
image.png

img_9000855c1ef9ed5c43ca1dfe4ae96c09.png
image.png

没有匹配到,就到默认default


img_87fccd51a710a63cd1905bcc5da88b40.png
image.png

从puppet forge 获取基础模块:http://forge.puppetlabs.com/
class

img_467350b70da7248e79790df3424ad363.png
image.png

img_a517fa7d5b74172ed3b09b63e3354432.png
image.png

inherits
img_3aee92ee0604839cc208c509e2b0890a.png
image.png

类继承
img_c865b21cb00ce094bc24bc502178a376.png
image.png

灰度发布:开发-测试-生产


img_a8406ecd8ce41bd0dc6d7166592e6a2d.png
image.png

变量


img_0dcf2d64a55bd0bd25a035a23762f7af.png
image.png

img_4ab01e3d8b9fcb35ed59f680d53a0381.png
image.png

puppet不能重复赋值


img_289bc5a8afb34a45465f5b9f608f8864.png
image.png

facter常用变量:ipaddress,kernel,memorysize,operatingsystem,rubyversion,uptime,hostname


img_6982f14840f36bdf17d2b43f0b4613c0.png
image.png

数组


img_f05d10cd4afe949976e07fe0613f0557.png
image.png

img_6096664488f68a36b006954553abb330.png
image.png

img_f9fd9c4d775da23f55806f17c3c5739c.png
image.png

img_eee0e2161d92eef78ab2f0929abf721e.png
image.png

字典


img_24d8c5238118ebd85aa9438e14babf69.png
image.png

布尔
img_19c18dfebdd6205ecc27b1fc020ab31e.png
image.png

/正则/:[a-z] () \w \W \s \S \d \D \b \B * + {m,n} ?
img_9c4bee8dd45642296a5c455e3aa30e63.png
image.png

img_42ea735c9c948c184528e68ca9a40153.png
image.png

if elsif else

img_fb7fcec73d9eceab0912e1fcb0f29ce0.png
image.png

=~
img_6238ccfc3f68cfd0033da7795e41333b.png
image.png

in
img_9b5ebd5171095cfbda008a2f82f9116f.png
image.png

case 用法:
case
operatingsystem { 'Solaris': { include role::solaris } 'RedHat','CentOS': { include role::redhat } /^(Debian|Ubuntu)
/:{}
default: {}
}
xx = xx ? {字典}
img_8cbee2b00cba8bca42414bdf3cbc307c.png
image.png

define


img_ab67e6b0db83ae8412ab4f5e08a15e5f.png
image.png

img_fac8800f2399e5e00419546dbc70a6f5.png
image.png

tag????


img_31b9bc9f978009bc860b41aab6a582e5.png
image.png

img_70adb19bb01ccf5b940fca42412d1890.png
image.png

generate
img_edcdec0f4cc4b4b9da59e5dde9293c14.png
image.png

template


img_9f5114cac715409b47ef7a3c41ec71a6.png
image.png

类的继承
img_7fe3522fc9494d05c1f87a3fd0de9811.png
image.png

文件导入
img_e98ef551604140d6c769c8326348acfe.png
image.png

模块导入方式:
img_c4ffa696281612dca3fc261401a75489.png
image.png

资源
img_c3d78d4b683ac5fe3d87bdf31c73d148.png
image.png

package 包安装工具

file {'name':
path:
ensure:absent present file directory link
backup:
checksum:md5
content:追加
group
links??
mode
owner
source:
target:
selxxxxxxxxxxxxxxxx
}


img_892a507b315d32fa3b86739d0101cf51.png
image.png

img_5b85e0b66504a4b3dbc1e15bef6858a0.png
image.png

filebucket 文件备份与恢复
name,path,port,server


img_a5542abc17a6378261323a05943cdb3e.png
image.png

host:DNS相关


img_596a08922f80bd413d200e7217d98f35.png
image.png

img_f9f3684ac88ea5f486a1db5abb28e240.png
image.png

user属性
name,ensure,comment,uid,gid,groups,home,manage_expiry,password,manage_password_max_age,manage_password_min_age,shell,provider:aix/hpuxuseradd/ldap/pw/useradd/windows_adsi
新建用户

img_97f445fe90392f0061482e772272799f.png
image.png

group
ensure,gid,members,name,provider:aix/groupadd/pw/windows_adsi
img_2f24e794a8f30830c08067e6e7845c3e.png
image.png

package
allowcdrom,ensure:installed present/absent/latest/版本号5.4.23,provider:yum/apt/aix/windows,source
holdable保持现状,install_options 传递参数,installable,purgeable,uninstall_options,uninstallable,upgradeable,versionable
img_fd450647f4dc5c9dd408de4592875e51.png
image.png

安装nginx
img_6e9893675e094c24859fee7cfcdb82f8.png
image.png

数组方式批量安装
img_49715b96154f2c807efb6efd27e4dc7e.png
image.png

service:
binary:程序路径,enable开机,ensure:running/stopped,hasrestart,hasstatus,name,path,pattern,restart,start,status,stop,provider:enableable/refreshable.


img_2e568f4ff61b94b0c78382b2b1efe092.png
image.png

exec:
command,creates,cwd:执行路径,environment,group,logoutput,onlyif:只有该执行结果为0时才执行,path,refresh,refreshonly:ture/false触发器,returns,timeout,tries,try_sleep,user,provider:shell/windows


img_e8b6e52525868a08ab86cae0d3c29bfb.png
image.png

cron:
command,ensure:present/absent,environment,hour,minute,month,monthday,weekday,name,provider,user


img_60547beb7f33bcf51b22c1f5a22ec1e9.png
image.png

notify :name,message
公有属性:before,require,stage,notify,subscribe,audit
require用法


img_9440c01fccd43f64cdd9199c0e2d5eef.png
image.png

before


img_7f4b7aa56fec91b154f847d94b6e7b43.png
image.png

notify
img_c92ec48b83377b232259d4cbe695f1b5.png
image.png

subscribe
img_8f91488627d0da10b615d17e70e41729.png
image.png

->先后关系


img_bfb81c1443608aeb79200ee79c59bd21.png
image.png

~>通知
img_d7abd55b8615cf210bb9abe0664fa432.png
image.png

三段
img_cd6c7744c5cbb2119efa1493d3104e13.png
image.png

img_080c688b468bd4e1eacf65836807a158.png
image.png

img_8254e3684aa48dda894edd045e9ec99d.png
image.png

audit审计
img_54024c9e8705c8f36f8ff70663139267.png
image.png

默认资源:Exec,Package,
虚拟资源:@ realize <|xxx|>
img_c1ab8bc6c2cf4520032e9ccee3ae1835.png
image.png

erb <%= %>


img_1a36eced777a752e9bdd3d0a6791e1ac.png
image.png

img_494e3802e14577ef529814fecf918725.png
image.png

img_1c27683bf7372ed3c88e60f094e0fcb6.png
image.png

erb
<% if %>
<% elsif %>
<% else %>
<% end %>
erb each ????? erb 函数


facter:physicalprocessorcount,processorcount,processor0-7,memorysize,memoryfree,swapsize,swapfree
获取内存信息:


img_fca682b98b0dcc1136cc11c174f851f0.png
image.png

facter:interfaces,ipaddress,netmask,ipaddress_eth1,netmask_eth1~~,macaddress
operatingsystem,operatingsystemrelease


img_45aade896a0e17987f91d57b31e463d9.png
image.png

facter:kernel,kernelmajversion,kernelrelease,kernelversion,selinux,selinux_config_mode,
扩展facter
img_5e33a4be15b4567fb5b6b0043757802b.png
image.png

YAML


img_4919ecf5a840253f855b15100795691d.png
image.png

puppet ENC功能
puppet dot graphviz功能
puppet stdlib扩展


master和agent多端口使用案例


img_3c7a08f46feec8af5b5709b55e15949d.png
image.png
img_9bd4e047f70114cfe465847a10caa365.png
image.png

img_32fbca9d5fcaac749965175d2ed4a003.png
image.png

img_420d5de12fee1b66d169591380c30da7.png
image.png

img_ebaec13614a63f179e0e9c44480ebf89.png
image.png

nginx+passenger 提升master的处理性能
puppet搭建集群:http://jingpin.jikexueyuan.com/article/48475.html


reportdir设置运行报告目录
[agent]
report=true

reportserver=

puppet agent --server puppet.xxxx.com --test --summarize
[master]
reports=store,tagmail,http #开启多个报告处理器
reportfrom=xxx
tagmap=xx/tagmail.conf


img_1f95d6c6256ecc9a6ec89dcb7a12e3df.png
image.png

自定义报告处理器

puppet dashboard 安装
puppetdb 安装
puppet MCollective 安装


img_513ba3916e55629c12874bbc53b4a543.png
image.png

puppet 部署 MCollective


img_d13a40d4845edf9b3e7dec2299c317ed.png
image.png

img_83b6fe2d0f8149afe569a90df5e5f36b.png
image.png

HAproxy 搭建puppet 集群

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值