run task in a sorted manner

19 views
Skip to first unread message

sandkan

unread,
Feb 15, 2020, 2:57:32 PM2/15/20
to Ansible Project
Playbook is running task on wrong node: I have two nodes and this task has to run on a specific one and not the other, as well as only running once.
I have tried adding a sort() like this: {{ansible_play_batch | join(' ') | sort()}}.
I'm not even sure why I need to add spaces after ansible_play_batch.
This is the command I am trying to translate to ansible. It is wrongly running the command pn server "pcmk-2" instead of "pcmk-1".
Command: pcs cluster setup --name mycluster pcmk-1 pcmk-2

My Ansible:
- name: Setup message bus
run_once: true
command: >
pcs cluster setup --name {{ cluster_name | quote }}
{{ ansible_play_batch | join(' ') }}

Nicholas Irving

unread,
Feb 16, 2020, 1:00:08 AM2/16/20
to ansible...@googlegroups.com
Try just using {{ ansible_hostname }} it should give you the details you want.

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/88d03557-f5b4-4b9b-bd5a-946a2b971bd4%40googlegroups.com.

Dick Visser

unread,
Feb 16, 2020, 2:17:50 AM2/16/20
to ansible...@googlegroups.com
You only posted a single task. 
Please post your entire playbook. 
Also explain what your command should look like (it’s not clear what you posted is correct or not). 

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/88d03557-f5b4-4b9b-bd5a-946a2b971bd4%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

soumya dutta

unread,
Feb 16, 2020, 7:35:47 AM2/16/20
to ansible...@googlegroups.com
Add below parameters and try if that works for you.

delegate_to: nodename/nodeip
run_once: true

Cheers,
Soumya

--
Reply all
Reply to author
Forward
0 new messages