summaryrefslogtreecommitdiffstats
path: root/roles/ands_network/tasks/common.yml
blob: 03d9fb47579be01b8ac43f3d46305e910c80198b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#- name: Remove obsolte hostnames from /etc/hosts
#  lineinfile: dest="/etc/hosts" regexp="{{ hostvars[item]['openshift_hostname'] }}" state="absent"
#  when: 
#    - hostvars[item]['openshift_hostname'] | default(ands_none) != ands_none
#    - hostvars[item]['ands_facts_configured'] is defined
#  with_inventory_hostnames:
#    - nodes
#    - new_nodes

# This will not work properly unless 'ands_facts' are executed on all nodes.... This is checked by evaluating if 'ands_openshift_fqdn' is defined
- name: Configure all cluster hostnames in /etc/hosts
  lineinfile: dest="/etc/hosts" line="{{ ip }} {{ fqdn }} {{ hostname }}" regexp="{{ fqdn }}" state="present"
  when: 
    - hostvars[item]['ands_openshift_fqdn'] | default(ands_none) != ands_none
    - hostvars[item]['ands_facts_configured'] is defined
  vars:
    ip: "{{ hostvars[item]['ands_openshift_ip'] }}"
    fqdn: "{{ hostvars[item]['ands_openshift_fqdn'] }}"
    hostname: "{{ fqdn.split('.')[0] }}"
  with_inventory_hostnames:
    - nodes
    - new_nodes

# This brakes communication of containers with KaaS cluster (as 127.0.0.1 is not valid in container context, but resolved like that nethertheless)
# DISABLED on 2019.10.10: I guess this is not that big a deal of extra communication. Technically, in futre we can put here actual ip of the node.
#- name: Provision /etc/hosts to ensure that all masters servers are accessing Master API on loopback device
#  lineinfile: dest="/etc/hosts" line="127.0.0.1 {{ openshift_master_cluster_hostname }}" regexp=".*{{ openshift_master_cluster_hostname }}$" state="present"
#  when: ('masters' in group_names or 'new_masters' in group_names)
#  register: result

- name: Provision /etc/hosts with load-balance IP on non master servers
  lineinfile: dest="/etc/hosts" line="{{ ands_inner_lb_ip }} {{ openshift_master_cluster_hostname }}" regexp=".*{{ openshift_master_cluster_hostname }}$" state="present"
  when: (result | skipped) and (ands_use_inner_lb | default(false))

- name: Provision inner load-balancer hostname in /etc/hosts
  lineinfile: dest="/etc/hosts" line="{{ ands_inner_lb_ip }} {{ ands_inner_lb_hostname }} {{ ands_inner_lb_fqdn }}" regexp=".*{{ ands_inner_lb_fqdn }}$" state="present"
  when: openshift_master_cluster_hostname != ands_inner_lb_fqdn

- name: Register openshift_dns_ip in /etc/hosts
  lineinfile: dest="/etc/hosts" line="{{ openshift_dns_ip }} openshift_dns_ip" regexp="openshift_dns_ip$" state="present"