class rsync::client inherits rsync {
}
节点配置:
/etc/puppet/manifests/nodes.pp
node 'server208' {
include 'rsync::server' ###应用模块,这个要有,不然的话host.pp定义的source将无法识别定义的共享路径
include 'rsync::client'
rsync::client::host {"first":
title => 'first',
source =>'test', #####rsync server 定义的模块名
rsyserver => '192.168.20.201',
target =>'/home/software/'
}
}
四: 客户端测试
puppet agent --server=puppet-server (最好是域名) --test -v
err: Could not retrieve catalog from remote server: Could not intern from pson: Could not convert from pson: Could not find>
解决办法:
Vi /etc/puppet/puppet.conf
追加一行:
preferred_serialization_format = yaml
再执行:
[root@server208 software]# puppet agent --server=puppet.51coolbar.com --test -v
info: Caching catalog for server208
notice: /Stage[main]/Rsync/Tidy[/etc/rsync]: Tidying File[/etc/rsync]
info: /File[/etc/rsync]: Duplicate generated resource; skipping
info: Applying configuration version '1375341008'
err: /Stage[main]//Node[server208]/Rsync::Client::Host[first]/Exec[first]/returns: change from notrun to 0 failed: rsync -avzP root@192.168.20.201::/home/test /home/software/,/tmp/ returned 5 instead of one of [0] at /etc/puppet/modules/rsync/manifests/client/host.pp:6
现在是提示没有语法的错误,是因为这一行命令的问题,但是返回的是0个filed,所以执行下这个命令
rsync -avzP root@192.168.20.201:/home/test /home/software/
The authenticity of host '192.168.20.201 (192.168.20.201)' can't be established.
RSA key fingerprint is 08:b3:92:84:5b:1d:a2:bc:94:6b:0a:b9:77:ae:b6:7f.
Are you sure you want to continue connecting (yes/no)? Yes
是需要输入密码的
也就是说,我们的rsync server 和 rsync client 密码信任是不对的,需要解决这个问题
参考URL:http://1413570.blog.51cto.com/1403570/659561
就是建立一个无密码的交互
之后再去执行:
[root@server208 .ssh]# puppet agent --server=puppet.51coolbar.com --test -v
info: Caching catalog for server208
notice: /Stage[main]/Rsync/Tidy[/etc/rsync]: Tidying File[/etc/rsync]
info: /File[/etc/rsync]: Duplicate generated resource; skipping
info: Applying configuration version '1375340449'
notice: /Stage[main]//Node[server208]/Rsync::Client::Host[first]/Exec[first]/returns: executed successfully
notice: Finished catalog run in 3.21 seconds
Ok,执行成功,可以到目录下去看下,可以看到同步过来的文件
这个是一个基本的同步文件的配置,可以根据实际的工作需要去配置你的节点,而模板是不需要去更改的,你可以host.pp里面,去编辑符合你业务需要的参数