|
29 | 29 |
|
30 | 30 | - name: Set default values
|
31 | 31 | ansible.builtin.set_fact:
|
32 |
| - __update_etc_hosts_comment: "{{ ( thishost.node_comment|d('') + ' ' + thishost.hana_site|d('') ) | trim }}" |
| 32 | + __update_etc_hosts_comment: "{{ (thishost.node_comment | d('') + ' ' + thishost.hana_site | d('')) | trim }}" |
33 | 33 | __update_etc_hosts_alias_mode: "{{ thishost.alias_mode | default('merge') }}"
|
34 | 34 |
|
35 | 35 | - name: Prepend Hashtag to comment
|
36 | 36 | when: __update_etc_hosts_comment|length > 0
|
37 | 37 | ansible.builtin.set_fact:
|
38 | 38 | __update_etc_hosts_comment: "# {{ __update_etc_hosts_comment }}"
|
39 | 39 |
|
40 |
| -- name: merge existing aliases with new alis list |
| 40 | +- name: Merge existing aliases with new alis list |
41 | 41 | when: __update_etc_hosts_alias_mode != "overwrite"
|
42 | 42 | block:
|
43 | 43 | - name: Get all existing hostname aliases of {{ thishost.node_ip }}
|
|
52 | 52 | changed_when: false
|
53 | 53 | - name: Add defined aliases
|
54 | 54 | ansible.builtin.set_fact:
|
55 |
| - __update_etc_hosts_aliases: "{{ (__update_etc_hosts_register_aliases.stdout.split(' ') + thishost.aliases|d([]))|unique|join(' ') }}" |
| 55 | + __update_etc_hosts_aliases: "{{ (__update_etc_hosts_register_aliases.stdout.split(' ') + thishost.aliases | d([])) | unique | join(' ') }}" |
56 | 56 |
|
57 | 57 | - name: Overwrite existing aliases
|
58 | 58 | when: __update_etc_hosts_alias_mode == "overwrite"
|
59 | 59 | ansible.builtin.set_fact:
|
60 |
| - __update_etc_hosts_aliases: "{{ thishost.node_aliases|d([])|unique|join(' ') }}" |
| 60 | + __update_etc_hosts_aliases: "{{ thishost.node_aliases | d([]) | unique | join(' ') }}" |
61 | 61 |
|
62 | 62 | - name: Display host and domain name, and IP address before the modification
|
63 | 63 | ansible.builtin.debug:
|
|
90 | 90 | - "More than one line containing {{ thishost.node_ip }}. File {{ __update_etc_hosts_file }} will not be modified."
|
91 | 91 | when:
|
92 | 92 | - not ansible_check_mode
|
93 |
| - - __update_etc_hosts_register_duplicate_ip_check.stdout == 'Duplicate IP entry in {{ __update_etc_hosts_file }}!' |
| 93 | + - __update_etc_hosts_register_duplicate_ip_check.rc == 1 |
94 | 94 |
|
95 | 95 | - name: Ensure that the entry in hosts file is correct
|
96 | 96 | ansible.builtin.lineinfile:
|
|
100 | 100 | backup: true
|
101 | 101 | when:
|
102 | 102 | - not ansible_check_mode
|
103 |
| - - __update_etc_hosts_register_duplicate_ip_check.stdout != 'Duplicate IP entry in {{ __update_etc_hosts_file }}!' |
| 103 | + - __update_etc_hosts_register_duplicate_ip_check.rc == 0 |
104 | 104 |
|
105 | 105 | - name: Check for duplicate or missing entries of hostname and fqdn in {{ __update_etc_hosts_file }}
|
106 | 106 | ansible.builtin.shell: |
|
|
0 commit comments