-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathupdate_etchosts.yml
More file actions
27 lines (25 loc) · 1.07 KB
/
update_etchosts.yml
File metadata and controls
27 lines (25 loc) · 1.07 KB
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
---
- name: "SAP HSR - Delete linux entry in /etc/hosts"
shell: sed -i '/linux/d' /etc/hosts
register: clean_etchosts
- name: "SAP HSR - Add Cluster Nodes to /etc/hosts"
lineinfile:
path: /etc/hosts
create: true
state: present
backup: true
line: "{{ item.node_ip }}\t{{ item.node_name }}.{{ sap_ha_install_hana_hsr_fqdn }}\t{{ item.node_name }}"
regexp: (?i)^\s*{{ item.node_ip }}\s+{{ item.node_name }}
loop: "{{ sap_ha_install_hana_hsr_cluster_nodes }}"
loop_control:
label: "{{ item.node_ip }} {{ item.node_name }}.{{ sap_ha_install_hana_hsr_fqdn }} {{ item.node_name }}"
when: clean_etchosts == 0
- name: "SAP HSR - Check /etc/hosts for conflicting entries"
shell: |
awk '(/{{ item.node_name }}/ && !/^{{ item.node_ip }}/) || (/^{{ item.node_ip }}/ && !/{{ item.node_name }}/)' /etc/hosts
register: etchosts_conflict
changed_when: false
failed_when: etchosts_conflict.stdout != ''
loop: "{{ sap_ha_install_hana_hsr_cluster_nodes }}"
loop_control:
label: "Check if {{ item.node_ip }} exists for hosts other than {{ item.node_name }}"