ansible问题汇总,不断更新中...

一、通过ssh代理传输文件超时

hosts配置文件

1
2
[TestServer]
172.16.0.129 ansible_ssh_port=12345 ansible_ssh_common_args='-o ProxyCommand="ssh -q -p33115 root@111.222.333.444 nc %h %p"'

应用synchronize模块时提示类似如下信息:

1
2
3
4
5
6
7
8
9
[root@xyzl-test3 ansible]# ansible TestServer -i /opt/App/ansible/TestServerHosts -m synchronize -a "src=/opt/JenkinsCache/TestServer/TestServer.tar.gz dest=/opt/JenkinsCache/TestServer/"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

172.16.0.129 | FAILED! => {
"changed": false,
"cmd": "/bin/rsync --delay-updates -F --compress --archive --rsh=/bin/ssh -S none -o Port=33115 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --out-format=<<CHANGED>>%i %n%L /opt/JenkinsCache/TestServer/TestServer.tar.gz 172.16.0.129:/opt/JenkinsCache/TestServer/TestServer/",
"msg": "ssh: connect to host 172.16.0.129 port 12345: Connection timed out\r\nrsync: connection unexpectedly closed (0 bytes received so far) [sender]\nrsync error: unexplained error (code 255) at io.c(226) [sender=3.1.2]\n",
"rc": 255
}

因改成copy模块:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[root@xyzl-test3 ansible]# ansible TestServer -i /opt/JenkinsCache/TestServer/TestServerHosts -m copy -a "src=/opt/JenkinsCache/TestServer/TestServer.tar.gz dest=/opt/JenkinsCache/TestServer/TestServer/"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

172.16.0.129 | CHANGED => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": true,
"checksum": "f91ea3c7d14223d73cd5ac667112388b13f8b8f4",
"dest": "/opt/JenkinsCache/TestServer/TestServer.tar.gz",
"gid": 0,
"group": "root",
"md5sum": "76cf7a69de2786d77327ab59f803fe1c",
"mode": "0644",
"owner": "root",
"size": 40923749,
"src": "/root/.ansible/tmp/ansible-tmp-1570589569.14-59930443509260/source",
"state": "file",
"uid": 0
}