delegate_to: "{{ item }}"
with_items: groups.domain_controllers
retries: 1
register: result
until: result.rc == 0
rwdc_server: '{{groups.rwdcs|random}}'
- name: Choosing random DB server to use
set_fact:
random_server: "{{ groups.groupname|random}}"
- name: executing the script on random server
shell: /path/to/script
delegate_to: "{{ random_server }}"
Hi All,
I have a task which has multiple with_items and hence it picks the latest defined item (arbiter) in the delegate which is not the expected result:
```
run_once: true
delegate_to: "{{ item }}"
with_items:
- "{{ groups['mongodb-active'] }}"
shell: /usr/bin/mongo --eval 'printjson(rs.add("{{ item }}:27017"))'
with_items:
- "{{ groups['mongodb-arbiter'] }}"```
```
I tried using below too, but failed - "ERROR! Unexpected Exception, this is probably a bug: unhashable type: 'list'":
- name: Choosing active server
set_fact:
active_server: "{{ groups['mongodb-active'] }}"
- name: Add secondaries
run_once: true
delegate_to: "{{ active_server }}"
shell: /usr/bin/mongo --eval 'printjson(rs.add("{{ item }}:27017"))'
with_items:
- "{{ groups['mongodb-arbiter'] }}"