puppet管理系统部署

enveroment:

iptables:off    selinux:disabled    date:sync    

server:172.25.254.1    www.puppet.server.com    puppet master    rhel6.5

client1:172.25.254.2    www.puppet.client1.com    puppet agent    rhel6.5

client2:172.25.254.3    www.puppet.client2.com    puppet agent     rhel6.5


packages need:

puppet-3.8.1-1.el6.noarch.rpm

facter-2.4.4-1.el6.x86_64.rpm

hiera-1.3.4-1.el6.noarch.rpm

rubygem-json-1.5.5-3.el6.x86_64.rpm

ruby-shadow-2.2.0-2.el6.x86_64.rpm

ruby-augeas-0.4.1-3.el6.x86_64.rpm

rubygems-1.3.7-5.el6.noarch.rpm


Install the packages on server:

yum install -y puppet-server-3.8.1-1.el6.noarch.rpm \

                        puppet-3.8.1-1.el6.noarch.rpm \

                        facter-2.4.4-1.el6.x86_64.rpm \

                        hiera-1.3.4-1.el6.noarch.rpm \

                        rubygem-json-1.5.5-3.el6.x86_64.rpm \

                        ruby-shadow-2.2.0-2.el6.x86_64.rpm \

                        ruby-augeas-0.4.1-3.el6.x86_64.rpm \

                        rubygems-1.3.7-5.el6.noarch.rpm


install the packages on client:

yum install -y puppet-3.8.1-1.el6.noarch.rpm \

                        facter-2.4.4-1.el6.x86_64.rpm \

                        hiera-1.3.4-1.el6.noarch.rpm \

                        rubygem-json-1.5.5-3.el6.x86_64.rpm \

                        ruby-shadow-2.2.0-2.el6.x86_64.rpm \

                        ruby-augeas-0.4.1-3.el6.x86_64.rpm \

                        rubygems-1.3.7-5.el6.noarch.rpm


start service on server and client:

/etc/init.d/puppetmaster start    ##on server

/etc/init.d/puppet start    ##on client


connect puppet master from client1:

puppet agent --server www.puppet.server.com   --no-daemonize -v

##clinet send  a request to master and wait master signed and return a certificate.

puppet cert list

##use this command on master in order to list whitch host is waiting for certificate.

puppet cert sign www.example.com

##use this command on master to sign and send certificate to the client who is waiting for.

##if this 3 commands is testing ok ,means puppet is ok.


configuration puppet master:

cd /etc/puppet/manifests

vim  site.pp    ##this file is important,it concern about whether puppet can work ok or not.

    file{
        "/tmp/testfile":
        content => "hellow world"
    }
##this means if client connect to master,puppet will touch a file named "testfile" in /tmp,and it conent "hellow world".

puppet agent --server www.puppet.server.com --no-daemonize -v -t

##use this command on client you will see ""Notice: /Stage[main]/Main/File[/tmp/testfile]/ensure: defined content as '{md5}40de8907e2a86f00a25332be5eaf69c5',and it true touch a file "testfile" in /tmp.


another example of site.pp:

vim site.pp

    file{
        "/tmp/testfile":    ##file name and file path
        content => "hellow world",    ##file contents
        mode => 600,    ##file mode
        owner => nobody    ##file owner
    }

puppet agent --server www.puppet.server.com --no-daemonize -v -t

##use this command on client,after client connect to the master,puppet will touch a file named testfile in /tmp,content "hellow world",it's mod is 600 and it's owner is nobody.


puppet autosign:

vim /etc/puppet/puppet.conf    ##edit the main config file of puppet master

    autosign = ture    ##add this line on the top.this means allow any clients' connect.

cd /etc/puppet

touch autosign.conf    ##create autosign file

vim autosign.conf    ##add autosign clients

    www.puppet.client1.com

    www.piuppet.client2.com

/etc/init.d/puppetmaster restart

some example of puppet grammer(all edit in site.pp): 

##touch file

file{
        "/tmp/testfile":
        content => "hellow world",
        mode => 600,
        owner => nobody
}

##creat dir

file{
        "/public":
        ensure => directory
}

##package install:

package {
        "vsftpd":
        ensure => present
}

##service status:

service {
        "httpd":
        ensure => running
}

##package remove:

package {
        "vsftpd":
        ensure => absent
}

##file transform:

vim fileserver.conf

    [files]
    path /etc/puppet/files
    allow *

cd  /etc/puppet

mkdir files    ##it include vsftpd.conf(as it an example)

vim manifests/site.pp
    file{
        "/etc/vsftpd/vsftpd.conf":
        source => "puppet:///files/vsftpd.conf",
        mode => 600
    }




转载于:https://my.oschina.net/yongzheli/blog/632420

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值