问题
ansible执行rsync时候出现
TASK [04-test rsync sending] *********************************************************************************************************************************************
fatal: [11.0.0.78]: FAILED! => {"changed": true, "cmd": "rsync -avz /tmp/test.txt rsync_backup@11.0.0.79::backup --password-file=/etc/rsync.password", "delta": "0:00:00.008224", "end": "2022-11-30 08:58:43.347132", "msg": "non-zero return code", "rc": 10, "start": "2022-11-30 08:58:43.338908", "stderr": "rsync: failed to connect to 11.0.0.79 (11.0.0.79): No route to host (113)\nrsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2]", "stderr_lines": ["rsync: failed to connect to 11.0.0.79 (11.0.0.79): No route to host (113)", "rsync error: error in socket IO (code 10) at clientserver.c(125) [sender=3.1.2]"], "stdout": "", "stdout_lines": []}
原因
rsync 提示错误:rsync: failed to connect to x.x.x.x No route to host (113),原因是没有开启端口,默认是 873。
解决
由于的调试验证,我就临时处理直接systemctl stop firewalld
firewall
#开放端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="允许ip" port protocol="tcp" port="873" accept"
#重启防火墙
systemctl restart firewalld
Iptables
#开放端口
iptables -I INPUT -s 允许ip -tcp --dport 873 -j ACCEPT
#保存设置
service iptables save
#重启防火墙
service iptables restart
参考
rsync: failed to connect to x.x.x.x: No route to host (113)错误原因及解决办法