updated logic to allow local_mgmt_ip to be loaded if its not passed in.
diff --git a/tasks/local_mgmt_ip.yml b/tasks/local_mgmt_ip.yml
index 11ce89d..44e8ad5 100644
--- a/tasks/local_mgmt_ip.yml
+++ b/tasks/local_mgmt_ip.yml
@@ -1,20 +1,18 @@
---
-- block:
- - name: Normalized name for management server local ip if on dc-1
- cache:
- key: 'local_mgmt_ip'
- value: "{{ hostvars[groups['dc-1-ms'][0]][interface_name].ipv4.address }}"
- when: groups['dc-1'] is defined and groups['dc-1-ms'] is defined and inventory_hostname in groups['dc-1']
+- name: Normalized name for management server local ip if on dc-1
+ cache:
+ key: 'local_mgmt_ip'
+ value: "{{ hostvars[groups['dc-1-ms'][0]][interface_name].ipv4.address }}"
+ when: groups['dc-1'] is defined and groups['dc-1-ms'] is defined and inventory_hostname in groups['dc-1']
- - name: Normalized name for management server local ip if on dc-2
- cache:
- key: 'local_mgmt_ip'
- value: "{{ hostvars[groups['dc-2-ms'][0]][interface_name].ipv4.address }}"
- when: groups['dc-2'] is defined and groups['dc-2-ms'] is defined and inventory_hostname in groups['dc-2']
+- name: Normalized name for management server local ip if on dc-2
+ cache:
+ key: 'local_mgmt_ip'
+ value: "{{ hostvars[groups['dc-2-ms'][0]][interface_name].ipv4.address }}"
+ when: groups['dc-2'] is defined and groups['dc-2-ms'] is defined and inventory_hostname in groups['dc-2']
- - name: Normalized name for management server local ip to dc-1 if current node is not on dc-1 or dc-2
- cache:
- key: 'local_mgmt_ip'
- value: "{{ hostvars[groups['dc-1-ms'][0]][interface_name].ipv4.address }}"
- when: local_mgmt_ip is not defined
- when: (assign_mgmt_ip is defined and assign_mgmt_ip | bool == True) or assign_mgmt_ip | default(True)
\ No newline at end of file
+- name: Normalized name for management server local ip to dc-1 if current node is not on dc-1 or dc-2
+ cache:
+ key: 'local_mgmt_ip'
+ value: "{{ hostvars[groups['dc-1-ms'][0]][interface_name].ipv4.address }}"
+ when: local_mgmt_ip is not defined or local_mgmt_ip | trim | length == 0