码迷,mamicode.com
首页 > 其他好文 > 详细

Puppet简易入门

时间:2016-06-26 14:07:32      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:

一、查看官方提供的下载源

      https://docs.puppet.com/guides/puppetlabs_package_repositories.html

 

二、 选择对应系统的下载源

       因为本机是CentOS 7.1,故选择YUM源

       https://yum.puppetlabs.com/

 

三、 安装Puppet

      # wget https://yum.puppetlabs.com/puppetlabs-release-el-7.noarch.rpm

      # rpm -ivh puppetlabs-release-el-7.noarch.rpm

      # yum install puppet -y

      # puppet --version

         3.8.7

 

四、 Puppet配置文件介绍

      Puppet的主配置文件均放到/etc/puppet目录下,3.8.7版本有以下几个文件

auth.conf  modules  puppet.conf

     其中:

     puppet.conf是Master守护进程的主配置文件,定义了Master的运行环境,启动加载文件等信息。守护进程在启动前会根据这个文件进行预检,只要预检成功才能启动

     守护进程。

     auth.conf主要用来定义Agent访问Master上目录的权限。如果没有权限控制的话,Agent可以访问Master服务器上的所有资源。

 

五、 安装nginx包并启动nginx服务

      安装nginx包,可先通过puppet resource命令生成相关的模板,然后再对其进行编辑。

[root@master1 ~]# puppet resource package nginx
package { nginx:
  ensure => absent,
}
[root@master1 ~]# puppet resource service nginx
service { nginx:
  ensure => stopped,
  enable => false,
}

    其中,puppet resource package是生成安装包的模板,puppet resource service是生成服务的模板

    最后,nginx包的配置文件如下:

package { nginx:
  ensure => present,
}
service { nginx:
  ensure => running,
}

    在本地应用该配置文件

    # puppet apply nginx.pp 

Notice: Compiled catalog for master1.localdomain in environment production in 0.56 seconds
Notice: /Stage[main]/Main/Package[nginx]/ensure: created
Notice: /Stage[main]/Main/Service[nginx]/ensure: ensure changed stopped to running
Notice: Finished catalog run in 5.76 seconds

    查看nginx包是否安装以及服务是否启动

[root@master1 ~]# rpm -qa |grep nginx
nginx-1.6.3-9.el7.x86_64
nginx-filesystem-1.6.3-9.el7.noarch
[root@master1 ~]# ps -ef |grep nginx
root       3094   3070  0 13:14 pts/2    00:00:00 tailf /var/log/nginx/error.log
root       3423      1  0 13:16 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx      3424   3423  0 13:16 ?        00:00:00 nginx: worker process
nginx      3425   3423  0 13:16 ?        00:00:00 nginx: worker process
root       3432   1536  0 13:18 pts/0    00:00:00 grep --color=auto nginx

 

      

 

      

Puppet简易入门

标签:

原文地址:http://www.cnblogs.com/ivictor/p/5617071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!