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
run_once: true with delegate_to now getting skipped (2.3.0) #23594
Comments
I cannot duplicate this. A full output of your playbook run where it fails would be useful. |
Sorry I posted and ran on this one. Should have waited until I was clear of a few things. :) Anyway, It's entirely possible I don't understand how a "run_once" w/ "delegate_to" should function, but this only popped up after my 2.3.0.0 update. I'm assuming that as long as at least one host is valid (not skipped) that the task will run once and be delegated to the specified host. Just looking at http://docs.ansible.com/ansible/playbooks_delegation.html#run-once My actual playbook is quite large with lots of inclusions, so I've pared down a simple example. With the following hosts file:
and the following playbook: - hosts: test-hosts
tasks:
- name: Clone iot-platform locally for v4.4.5
git:
repo: 'git@ourserver.domain.com:group/iot-platform.git'
dest: '/etc/ansible/test/4.4.5'
depth: 1
update: yes
version: 'v4.4.5'
run_once: true
delegate_to: 127.0.0.1
when: _myVar The task will be skipped and not cloned locally. Output:
However, if I switch the order of the hosts so that a valid host is first, like this:
Then the task will execute:
|
This also affects 2.2.3.0 |
Possible MisunderstandingHi! Thanks very much for your submission to Ansible. It sincerely means a lot to us. We believe the ticket you have filed is being somewhat misunderstood, as one thing works a little differently than stated. The In the future, this might be a topic more well suited for the user list, which you can also post here if you'd like some more help with the above. Thank you once again for this and your interest in Ansible! |
@bcoca I understand that that is the current behavior, but that behavior is not what is intuitively understood, that behavior is not mentioned in the docs, and that behavior is almost certainly not what 99.99999% of people want it to do. The issue is not that it executes on the first host in the play, but that it DECIDES whether to run at all based on the first node in the play. What is intuitive, and what matches the documentation, is for it to run on the first host in the play, if ANY host in the play matches the Even if you disagree with changing it to run if any host matches the |
FYI we are able to do the desired behavior using
Output:
|
ISSUE TYPE
COMPONENT NAME
run_once
delegate_to
ANSIBLE VERSION
CONFIGURATION
Nothing notable changed.
OS / ENVIRONMENT
N/A (but using Ubuntu 16.0.4.2 for both)
SUMMARY
I recently updated Ansible to 2.3.0.0 and several tasks that use a run_once: true with delegate_to: 127.0.0.1 are now being skipped. I've included an example below which used to run as long as at least one host was valid (not skipped). Now the play is skipped regardless when run_once: true.
STEPS TO REPRODUCE
Including the task below with one skipped host and one valid host on Ansible 2.3.0.0 results in the task being skipped altogether for me. Changing it to run_once: false allows it to process with first host being skipped and the other triggering it. The issue seems similar to this old (closed) issue -- #9784
"As run_once will always target the first host in the list, if that host is supposed to skip a set of tasks (due to some condition, for instance), it will also skip any run_once tasks even though they may delegate_to other hosts which are willing to run that task."
EXPECTED RESULTS
Task should run once on the local host
ACTUAL RESULTS
Task is skipped.
The text was updated successfully, but these errors were encountered: