• Puppent 基本使用方法


    简单的文件配置

    master端

    vim /etc/puppet/manifests/site.pp
    ###########################内容如下
    node default{
             file {"/tmp/test.txt":
                   content=>"I am test puppet
    ";
    
             }
    }

    第一次需要重启Master

    service puppetmaster restart

    客户端请求

    [root@client01 puppet]# puppet agent --test
    Info: Retrieving pluginfacts
    Info: Retrieving plugin
    Info: Caching catalog for client01.test.com
    Info: Applying configuration version '1476164638'
    Notice: /Stage[main]/Main/Node[default]/File[/tmp/test.txt]/ensure: defined content as '{md5}a54460ca5545fddd6250f9aab22fc857'
    Notice: Finished catalog run in 0.06 seconds
    [root@client01 puppet]# ll /tmp/
    total 4
    -rw-r--r--  1 root root 17 Oct 11 13:43 test.txt
    -rw-------. 1 root root  0 Mar 21  2016 yum.log
    [root@client01 puppet]# cat /tmp/test.txt 
    I am test puppet

    查看到文件以及同步过来了

    创建文件并改变用户和授权

    node default{
             file {"/tmp/test.txt":
                   content=>"I am test puppet
    ";
                  owner => "root"
                  group => "puppet"
                  mode => "0777"
             }
    }

    管理组和用户:

    group {"test":
                   gid =>999,
                  ensure => present,
    }
    
    user {"hmy":
                name => "yf",
                uid => 999,
                gid => test,
                 managehome => true 
    }
    
    默认是false
             ensure => present
             groups => ['puppet','xfs']
             shell => "/bin/bash"

    实例

    user {"test1":
           name => "test",
           uid => 999,
           gid => test,
           managehome => true,
           ensure => present,
           groups => ['puppet'],
           shell => "/bin/bash";
    }

    定时任务cron

    cron { "ntp time":
            command => "/usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1",
            minute => '*/10',
            hour => ['2-4'],
            monthday => [2,4],
            ensure => present,
           
    }

    文件同步案例

    同步master端/etc/puppet/system_conf/下的文件到agent

    a修改master配置文件

    [root@master01 puppet]# vim fileserver.conf
    [system_conf]
           path /etc/puppet/system_conf
           allow *

    重启

    [root@master01 puppet]# /etc/init.d/puppetmaster restart
    Stopping puppetmaster:                                     [  OK  ]
    Starting puppetmaster:                                     [  OK  ]

    b 把需要同步的文件放到master的/etc/puppet/system_conf下

     cp /etc/resolv.conf /etc/puppet/system_conf/

    c 修改master端 site.pp

    file {"/etc/resolv.conf":
             mode => 644,
            source => "puppet://master01.test.com/system_conf/resolv.conf";
    
    }

    d 客户端同步

    # puppet agent --test

    这个实例可以配置:
    系统文件 hosts,resolv.conf,i18n,yum配置文件
    脚本文件 /script/service_all_clear.sh

  • 相关阅读:
    说说该死的Google Android Market
    由HTML5绘制地图说开去
    unicode解码小工具
    IntelliJ IDEA 的安装、配置与使用
    再次强调!考试必带的十几样物品,一样也不能少
    Redis 实现限流的三种方式
    Linux配置/etc/resolv.conf详解
    人生哲学
    一文教你如何高效使用 IDEA !
    Mysql5.7.30_配置参数
  • 原文地址:https://www.cnblogs.com/yexiaochong/p/5950951.html
Copyright © 2020-2023  润新知