Skip to content

Commit dd51746

Browse files
authored
Update freeipa_client & server to address RHEL9 (#199)
* Introduce new 'freeipa_sidecar' parameter in playbooks to suppress FreeIPA client configuration changes * Update freeipa_client and freeipa_server roles to restart networking, not restart host, on most configuration changes * Set SELinux to Permissive mode during FreeIPA configurations Signed-off-by: Chuck Levesque <[email protected]>
1 parent a9cdbe9 commit dd51746

File tree

6 files changed

+45
-33
lines changed

6 files changed

+45
-33
lines changed

playbooks/pvc_base_prereqs_ext.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@
180180
become: yes
181181
roles:
182182
- role: cloudera.cluster.infrastructure.krb5_client
183-
when: krb5_kdc_host is defined or 'krb5_server' in groups
183+
when:
184+
- krb5_kdc_host is defined or 'krb5_server' in groups
185+
- not (freeipa_sidecar is defined and freeipa_sidecar)
184186
tags:
185187
- security
186188
- kerberos

playbooks/pvc_base_prereqs_int.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@
140140
become: yes
141141
roles:
142142
- role: cloudera.cluster.prereqs.kerberos
143-
when: krb5_kdc_host is defined or 'krb5_server' in groups
143+
when:
144+
- krb5_kdc_host is defined or 'krb5_server' in groups
145+
- not (freeipa_sidecar is defined and freeipa_sidecar)
144146
tags:
145147
- kerberos
146148
- prereqs

roles/freeipa_client/handlers/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
- name: restart host
18-
ansible.builtin.reboot:
17+
- name: restart network
18+
ansible.builtin.service:
19+
name: NetworkManager
20+
state: restarted

roles/freeipa_client/tasks/main.yml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,37 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
- name: Disable SELinux
17+
- name: Permissive SELinux
1818
ansible.posix.selinux:
19-
state: disabled
20-
notify: restart host
19+
policy: targeted
20+
state: permissive
2121

2222
- name: Set up DNS and networking
2323
when: enable_dns
2424
block:
2525
- name: Update RHEL networking
2626
when: ansible_facts['os_family'] == 'RedHat'
2727
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+
2832
- name: Set cloud-init to preserve hostname (RHEL)
2933
ansible.builtin.lineinfile:
3034
path: /etc/cloud/cloud.cfg
3135
regex: "^(#)?preserve_hostname"
3236
line: "preserve_hostname: 1"
3337
state: present
34-
notify: restart host
38+
when: cloud_cfg.stat.exists
39+
notify: restart network
3540

3641
- name: Set interface config to preserve resolv.conf changes (RHEL)'
3742
ansible.builtin.lineinfile:
3843
path: "/etc/sysconfig/network-scripts/ifcfg-{{ ansible_default_ipv4.interface }}"
3944
regex: "^(#)?PEERDNS"
4045
line: "PEERDNS=no"
4146
state: present
42-
notify: restart host
47+
notify: restart network
4348

4449
- name: Set /etc/NetworkManager/conf.d/disable-resolve.conf-managing.conf (RHEL)
4550
ansible.builtin.copy:
@@ -48,7 +53,7 @@
4853
# Generated by Ansible
4954
[main]
5055
dns=none
51-
notify: restart host
56+
notify: restart network
5257

5358
- name: Set /etc/resolv.conf directly
5459
ansible.builtin.copy:
@@ -57,7 +62,7 @@
5762
# Generated by Ansible
5863
search {{ ipaserver_domain }}
5964
{{ ['nameserver '] | product(ipa_server_ips | sort) | map('join') | join('\n') }}
60-
notify: restart host
65+
notify: restart network
6166

6267
- name: Disable nm-cloud-setup if present
6368
ignore_errors: yes
@@ -67,27 +72,21 @@
6772
loop:
6873
- systemctl disable nm-cloud-setup.service nm-cloud-setup.timer
6974
- systemctl stop nm-cloud-setup.service nm-cloud-setup.timer
70-
- ip rule del prio 30400
7175
- rm -rf /etc/systemd/system/nm-cloud-setup.service.d
7276

73-
- name: Ensure NetworkManager is running to maintain DHCP
74-
ansible.builtin.service:
75-
name: NetworkManager
76-
state: restarted
77-
7877
- name: Set /etc/hostname to the FQDN
7978
ansible.builtin.copy:
8079
content: "{{ inventory_hostname }}"
8180
dest: /etc/hostname
82-
notify: restart host
81+
notify: restart network
8382

8483
- name: Set /etc/hosts
8584
ansible.builtin.copy:
8685
dest: /etc/hosts
8786
content: |
8887
# Set by Ansible
8988
{{ ansible_default_ipv4.address }} {{ inventory_hostname }} {{ inventory_hostname_short }}
90-
notify: restart host
89+
notify: restart network
9190

9291
- name: Check for existence of /etc/dhcp/dhclient.conf
9392
ansible.builtin.stat: path=/etc/dhcp/dhclient.conf
@@ -108,7 +107,7 @@
108107
domain_search: supersede domain-search "{{ ipaserver_domain }}";
109108
domain_name_servers: supersede domain-name-servers {{ ipa_server_ips | sort | union(fallback_nameservers) | join(', ') }};
110109
when: dhclient_conf.stat.exists
111-
notify: restart host
110+
notify: restart network
112111

113112
- name: Flush handlers
114113
ansible.builtin.meta: flush_handlers

roles/freeipa_server/handlers/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
- name: restart host
18-
ansible.builtin.reboot:
17+
- name: restart network
18+
ansible.builtin.service:
19+
name: NetworkManager
20+
state: restarted
1921

2022
- name: restart dns
2123
ansible.builtin.service:

roles/freeipa_server/tasks/main.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
update_cache: yes
4646
state: present
4747

48-
- name: Disable SELinux
48+
- name: Permissive SELinux
4949
ansible.posix.selinux:
50-
state: disabled
51-
notify: restart host
50+
policy: targeted
51+
state: permissive
5252

5353
- name: Install base FreeIPA server packages
5454
ansible.builtin.package:
@@ -61,17 +61,22 @@
6161
- name: Configure RHEL systems
6262
when: ansible_facts['os_family'] == 'RedHat'
6363
block:
64+
- name: Check for existence of /etc/cloud/cloud.cfg
65+
ansible.builtin.stat: path=/etc/cloud/cloud.cfg
66+
register: cloud_cfg
67+
6468
- name: Set cloud-init to preserve hostname (RHEL)
6569
ansible.builtin.lineinfile:
6670
path: /etc/cloud/cloud.cfg
6771
regex: "^(#)?preserve_hostname"
6872
line: "preserve_hostname: 1"
6973
state: present
70-
notify: restart host
74+
when: cloud_cfg.stat.exists
75+
notify: restart network
7176

7277
- name: Check for existence of /etc/NetworkManager/conf.d
7378
ansible.builtin.stat: path=/etc/NetworkManager/conf.d
74-
register: st
79+
register: nm_conf
7580

7681
- name: Set /etc/NetworkManager/conf.d/disable-resolve.conf-managing.conf (RHEL)
7782
ansible.builtin.copy:
@@ -80,8 +85,8 @@
8085
# Generated by Ansible
8186
[main]
8287
dns=none
83-
when: st.stat.exists
84-
notify: restart host
88+
when: nm_conf.stat.exists
89+
notify: restart network
8590

8691
# TODO Either local if dns_provider=freeipa or keep nameserver and update search only
8792
# TODO Convert to ansible.builtin.template with role templates
@@ -93,14 +98,14 @@
9398
search {{ [[name_prefix, domain] | join('.'), domain] | join(' ') }}
9499
nameserver 127.0.0.1
95100
{{ ['nameserver'] | product(ipaserver_resolv_nameservers) | map('join', ' ') | join('\n') }}
96-
notify: restart host
101+
notify: restart network
97102

98103
# TODO Need to check-n-set vs. overwrite (forces reboot...)
99104
- name: Set /etc/hostname to the FQDN
100105
ansible.builtin.copy:
101106
content: "{{ inventory_hostname }}"
102107
dest: /etc/hostname
103-
notify: restart host
108+
notify: restart network
104109

105110
# TODO Need to check-n-set vs. overwrite (forces reboot...)
106111
- name: Set /etc/hosts
@@ -111,7 +116,7 @@
111116
127.0.0.1 localhost
112117
{{ ansible_default_ipv4.address }} {{ inventory_hostname }} {{ inventory_hostname_short }}
113118
backup: yes
114-
notify: restart host
119+
notify: restart network
115120

116121
- name: Check for existence of /etc/dhcp/dhclient.conf
117122
ansible.builtin.stat: path=/etc/dhcp/dhclient.conf
@@ -132,7 +137,7 @@
132137
domain_search: supersede domain-search "{{ [[name_prefix, domain] | join('.'), domain] | join('", "') }}";
133138
domain_name_servers: supersede domain-name-servers 127.0.0.1, {{ ipaserver_resolv_nameservers | join(', ') }};
134139
when: dhclient_conf.stat.exists
135-
notify: restart host
140+
notify: restart network
136141

137142
- name: Flush handlers
138143
ansible.builtin.meta: flush_handlers

0 commit comments

Comments
 (0)