运行Ansible任务会引发共享连接关闭错误

时间:2016-05-19 04:27:42

标签: xpath ansible

我已经为ansible-xml模块编写了一个任务。

- name: Learning xml module
  xml:
    file: /var/lib/tomcat7/webapps/sme/WEB-INF/sme-servlet.xml
    xpath: //ref/[@abcd="test"]

我收到以下错误:

failed: [xxxx] => {"failed": true, "parsed": false}
BECOME-SUCCESS-ezlukfdsowbhzcovltxcovwmgbziywxu
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 3: Applying options for *
debug1: auto-mux: Trying existing master
debug1: mux_client_request_session: master session id: 2
Shared connection to xxxx closed.

1 个答案:

答案 0 :(得分:1)

默认情况下,ansible会添加一些覆盖ssh_config选项的选项。具体来说,它补充说:

-o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/home/user/.ansible/cp/ansible-ssh-%h-%p-%r"

-vvvansible-playbook一起使用。

如何修复:

您可以通过在指定heressh_args的{​​{1}}部分中指定[ssh_connection]来覆盖这些选项。更改.ansible.cfg实际上并未更改所有参数,因为Ansible还会传递ssh_args和其他选项(例如-C -tt -v -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o ConnectTimeout=10),其中一些只是不可变的默认值,其中一些取决于您在剧本中指定的变量。