设为首页 收藏本站
查看: 1049|回复: 0

[经验分享] puppet------安装

[复制链接]

尚未签到

发表于 2018-8-2 08:50:57 | 显示全部楼层 |阅读模式
  注: puppet的安装前最好创建快照,需要细心,下面是我的安装过程
  puppet准备工作
  1 安装
  yum -y install puppet puppet-server(服务端才要装这个)
  [root@puppet puppet]# puppet -V
  2.7.26
  增加host文件解析
  最后确保不会更改服务端主机名了,并且已经做好了快照或备份还原点的准备,客户端和服务端都做,这样方便后面的解决问题
  2 初步配置
  2.1 增加配置文件
  [root@puppet ~]# tree -R /etc/puppet/
  /etc/puppet/
  ├── auth.conf
  ├── fileserver.conf
  ├── manifests
  ├── modules
  └── puppet.conf
  2 directories, 4 files
  [root@puppet puppet]# cd /etc/puppet
  [root@puppet puppet]# cat manifests/site.pp
  import "nodes/*.pp"
  2.2 服务端服务开启,客户端认证请求,服务端签发证书
  前提:selinux和防火墙至少开放8140口没问题,否则会报get addr info的错误
  [root@puppet ~]# puppet master start
  [root@puppet ~]# netstat -tnlp
  Active Internet connections (only servers)
  Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
  tcp        0      0 0.0.0.0:8140                0.0.0.0:*                   LISTEN      5167/ruby
  客户端:
  [root@cobbler ~]# puppet agent --test --verbose
  info: Creating a new SSL key for cobbler
  info: Caching certificate for ca
  info: Creating a new SSL certificate request for cobbler
  info: Certificate Request fingerprint (SHA256): 14:3E:29:3E:88:83:FE:20:93:03:0A:03:6B:F5:B6:98:2B:07:0C:D3:32:A7:A9:D7:A5:80:D9:D8:30:E0:A8:57
  Exiting; no certificate found and waitforcert is disabled
  server端查看下请求并签发:
  [root@puppet ~]# puppet cert list
  "cobbler"                      (D0:92:71:0D:B9:10:3D:28:35:D9:CE:99:7D:01:4C:3B)
  "zabbix-server" (CC:DC:03:09:B7:86:9C:90:0F:76:FF:E2:6E:E0:61:4A)
  如果出现你的hostname后面还有rev.home.ne.jp,那么去/etc/resolv.conf把search domain注释掉,把/etc/sysconfig/network-scripts/ifcfg-eth0的NM_CONTROLLED设置为no
  [root@puppet ~]# puppet cert sign "cobbler"
  notice: Signed certificate request for cobbler
  notice: Removing file Puppet::SSL::CertificateRequest cobbler at '/var/lib/puppet/ssl/ca/requests/cobbler.pem'
  最后做一个测试就行了:
  测试过程
  1 server端写一个pp文件,相当于puppet的对节点的配置文件
  [root@puppet puppet]# cat  manifests/site.pp
  node default {
  file {"/tmp/liuliancao_test.txt":
  ensure  =>  present,
  content =>  "you know.puppet is your friend.\n";
  }
  }
  #import "nodes/*.pp"
  检查一下是否有语法错误
  [root@puppet puppet]# puppet parser validate  manifests/site.pp
  2 agent请求,然后观察是否有指定的测试文件
  [root@Zabbix-Server ~]# puppet agent --test --verbose --server puppet
  info: Caching catalog for zabbix-server
  info: Applying configuration version '1455787094'
  notice: /Stage[main]//Node[default]/File[/tmp/liuliancao_test.txt]/content:
  --- /tmp/liuliancao_test.txt2016-02-18 17:16:13.646414163 +0800
  +++ /tmp/puppet-file20160218-12128-1dp2fei-02016-02-18 17:18:16.251414135 +0800
  @@ -1 +1 @@
  -you know.puppet is your friend.
  \ No newline at end of file
  +you know.puppet is your friend.
  info: FileBucket adding {md5}7364c5483d25fe12eb0912643d8c8927
  info: /Stage[main]//Node[default]/File[/tmp/liuliancao_test.txt]: Filebucketed /tmp/liuliancao_test.txt to puppet with sum 7364c5483d25fe12eb0912643d8c8927
  notice: /Stage[main]//Node[default]/File[/tmp/liuliancao_test.txt]/content: content changed '{md5}7364c5483d25fe12eb0912643d8c8927' to '{md5}aa050a17ce909e980c9e3e510a08935a'
  notice: Finished catalog run in 0.09 seconds
  [root@Zabbix-Server ~]# cat /tmp/liuliancao_test.txt
  you know.puppet is your friend.
  运行正常
  FAQ:
  由于问题比较多,所以这里总结下遇到的错误,建议写出来,可能下个月就忘了
  问题1:在输入puppet agent --test --verbose --server启动的时候,no route to host
  答:检查两端防火墙service iptables status,还有是否指定了server参数(配置文件中或者当下)
  问题2:重新申请证书,如何清理干净
  答:我的步骤,
  S:puppet cert clean "清理的主机名"    C:rm -rf /var/lib/puppet
  S:puppet master restart     C:puppet agent --verbose --test --server "服务器的主机名"
  S:puppet cert list && puppet cert sign "清理的主机名"     C:puppet agent --verbose --test --server "服务器的主机名"(验证是否成功)
  问题3:其他奇怪的问题
  答:换其他agent测试,如果一样,实在不行重装,肯定行了

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-545084-1-1.html 上篇帖子: 【中级篇】puppet部署与应用 下篇帖子: puppet(1.1-1.6)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表