Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional role inclusion+run_once may skip tasks unexpectedly #18821

Closed
amenonsen opened this issue Dec 7, 2016 · 2 comments
Closed

Conditional role inclusion+run_once may skip tasks unexpectedly #18821

amenonsen opened this issue Dec 7, 2016 · 2 comments
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug.

Comments

@amenonsen
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

core

ANSIBLE VERSION
devel
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

If a role is included conditionally, then any run_once task in it may be skipped if the first host that is running the play doesn't meet the condition.

STEPS TO REPRODUCE

foo.yml

---
- hosts: all
  gather_facts: no
  roles:
    - role: p
      when: inventory_hostname == 'c'

roles/p/tasks/main.yml:

- command: cat /proc/uptime
  run_once: true

I did this:

ansible-playbook -v -i a,b,c,d, -e ansible_connection=local i.yml
EXPECTED RESULTS

I expected the task to be executed on 'c'.

ACTUAL RESULTS
PLAY [all] ************************************************************************************************************************************************************************************

TASK [p : command] ****************************************************************************************************************************************************************************
skipping: [a] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

PLAY RECAP ************************************************************************************************************************************************************************************
a                          : ok=0    changed=0    unreachable=0    failed=0   
@krzysztof-magosa
Copy link
Contributor

Related to #13226

@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report labels Dec 13, 2016
@bcoca
Copy link
Member

bcoca commented Dec 20, 2016

closing as dupe of #13226, this is a consequence of run_once running on the first active host in the run, so the when condition evaluates relative to that host.

@bcoca bcoca closed this as completed Dec 20, 2016
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants