#111 Wrong usage of ansible facts for 'executor' code.
Closed: SOLVED Opened by astepano.

https://pagure.io/standard-test-roles/blob/master/f/roles/standard-test-beakerlib/tasks/main.yml#_51

Problem is: Ansible uses facts for remote system, not facts from delegated server.

  - name: Add restraint repo for restraint-rhts on Fedora hosts
    shell: dnf copr enable -y bpeck/restraint
    when: ansible_distribution == 'Fedora'

Example:

$ cat 4.yml 
---
- hosts: all
  tasks:
  - name: Add executor host
    add_host:
      name: executor
      ansible_connection: local
  - block:
    - name: Gather facts
      setup:
      delegate_facts: True
    - debug:
        msg: ansible_distribution ==  {{ ansible_distribution }}
    delegate_to: executor
# vim: et ts=2 sw=2 ai

LOCAL SYSTEM IS: CENTOS 7

$ ansible-playbook  -i f26, 4.yml 
PLAY [all] ************************************************************************************************************
TASK [Gathering Facts] ************************************************************************************************
ok: [f26]
TASK [Add executor host] **********************************************************************************************
changed: [f26]
TASK [Gather facts] ***************************************************************************************************
ok: [f26 -> executor]
TASK [debug] **********************************************************************************************************
ok: [f26 -> executor] => {
    "msg": "ansible_distribution ==  Fedora"
}
PLAY RECAP ************************************************************************************************************
f26                        : ok=4    changed=1    unreachable=0    failed=0   

Metadata Update from @astepano:
- Issue assigned to astepano

Metadata Update from @astepano:
- Issue close_status updated to: SOLVED

Metadata