Hello guys.

I'm here to bring an issue with Ansible dry-run (--check) mode. I have been 
facing a curious situation where package installation made using Playbooks 
and run in a dry-run mode is not working as expected. Using register+debug 
module it's possible to see that the package has been successfully 
installed, but when I try to use that installed package in later task, 
Ansible fails. 

*My Playbook:* 

---
- hosts: logging
  become: yes

  tasks:
    - name: Setting up EPEL
      yum: name=epel-release state=present
      register: inst
    - debug: var=inst

    - name: Checking installation
      stat:
        path: /etc/yum.repos.d/epel.repo
      register: file

    - fail:
        msg: "File epel.repo doesn't exist!"
      when: file.stat.exists == False

*Result:* 

[root@c7 projX]# ansible-playbook -i inventory epel.yml --check

PLAY [logging] 
***************************************************************************

TASK [Gathering Facts] 
*******************************************************************
ok: [192.168.52.20]

TASK [Setting up EPEL] 
*******************************************************************
changed: [192.168.52.20]

TASK [debug] 
*****************************************************************************
ok: [192.168.52.20] => {
    "inst": {
        "changed": true,
        "changes": {
            "installed": [
                "epel-release"
            ]
        },
        "failed": false,
        "results": []
    }
}

TASK [Checking installation] 
*************************************************************
ok: [192.168.52.20]

TASK [fail] 
******************************************************************************
fatal: [192.168.52.20]: FAILED! => {"changed": false, "msg": *"File 
epel.repo doesn't exist!"*}

PLAY RECAP 
*******************************************************************************
192.168.52.20              : ok=4    changed=1    unreachable=0    failed=1

---------------------------------------------------------------------------

If I take '--check' for dry-run out of the command it does work, but it's 
not the best approach for me once I'm planning to put this "checking task" 
in a CI software to "automate the automation". 

My question is: is there any specific reason for that case (package 
installation) not to work with --check parameter? I've done further tests 
using Ubuntu and the Ansible's apt module but the same problem comes up. 

Could you guys help me? 

thank you.
j

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/4d4c81c2-4fe1-4b03-b7d2-8130fe82e263%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to