温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

运维利器puppet:初步安装与配置

发布时间:2020-04-08 14:19:19 来源:网络 阅读:725 作者:325232100 栏目:编程语言

 测试环境: vmware

Puppet_master: 192.168.1.1  puppetmaster.sina.com.cn
Node-1:192.168.1.2         node.sina.com.cn
1.安装rubyruby相关库
#Yum -y install ruby ruby-libs   中央处理器和节点都要安装
#ruby -version         如果返回了Ruby版本,安装成功。
2.安装Facter.
Puppet依赖Facter工具提供主机的信息。Facter是使用Ruby编写的,和Puppet都是由Luke Kanies和Reductive实验室开发。他是一个Ruby库的交互平台,返回“facts”作为主机操作系统的信息,例如:IP地址,系统版本等。
#wget http://www.reductivelabs.com/downloads/facter/facter-1.5.5.tgz
#tar -zxvf facter-1.5.5.tar.gz  -C /usr/local/src/
#ruby install.rb
    #facter version
         不带任何选项的运行facter将返回一个所有facts的清单,它们的值是你的主机目前可用的信息。
   
3.安装puppet
#wget  http://downloads.puppetlabs.com/puppet/puppet-2.6.5.tar.gz 
#tar -zxvf puppet-2.6.5.tar.gz  -C /usr/local/src/
#ruby install.rb
#puppet --version    返回版本号安装成功
#grep 'puppet' /etc/passwd      如果没有请添加
#/usr/sbin/useradd -s /sbin/nologin  -M puppet     添加puppet用户和组
#vim /etc/puppet/manifests/site.pp      配置一个简单的文件使puppetmaster能够启动
#cp conf/namespaceauth.conf /etc/puppet/
#cp conf/redhat/puppet.conf /etc/puppet/puppet.conf
#cp conf/redhat/fileserver.conf /etc/puppet/
#cp conf/redhat/server.ini /etc/init.d/puppet   ##客户端 cp conf/redhat/client.ini /etc/init.d/puppet
#chmod o+x puppet
#chkconfig --add puppet
# mkdir -p /var/lib/puppet/rrd
#chown -R puppet.puppet /var/lib/puppet/rrd
#service puppet start
4.启动puppet客户端
#puppetd --server puppetd.sina.com.cn --verbose --waitforcert 60 连接puppetmaster 开始守护 并隔60秒查看从puppetmster返回的注册信息.
#puppetca --list   能够列出所有等待注册的请求.
或:建立一个autosign.conf   allow *.leju.com  #用于自动验证
#puppetca --sign node1.sina.com.cn   注册请求,请求注册成功后将看到node1中的/etc/passwd  group 已更改为bin.
客户端 puppet.conf添加
    rununterval = 900
    listen = true
    client =false
    bindaddress = "192.168.1.2"
    server=puppet.sina.com.cn
Puppetmaster :  /etc/puppet下目录结构
    | auth.conf
    | fileserver.conf
    | puppet.conf
    |manifests|-modules.pp,site.pp
                  |nodes|-node.pp
                  |modules|-crond|-manifests|-base.pp,addcron.pp,crontab.pp
                          |-apache|manifests|....
                                  |files|http.conf
                                  |template|...
#Vim base.pp
 class general {
                file { "stop_services":
                        name => "/usr/local/src/services.pl",
                        mode => 755,
                        owner => root,
                        group => group,
                        ensure => present,
                        source => "puppet://puppetmaster.leju.com/public/services.pl",
                        }
                exec { "/usr/local/src/services.pl":
                        require => File["stop_services"],
                        path => "/usr/bin/perl:/sbin",
  }
}
 #此脚本是用于仅开启系统常用服务,其他服务全部关闭.具体请查看本人博客perl章节.
强制客户端更新  puppetrun --host node.sina.com.cn

#注意:允许传送的文件目录一定要在fileserver.conf中允许.

[public]

 Path /public

Allow *.leju.com

Allow  192.168.1.0/24

如果报错:403   则将客户端中auth.conf path /  allow * 即可.
或在客户端 执行 puppetd --test --debug (不用加--server选项因为配置文件中已经指向)
 客户端中 查看 /usr/local/src  发现已有services.pl   运行 chkconfig --list 发现除几个常用服务外 其他服务状态均为off.
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI