|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
17 | | -- name: Disable SELinux |
| 17 | +- name: Permissive SELinux |
18 | 18 | ansible.posix.selinux: |
19 | | - state: disabled |
20 | | - notify: restart host |
| 19 | + policy: targeted |
| 20 | + state: permissive |
21 | 21 |
|
22 | 22 | - name: Set up DNS and networking |
23 | 23 | when: enable_dns |
24 | 24 | block: |
25 | 25 | - name: Update RHEL networking |
26 | 26 | when: ansible_facts['os_family'] == 'RedHat' |
27 | 27 | block: |
| 28 | + - name: Check for existence of /etc/cloud/cloud.cfg |
| 29 | + ansible.builtin.stat: path=/etc/cloud/cloud.cfg |
| 30 | + register: cloud_cfg |
| 31 | + |
28 | 32 | - name: Set cloud-init to preserve hostname (RHEL) |
29 | 33 | ansible.builtin.lineinfile: |
30 | 34 | path: /etc/cloud/cloud.cfg |
31 | 35 | regex: "^(#)?preserve_hostname" |
32 | 36 | line: "preserve_hostname: 1" |
33 | 37 | state: present |
34 | | - notify: restart host |
| 38 | + when: cloud_cfg.stat.exists |
| 39 | + notify: restart network |
35 | 40 |
|
36 | 41 | - name: Set interface config to preserve resolv.conf changes (RHEL)' |
37 | 42 | ansible.builtin.lineinfile: |
38 | 43 | path: "/etc/sysconfig/network-scripts/ifcfg-{{ ansible_default_ipv4.interface }}" |
39 | 44 | regex: "^(#)?PEERDNS" |
40 | 45 | line: "PEERDNS=no" |
41 | 46 | state: present |
42 | | - notify: restart host |
| 47 | + notify: restart network |
43 | 48 |
|
44 | 49 | - name: Set /etc/NetworkManager/conf.d/disable-resolve.conf-managing.conf (RHEL) |
45 | 50 | ansible.builtin.copy: |
|
48 | 53 | # Generated by Ansible |
49 | 54 | [main] |
50 | 55 | dns=none |
51 | | - notify: restart host |
| 56 | + notify: restart network |
52 | 57 |
|
53 | 58 | - name: Set /etc/resolv.conf directly |
54 | 59 | ansible.builtin.copy: |
|
57 | 62 | # Generated by Ansible |
58 | 63 | search {{ ipaserver_domain }} |
59 | 64 | {{ ['nameserver '] | product(ipa_server_ips | sort) | map('join') | join('\n') }} |
60 | | - notify: restart host |
| 65 | + notify: restart network |
61 | 66 |
|
62 | 67 | - name: Disable nm-cloud-setup if present |
63 | 68 | ignore_errors: yes |
|
67 | 72 | loop: |
68 | 73 | - systemctl disable nm-cloud-setup.service nm-cloud-setup.timer |
69 | 74 | - systemctl stop nm-cloud-setup.service nm-cloud-setup.timer |
70 | | - - ip rule del prio 30400 |
71 | 75 | - rm -rf /etc/systemd/system/nm-cloud-setup.service.d |
72 | 76 |
|
73 | | - - name: Ensure NetworkManager is running to maintain DHCP |
74 | | - ansible.builtin.service: |
75 | | - name: NetworkManager |
76 | | - state: restarted |
77 | | - |
78 | 77 | - name: Set /etc/hostname to the FQDN |
79 | 78 | ansible.builtin.copy: |
80 | 79 | content: "{{ inventory_hostname }}" |
81 | 80 | dest: /etc/hostname |
82 | | - notify: restart host |
| 81 | + notify: restart network |
83 | 82 |
|
84 | 83 | - name: Set /etc/hosts |
85 | 84 | ansible.builtin.copy: |
86 | 85 | dest: /etc/hosts |
87 | 86 | content: | |
88 | 87 | # Set by Ansible |
89 | 88 | {{ ansible_default_ipv4.address }} {{ inventory_hostname }} {{ inventory_hostname_short }} |
90 | | - notify: restart host |
| 89 | + notify: restart network |
91 | 90 |
|
92 | 91 | - name: Check for existence of /etc/dhcp/dhclient.conf |
93 | 92 | ansible.builtin.stat: path=/etc/dhcp/dhclient.conf |
|
108 | 107 | domain_search: supersede domain-search "{{ ipaserver_domain }}"; |
109 | 108 | domain_name_servers: supersede domain-name-servers {{ ipa_server_ips | sort | union(fallback_nameservers) | join(', ') }}; |
110 | 109 | when: dhclient_conf.stat.exists |
111 | | - notify: restart host |
| 110 | + notify: restart network |
112 | 111 |
|
113 | 112 | - name: Flush handlers |
114 | 113 | ansible.builtin.meta: flush_handlers |
|
0 commit comments