Chethan S.
Chethan S.

Reputation: 556

Installation succeeds but Ansible reports a failure

I have a simple playbook that is expected to install a Windows application -

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

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

The application installation succeeds but is reported 'fail' by Ansible Tower.

The standard output had this information -

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'

I could get rid of the 'could not create retry' file error by uncommenting retry_files_enabled = False but the fatal failure still continues to appear.

How to ensure that Ansible reports "changed": true?

Upvotes: 0

Views: 525

Answers (1)

augurar
augurar

Reputation: 13016

The task is failing because the command's return code is 1. (Notice the "rc": 1 in the output.)

If this is expected, you can use failed_when to specify a different failure condition, or ignore_errors to ignore all failures for the task. See https://docs.ansible.com/ansible/playbooks_error_handling.html for more details.

Upvotes: 1

Related Questions