当我们配置的用户没有家目录执行命令之后,发现以下问题:
) W% q3 N; j# c说明我们已经更改过ansible下的hosts文件了。: Y; {1 V9 J; _6 L# R, g
- L- a4 S+ I3 \$ ansible -m shell -a "uptime" 192.168.13.5) D; A$ t! M1 Q! @
192.168.13.5 | UNREACHABLE! => {5 ^# T: {. K7 g
"changed": false, / E) f4 s3 W; P, P3 g U3 K$ {
"msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote temp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /home/victor/.ansible/tmp/ansible-tmp-1514033210.52-982392478156 `\" && echo ansible-tmp-1514033210.52-982392478156=\"` echo /home/victor/.ansible/tmp/ansible-tmp-1514033210.52-982392478156 `\" ), exited with result 1",
& |; ?) `- k3 d3 f4 E Y# x6 P5 v "unreachable": true
0 n" [# h7 ~9 h" J/ U}% Z I3 M9 }' Q U9 j( [0 ~
7 H. ^* l$ b2 } i( h解决方法:
. L3 s( \9 [. |需要修改下ansible.cfg 文件:
( r' @) s( _- z8 k# n2 R0 C, i2 \! F' u) ]2 V. p0 P" P' x* _
$ sudo vim/etc/ansible/ansible.cfg 将文件配置为/tmp目录下即可:remote_tmp = /tmp/.ansible/tmp 9 S. w; w0 N! H5 u a4 `
5 K! _# \* J4 F0 O |