summaryrefslogtreecommitdiffstats
path: root/roles/ands_facts/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/ands_facts/tasks')
-rw-r--r--roles/ands_facts/tasks/find_interface_by_ip.yml20
-rw-r--r--roles/ands_facts/tasks/main.yml65
-rw-r--r--roles/ands_facts/tasks/network.yml49
-rw-r--r--roles/ands_facts/tasks/storage.yml59
4 files changed, 138 insertions, 55 deletions
diff --git a/roles/ands_facts/tasks/find_interface_by_ip.yml b/roles/ands_facts/tasks/find_interface_by_ip.yml
new file mode 100644
index 0000000..ecfa3c3
--- /dev/null
+++ b/roles/ands_facts/tasks/find_interface_by_ip.yml
@@ -0,0 +1,20 @@
+- name: "Looking for interface holding {{ ip }}"
+ set_fact:
+ "{{ var }}": "{{ eth['device'] }}"
+ vars:
+ eth: "{{ hostvars[inventory_hostname]['ansible_' + item] | default({}) }}"
+ ipv4: "{{ eth['ipv4'] | default({}) }}"
+ q: "{{ eth | json_query('ipv4_secondaries[*].address') }}"
+ sec: "{{ ((q == ands_none) or (q == '')) | ternary([], q) }}"
+ ips: "{{ sec | union([ipv4.address]) }}"
+ when:
+ - eth['type'] is defined
+ - eth['ipv4'] is defined
+ - eth['device'] is defined
+ - eth['type'] == 'ether'
+ - ip in ips
+ with_items:
+ - "{{ hostvars[inventory_hostname]['ansible_interfaces'] }}"
+# loop_control:
+# label: "{{ item }}"
+# no_log: true
diff --git a/roles/ands_facts/tasks/main.yml b/roles/ands_facts/tasks/main.yml
index cf995a0..6b28683 100644
--- a/roles/ands_facts/tasks/main.yml
+++ b/roles/ands_facts/tasks/main.yml
@@ -1,59 +1,14 @@
-- include_vars: dir="vars"
+---
-- name: Detect Heketi
- set_fact: ands_storage_domains="{{ ands_storage_domains | union([ands_heketi_domain]) }}"
- when:
- - ands_configure_heketi
- - ands_heketi_domain is defined
- - ansible_lvm.lvs[ands_heketi_lv] is defined
+# The variables accessed trough 'hostvars' should be set as facts
+# Here we set 'ands_storage_servers' and other variables
+- name: "Configuring storage facts"
+ include_tasks: "storage.yml"
-- name: Set some facts
- set_fact:
- ands_storage_servers: "{{ ands_storage_servers }}"
-
-- name: Set some facts
- set_fact:
- ands_data_vg: "{{ ands_data_vg }}"
- when: ands_data_vg != ""
-
-- name: Set some facts
- set_fact:
- ands_data_lv: "{{ ands_data_lv }}"
- when: ands_data_lv != ""
-
-- name: Set some facts
- set_fact:
- ands_heketi_vg: "{{ ands_heketi_vg }}"
- when: ands_heketi_vg != ""
-
-- name: Set some facts
- set_fact:
- ands_heketi_lv: "{{ ands_heketi_lv }}"
- when: ands_heketi_lv != ""
-
-- name: Set some facts
- set_fact:
- ands_data_dev: "/dev/mapper/{{ands_data_vg}}-{{ands_data_lv}}"
- when:
- - ands_data_vg != ""
- - ands_data_lv != ""
-
-- name: set some facts
- set_fact:
- ands_heketi_dev: "/dev/mapper/{{ands_heketi_vg}}-{{ands_heketi_lv}}"
- when:
- - ands_heketi_vg != ""
- - ands_heketi_lv != ""
+# Here we set 'openshift_hostname', 'openshift_ip' and other variables
+- name: "Configuring network facts"
+ include_tasks: "network.yml"
-- name: set some facts
+- name: "Confirm that ands facts are configured"
set_fact:
- glusterfs_devices: [ "{{ ands_heketi_dev }}" ]
- when:
- - ands_heketi_vg != ""
- - ands_heketi_lv != ""
-
-- include_tasks: detect_data_path.yml
- when: not ands_data_path is defined
-
-#- command: yum-complete-transaction --cleanup-only
-
+ ands_facts_configured: true
diff --git a/roles/ands_facts/tasks/network.yml b/roles/ands_facts/tasks/network.yml
new file mode 100644
index 0000000..1d0248f
--- /dev/null
+++ b/roles/ands_facts/tasks/network.yml
@@ -0,0 +1,49 @@
+- name: Set network facts
+ set_fact:
+ ands_cluster_domain: "{{ ands_cluster_domain }}"
+ ands_cluster_dot_domain: ".{{ ands_cluster_domain }}"
+ ands_inner_domain: "{{ ands_inner_domain }}"
+ ands_inner_dot_domain: "{{ (ands_inner_domain == ands_none) | ternary('', '.' ~ ands_inner_domain) }}"
+ ands_inner_lb_ip: "{{ ands_openshift_network | ipaddr(ands_inner_lb_id) | ipaddr('address') }}"
+ ands_inner_lb_hostname: "{{ ands_inner_lb_hostname }}"
+ ands_openshift_ip: "{{ ands_openshift_network | ipaddr(ands_host_id) | ipaddr('address') }}"
+ ands_openshift_hostname: "{{ ands_openshift_hostname | default(ands_openshift_set_hostname | ternary(ands_openshift_default_hostname, ands_none)) }}"
+ ands_openshift_public_ip: "{{ (ands_openshift_public_network is defined) | ternary( ands_openshift_public_network | ipaddr(ands_host_id) | ipaddr('address'), ands_openshift_default_ip) }}"
+ ands_openshift_public_hostname: "{{ ands_openshift_public_hostname | default(ands_openshift_set_public_hostname | ternary(ands_openshift_default_hostname, ands_none)) }}"
+ ands_storage_ip: "{{ ands_storage_network | default(ands_openshift_network) | ipaddr(ands_host_id) | ipaddr('address') }}"
+ ands_hostname_storage: "ands_storage{{ ands_host_id }}"
+ ands_hostname_openshift: "ands_openshift{{ ands_host_id }}"
+
+- name: Set more network facts
+ set_fact:
+ ands_openshift_public_fqdn: "{{ (ands_openshift_public_hostname == ands_none) | ternary(ands_none, ands_openshift_public_hostname ~ ands_cluster_dot_domain ) }}"
+ ands_openshift_fqdn: "{{ (ands_openshift_hostname == ands_none) | ternary(ands_none, ands_openshift_hostname ~ ands_inner_dot_domain ) }}"
+ ands_openshift_cluster_fqdn: "{{ ands_inner_lb | ternary(ands_inner_lb_hostname ~ ands_inner_dot_domain, ands_openshift_lb) }}"
+
+- name: "Detect inner network interface"
+ include_tasks: "find_interface_by_ip.yml"
+ vars:
+ var: "ands_openshift_inner_interface"
+ ip: "{{ ands_openshift_ip }}"
+ when:
+ - ands_openshift_inner_interface is not defined
+
+- name: "Detect public network interface"
+ include_tasks: "find_interface_by_ip.yml"
+ vars:
+ var: "ands_openshift_public_interface"
+ ip: "{{ (ands_openshift_public_ip == ands_none) | ternary(ands_default_ip, ands_openshift_public_ip) }}"
+ when:
+ - ands_openshift_public_interface is not defined
+
+- name: Set ipfailover interface
+ set_fact:
+ ands_ipfailover_interface: "{{ ands_openshift_public_interface }}"
+ when: ands_ipfailover_interface is not defined
+
+- name: Set ipfailover inner interface
+ set_fact:
+ ands_ipfailover_inner_interface: "{{ ands_openshift_inner_interface }}"
+ when: ands_ipfailover_inner_interface is not defined
+
+#- debug: msg="{{ hostvars }}"
diff --git a/roles/ands_facts/tasks/storage.yml b/roles/ands_facts/tasks/storage.yml
new file mode 100644
index 0000000..cf995a0
--- /dev/null
+++ b/roles/ands_facts/tasks/storage.yml
@@ -0,0 +1,59 @@
+- include_vars: dir="vars"
+
+- name: Detect Heketi
+ set_fact: ands_storage_domains="{{ ands_storage_domains | union([ands_heketi_domain]) }}"
+ when:
+ - ands_configure_heketi
+ - ands_heketi_domain is defined
+ - ansible_lvm.lvs[ands_heketi_lv] is defined
+
+- name: Set some facts
+ set_fact:
+ ands_storage_servers: "{{ ands_storage_servers }}"
+
+- name: Set some facts
+ set_fact:
+ ands_data_vg: "{{ ands_data_vg }}"
+ when: ands_data_vg != ""
+
+- name: Set some facts
+ set_fact:
+ ands_data_lv: "{{ ands_data_lv }}"
+ when: ands_data_lv != ""
+
+- name: Set some facts
+ set_fact:
+ ands_heketi_vg: "{{ ands_heketi_vg }}"
+ when: ands_heketi_vg != ""
+
+- name: Set some facts
+ set_fact:
+ ands_heketi_lv: "{{ ands_heketi_lv }}"
+ when: ands_heketi_lv != ""
+
+- name: Set some facts
+ set_fact:
+ ands_data_dev: "/dev/mapper/{{ands_data_vg}}-{{ands_data_lv}}"
+ when:
+ - ands_data_vg != ""
+ - ands_data_lv != ""
+
+- name: set some facts
+ set_fact:
+ ands_heketi_dev: "/dev/mapper/{{ands_heketi_vg}}-{{ands_heketi_lv}}"
+ when:
+ - ands_heketi_vg != ""
+ - ands_heketi_lv != ""
+
+- name: set some facts
+ set_fact:
+ glusterfs_devices: [ "{{ ands_heketi_dev }}" ]
+ when:
+ - ands_heketi_vg != ""
+ - ands_heketi_lv != ""
+
+- include_tasks: detect_data_path.yml
+ when: not ands_data_path is defined
+
+#- command: yum-complete-transaction --cleanup-only
+