puppet agent向server拉取文件进行同步

agent向server拉取文件,进行同步。需要对server进行配置。

假如将server侧的/etc/httpd/conf/httpd.conf同步到agent。server侧/etc/puppet/manifests/site.pp内容如下:file后的“/etc/httpd/conf/httpd.conf”为agent侧的位置,source后为准备同步下去的文件在master服务器上的位置

node default {

    notify{"Hello World":
        name => "welcome",
        message => "Hello World!",
    }

    file {"/etc/httpd/conf/httpd.conf":
    mode => '777',owner => 'nobody',group => 'nobody',
    backup => '.bak',
    source => "puppet:///mount_point/httpd.conf",
    }
}

在/etc/puppet/fileserver.conf的最后添加mount_point的配置,如下:

[root@puppetmaster puppet]# tail fileserver.conf
# allow /^(.+)\.example\.com$/
# allow_ip 192.168.100.0/24
#
# If added to auth.conf BEFORE the "path /file" rule, the rule above
# will add stricter restrictions to the extra_files mount point.
#

[mount_point]
path /etc/httpd/conf
allow *

 在agent端验证(生成了.bak文件,也有hello world的输出):

[root@puppetclient2 puppet]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for puppetclient2
Info: Applying configuration version '1551258710'
Notice: /Stage[main]/Main/Node[default]/File[/etc/httpd/conf/httpd.conf]/content: 
--- /etc/httpd/conf/httpd.conf	2018-02-19 19:24:50.000000000 +0800
+++ /tmp/puppet-file20190227-17325-bv4h7t-0	2019-02-27 17:12:15.123457239 +0800
@@ -1,4 +1,6 @@
 #
+#haha
+#
 # This is the main Apache server configuration file.  It contains the
 # configuration directives that give the server its instructions.
 # See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.

Notice: /Stage[main]/Main/Node[default]/File[/etc/httpd/conf/httpd.conf]/content: content changed '{md5}f6351c6d8c8dfc5899820d8c46d74651' to '{md5}60f4b8ee93f4a19994aa94395dfe6812'
Notice: /Stage[main]/Main/Node[default]/File[/etc/httpd/conf/httpd.conf]/owner: owner changed 'root' to 'nobody'
Notice: /Stage[main]/Main/Node[default]/File[/etc/httpd/conf/httpd.conf]/group: group changed 'root' to 'nobody'
Notice: /Stage[main]/Main/Node[default]/File[/etc/httpd/conf/httpd.conf]/mode: mode changed '0644' to '0777'
Notice: Hello World!
Notice: /Stage[main]/Main/Node[default]/Notify[Hello World]/message: defined 'message' as 'Hello World!'
Notice: Finished catalog run in 0.20 seconds
[root@puppetclient2 puppet]# ll /etc/httpd/conf/httpd.conf.bak 
-rw-r--r-- 1 root root 34419 Feb 19  2018 /etc/httpd/conf/httpd.conf.bak

如果遇到故障,一定要冷静思考。如果认证什么都正常,但是agent不报错,但无法同步,就需要检查server侧的配置文件,环境了。

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值