Puppet学习--基础安装和配置
2015-04-27 17:48
453 查看
0. 安装环境
客户端IP | puppet_client.example.net(192.168.1.10) |
服务端IP | puppet_server.example.net(192.168.1.11) |
OS版本 | CentOS release 6.6 x86_64 |
puppet版本 | 3.7.5 |
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 |
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] classfile = $vardir/classes.txt localconfig = $vardir/localconfig server = puppet_server.example.net certname = puppetmaster_cert.example.net [master] certname = puppet_server.example.net |
[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] classfile = $vardir/classes.txt localconfig = $vardir/localconfig server = puppet_server.example.net certname = puppetmaster_cert.example.net |
[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, } |
[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。
本文出自 “烟花易冷” 博客,转载请与作者联系!
相关文章推荐
- PHP基础学习(1)-Win2003下安装配置PHP
- nginx+PHP服务器环境安装与配置学习(一) - windows系统基础环境搭建
- java基础学习一:环境的安装与配置
- Puppet学习之puppet的安装和配置
- Puppet学习之puppet的安装和配置
- VMware从零开始学习之01 ESXI 5.5基础安装与网络配置
- puppet运维自动化配置安装学习
- puppet 学习之安装配置
- 零基础学习Puppet自动化配置管理(文档持续更新中)
- java语言学习003_开发环境基础配置和安装(jdk,jre,eclipse&myeclipse)
- JAVA基础学习(一)--JAVA入门和JDK的安装与配置
- 【修正版】Python基础学习(一)——安装与配置python2.7.x环境(linux)
- 基础学习day01--JAVA入门和JDK的安装与配置
- 【转】Android Studio安装配置学习教程指南 Gradle基础--不错
- Puppet学习之puppet的安装和配置
- Python基础学习笔记(一)安装以及IDE的配置
- puppet学习笔记之安装与配置
- Yii学习笔记之一(安装与基础环境的配置)
- php JpGraph 安装配置 基础学习