No it does not. run_once will only perform a task on node1, therefor skip the task.
Please re-check in a local environment.
last time i explain this:
- script: myscript
register: myreturn
failed_when: not myreturn.stdout|bool
^ this will remove host 1 from the host list so the next task only chooses ‘first host’ from 2 and 3
- command: othertask
run_once: true
^ this task runs against ONLY 2 OR 3
tasks:
- stat:
path: /tmp/hi
register: me
- set_fact:
run_on: "{{ item }}"
with_items: "{{ play_hosts }}"
when: run_on is undefined and hostvars[item].me.stat.exists
run_once: true
- shell: echo
when: inventory_hostname == run_on
This will FAIL the task at node 1, which is in no way desired. That is no real solution.
Also, after ‘othertask’ has been run, I’d like to perform other tasks on node 1.
Hallelujah! You did it. Big thanks to you sir!
TASK [command] *****************************************************************
Saturday 17 December 2016 14:08:12 +0100 (0:00:00.101) 0:00:01.122 *****
skipping: [localMulti1]
skipping: [localMulti3]
changed: [localMulti2]
PLAY RECAP *********************************************************************
localMulti1 : ok=3 changed=0 unreachable=0 failed=0
localMulti2 : ok=3 changed=1 unreachable=0 failed=0
localMulti3 : ok=2 changed=0 unreachable=0 failed=0
Kevin, can you please show the playbook/tasks that are working for you so that it will help others. Thanks
Erhm, the solution is in the quoted text..
Here is a copy/paste:
On node 2 and 3 perform:
$: touch /tmp/hi
tasks:
- stat:
path: /tmp/hi
register: me
- set_fact:
run_on: "{{ item }}"
with_items: "{{ play_hosts }}"
when: run_on is undefined and hostvars[item].me.stat.exists
run_once: true
- shell: echo
when: inventory_hostname == run_on