【问题标题】:Installation succeeds but Ansible reports a failure安装成功但 Ansible 报告失败
【发布时间】:2016-08-24 06:44:46
【问题描述】:

我有一个简单的剧本,预计会安装一个 Windows 应用程序 -

--
- name: Install the <application>
  hosts: all 

  tasks:
  - name: Installation of <application>
    raw: cmd /c "<path to setup> /s <appname> /n ACCEPT_EULA=1"

应用程序安装成功,但 Ansible Tower 报告“失败”。

标准输出有这个信息 -

TASK [Installation of <application_name>] ************************************************
task path: /var/lib/awx/projects/tests/<file>.yml:6
fatal: [xxx.163.xxx.69]: FAILED! => {"changed": false, "failed": true, "rc": 1, "stderr": "", "stdout": "", "stdout_lines": []}

NO MORE HOSTS LEFT *************************************************************
 [ERROR]: Could not create retry file '<file>_bat.retry'. The error was: [Errno
13] Permission denied: '<file>_bat.retry'

我可以通过取消注释 retry_files_enabled = False 来消除“无法创建重试”文件错误,但致命故障仍然继续出现。

如何确保 Ansible 报告“已更改”:true?

【问题讨论】:

    标签: ansible ansible-playbook


    【解决方案1】:

    任务失败,因为命令的返回码是 1。(注意输出中的 "rc": 1。)

    如果这是预期的,您可以使用failed_when 指定不同的失败条件,或使用ignore_errors 忽略任务的所有失败。详情请见https://docs.ansible.com/ansible/playbooks_error_handling.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-13
      • 2016-07-12
      • 1970-01-01
      • 1970-01-01
      • 2017-03-11
      • 1970-01-01
      • 1970-01-01
      • 2015-06-24
      相关资源
      最近更新 更多