- name: set_fact monitor_name ansible_hostname
set_fact:
- monitor_name: "{{ ansible_hostname }}"
- when: not mon_use_fqdn | bool
+ monitor_name: "{{ hostvars[item]['ansible_hostname'] }}"
+ delegate_to: "{{ item }}"
+ delegate_facts: true
+ with_items: "{{ groups.get(mon_group_name, []) }}"
+ run_once: true
+ when:
+ - groups.get(mon_group_name, []) | length > 0
+ - not mon_use_fqdn | bool
- name: set_fact monitor_name ansible_fqdn
set_fact:
- monitor_name: "{{ ansible_fqdn }}"
- when: mon_use_fqdn | bool
+ monitor_name: "{{ hostvars[item]['ansible_fqdn'] }}"
+ delegate_to: "{{ item }}"
+ delegate_facts: true
+ with_items: "{{ groups.get(mon_group_name, []) }}"
+ run_once: true
+ when:
+ - groups.get(mon_group_name, []) | length > 0
+ - mon_use_fqdn | bool
- name: find a running monitor
when: groups.get(mon_group_name, []) | length > 0