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

[经验分享] Puppet学习--基础安装和配置

[复制链接]
YunVN网友  发表于 2018-8-2 09:54:16 |阅读模式
0. 安装环境
客户端IPpuppet_client.example.net(192.168.1.10)服务端IPpuppet_server.example.net(192.168.1.11)OS版本CentOS>1.预安装配置
  需要在服务端和客户端进行一些必要的预安装配置,因此本节下面的命令需要在客户端和服务端均要执行。
  (1) yum install ruby #安装ruby
  (2) 修改/etc/hosts,写入两行:
192.168.1.10    puppet_client.example.net  192.168.1.11    puppet_server.example.net
  (3) rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-6.noarch.rpm  #安装puppet仓库
2. 安装服务端
  登录puppet_server.example.net,执行如下命令:
  [root@puppet_server.example.net ~]# yum install puppet-server puppet –y   #安装puppet服务端和客户端
  [root@puppet_server.example.net ~]# puppet resource package puppet-server ensure=latest  #更新puppet服务端
  [root@puppet_client.example.net ~]# mv /etc/puppet/puppet.conf /etc/puppet/puppet.conf_bak #备份原配置文件
  [root@puppet_client.example.net ~]# vim /etc/puppet/puppet.conf  # 重新写入文件,文件内容如下:
  [main]
  logdir = /var/log/puppet
  rundir = /var/run/puppet
  ssldir = $vardir/ssl
  [agent]

  >  localconfig = $vardir/localconfig
  server = puppet_server.example.net
  certname = puppetmaster_cert.example.net
  [master]
  certname = puppet_server.example.net
  [root@puppet_server.example.net ~]# chkconfig puppetmaster on  #设置puppetmaster服务开启启动
  [root@puppet_server.example.net ~]# service puppetmaster start  #启动puppetmaster
3. 安装客户端
  登录puppet_client.example.net,执行如下命令:
  [root@puppet_client.example.net ~]# yum install puppet –y   #安装puppet客户端
  [root@puppet_client.example.net ~]# puppet resource package puppet ensure=latest  #更新puppet
  [root@puppet_client.example.net ~]# mv /etc/puppet/puppet.conf /etc/puppet/puppet.conf_bak #备份原配置文件
  [root@puppet_client.example.net ~]# vim /etc/puppet/puppet.conf  # 重新写入文件,文件内容如下:
  [main]
  logdir = /var/log/puppet
  rundir = /var/run/puppet
  ssldir = $vardir/ssl
  [agent]

  >  localconfig = $vardir/localconfig
  server = puppet_server.example.net
  certname = puppetmaster_cert.example.net
  [root@puppet_client.example.net ~]# chkconfig puppet on  #设置puppet服务开启启动/etc/puppet/puppet.conf
  [root@puppet_client.example.net ~]# service puppet start  #启动puppet
4. 客户端与服务端进行认证
  客户端通过调试模式启动节点向puppetmaster端发起认证:
  [root@puppet_client.example.net ~]# puppet agent –t
  Info: Caching certificate for puppet_client.example.net
  Info: Caching certificate for puppet_client.example.net
  Info: Caching catalog for puppet_client.example.net
  Info: Applying configuration version '1430120791'
  Notice: Finished catalog run in 0.02 seconds
  服务端确定认证:
  [root@puppet_server.example.net ~]# puppet cert --list -all   #查看所有证书,未认证的证书前面没有+号
  [root@puppet_server.example.net ~]# puppet cert --sign -all  #对所有证书进行认证
  或者只对指定的证书进行认证:
  [root@puppet_server.example.net ~]# puppet cert --sign “puppet_client.example.net” #对指定的证书进行认证
  [root@puppet_server.example.net ~]# puppet cert --list -all   #再次查看所有证书,证书前面已经有+号,表示已经认证通过
5. 客户端进行操作的一个简单例子
  现在举一个最简单的例子说明一下如何使用。
  假如我们需要在客户端上安装lsof命令,常规情况下我们需要运行yum install lsof -y命令,这只是RHEL、CentOS系统上的命令,而在Debian、Ubuntu等系统上则是用apt-get命令。如果需要安装lsof命令的系统比较多的话,就需要编写脚本判断系统版本进行安装了。但是在puppet中,可以通过以下方式简单的实现上述需求。
  首先,在puppet服务端创建一个/etc/puppet/manifests/site.pp文件,内容如下:
  [root@puppet_server.example.net ~]# vim /etc/puppet/manifests/site.pp
  package{ 'lsof':
  ensure => installed,
  }
  然后,在client端执行puppet agent -t命令:
  [root@puppet_client.example.net ~]# puppet agent -t
  Info: Caching catalog for puppet_client.example.net
  Info: Applying configuration version '1430127711'
  Notice: /Stage[main]/Main/Package[lsof]/ensure: created
  Notice: Finished catalog run in 6.90 seconds
  输出已经表明lsof包已经安装成功。查看一下:
  [root@puppet_client.example.net ~]# rpm -q lsof
  lsof-4.82-4.el6.x86_64
  说明:puppet agent -t命令是在客户端手动运行agent程序。puppet客户端本身如果启动了puppet服务的话,puppet是可以自动间隔一段时间后去运行agent的,默认时间间隔为1800s。可以修改该时间间隔参数,修改客户端agent节点中的/etc/puppet/puppet.conf文件,修改[agent]下面的:runinterval = 100,单位为秒,然后重启puppet:service puppet restart。

运维网声明 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-545151-1-1.html 上篇帖子: Puppet安装与配置-自学 下篇帖子: puppet安装配置及测试
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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