Skip to content

Commit 129dea2

Browse files
committed
Update edpm_bootstrap for bootc
Exclude some packages and download cache tasks on bootc nodes. Jira: OSPRH-11433 Signed-off-by: James Slagle <[email protected]>
1 parent 8666a98 commit 129dea2

File tree

4 files changed

+141
-94
lines changed

4 files changed

+141
-94
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
# Copyright 2024 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Set selinux state
18+
ansible.posix.selinux:
19+
policy: targeted
20+
state: "{{ edpm_bootstrap_selinux_mode }}"
21+
become: true
22+
23+
- name: Stop NetworkManager from updating resolv.conf
24+
when: ( edpm_bootstrap_network_service == 'NetworkManager' ) and ( not edpm_bootstrap_network_resolvconf_update )
25+
become: true
26+
block:
27+
- name: Set 'dns=none' in /etc/NetworkManager/NetworkManager.conf
28+
community.general.ini_file:
29+
path: /etc/NetworkManager/NetworkManager.conf
30+
state: present
31+
no_extra_spaces: true
32+
section: main
33+
option: dns
34+
value: none
35+
backup: true
36+
mode: '0644'
37+
- name: Set 'rc-manager=unmanaged' in /etc/NetworkManager/NetworkManager.conf
38+
community.general.ini_file:
39+
path: /etc/NetworkManager/NetworkManager.conf
40+
state: present
41+
no_extra_spaces: true
42+
section: main
43+
option: rc-manager
44+
value: unmanaged
45+
backup: true
46+
mode: '0644'
47+
- name: Reload NetworkManager
48+
ansible.builtin.systemd:
49+
name: NetworkManager
50+
state: reloaded
51+
52+
- name: Stop dhclient from updating resolv.conf
53+
become: true
54+
ansible.builtin.copy:
55+
dest: /etc/dhcp/dhclient-enter-hooks
56+
mode: "0755"
57+
content: |
58+
#!/bin/sh
59+
make_resolv_conf() { : ; }
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
# Copyright 2024 Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Ensure /var/log/journal exists
18+
ansible.builtin.file:
19+
path: /var/log/journal
20+
state: directory
21+
mode: '0750'
22+
owner: root
23+
group: root
24+
setype: var_log_t
25+
become: true
26+
27+
- name: Gather services facts
28+
ansible.builtin.service_facts:
29+
30+
- name: Print cloud-init service status
31+
ansible.builtin.debug:
32+
var: ansible_facts.services["cloud-init.service"]
33+
34+
- name: Check if cloud-init is disabled via kernel args
35+
ansible.builtin.lineinfile:
36+
path: /proc/cmdline
37+
line: "cloud-init=disabled"
38+
state: present
39+
check_mode: true
40+
register: cloud_init_vendor_disabled
41+
42+
- name: Wait for cloud-init to finish, if enabled
43+
community.general.cloud_init_data_facts:
44+
filter: status
45+
register: res
46+
until: >
47+
res.cloud_init_data_facts.status.v1.stage is defined and
48+
not res.cloud_init_data_facts.status.v1.stage
49+
retries: 50
50+
delay: 5
51+
when:
52+
- not ansible_check_mode
53+
- ansible_facts.services["cloud-init.service"] is defined
54+
- ansible_facts.services["cloud-init.service"]["status"] != "not-found"
55+
- ansible_facts.services["cloud-init.service"]["state"] == "running"
56+
- ansible_facts.services["cloud-init.service"]["status"] == "enabled"
57+
- cloud_init_vendor_disabled is changed
58+
become: true
59+
60+
- name: Execute bootstrap command
61+
ansible.builtin.import_tasks: bootstrap_command.yml

roles/edpm_bootstrap/tasks/bootstrap.yml

Lines changed: 14 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -14,102 +14,24 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
- name: Ensure /var/log/journal exists
18-
ansible.builtin.file:
19-
path: /var/log/journal
20-
state: directory
21-
mode: '0750'
22-
owner: root
23-
group: root
24-
setype: var_log_t
25-
become: true
17+
- name: Import edpm_bootc role
18+
ansible.builtin.import_role:
19+
name: edpm_bootc
2620

27-
- name: Gather services facts
28-
ansible.builtin.service_facts:
21+
- name: Import common pre packages tasks
22+
ansible.builtin.import_tasks: bootstrap-common-pre-packages.yml
2923

30-
- name: Print cloud-init service status
31-
ansible.builtin.debug:
32-
var: ansible_facts.services["cloud-init.service"]
24+
- name: Include packages tasks
25+
ansible.builtin.include_tasks: packages.yml
26+
when: not bootc
3327

34-
- name: Check if cloud-init is disabled via kernel args
35-
ansible.builtin.lineinfile:
36-
path: /proc/cmdline
37-
line: "cloud-init=disabled"
38-
state: present
39-
check_mode: true
40-
register: cloud_init_vendor_disabled
28+
- name: Import common post packages tasks
29+
ansible.builtin.import_tasks: bootstrap-common-post-packages.yml
4130

42-
- name: Wait for cloud-init to finish, if enabled
43-
community.general.cloud_init_data_facts:
44-
filter: status
45-
register: res
46-
until: >
47-
res.cloud_init_data_facts.status.v1.stage is defined and
48-
not res.cloud_init_data_facts.status.v1.stage
49-
retries: 50
50-
delay: 5
51-
when:
52-
- not ansible_check_mode
53-
- ansible_facts.services["cloud-init.service"] is defined
54-
- ansible_facts.services["cloud-init.service"]["status"] != "not-found"
55-
- ansible_facts.services["cloud-init.service"]["state"] == "running"
56-
- ansible_facts.services["cloud-init.service"]["status"] == "enabled"
57-
- cloud_init_vendor_disabled is changed
58-
become: true
31+
- name: Include swap tasks
32+
ansible.builtin.include_tasks: swap.yml
33+
when: not bootc
5934

60-
- name: Execute bootstrap command
61-
ansible.builtin.import_tasks: bootstrap_command.yml
62-
63-
- name: Import packages tasks
64-
ansible.builtin.import_tasks: packages.yml
65-
66-
- name: Set selinux state
67-
ansible.posix.selinux:
68-
policy: targeted
69-
state: "{{ edpm_bootstrap_selinux_mode }}"
70-
become: true
71-
72-
- name: Stop NetworkManager from updating resolv.conf
73-
when: ( edpm_bootstrap_network_service == 'NetworkManager' ) and ( not edpm_bootstrap_network_resolvconf_update )
74-
become: true
75-
block:
76-
- name: Set 'dns=none' in /etc/NetworkManager/NetworkManager.conf
77-
community.general.ini_file:
78-
path: /etc/NetworkManager/NetworkManager.conf
79-
state: present
80-
no_extra_spaces: true
81-
section: main
82-
option: dns
83-
value: none
84-
backup: true
85-
mode: '0644'
86-
- name: Set 'rc-manager=unmanaged' in /etc/NetworkManager/NetworkManager.conf
87-
community.general.ini_file:
88-
path: /etc/NetworkManager/NetworkManager.conf
89-
state: present
90-
no_extra_spaces: true
91-
section: main
92-
option: rc-manager
93-
value: unmanaged
94-
backup: true
95-
mode: '0644'
96-
- name: Reload NetworkManager
97-
ansible.builtin.systemd:
98-
name: NetworkManager
99-
state: reloaded
100-
101-
- name: Stop dhclient from updating resolv.conf
102-
become: true
103-
ansible.builtin.copy:
104-
dest: /etc/dhcp/dhclient-enter-hooks
105-
mode: "0755"
106-
content: |
107-
#!/bin/sh
108-
make_resolv_conf() { : ; }
109-
110-
- name: Configure swap
111-
ansible.builtin.import_tasks: swap.yml
112-
113-
- name: FIPS tasks
35+
- name: Import FIPS tasks
11436
ansible.builtin.import_tasks: fips.yml
11537
when: edpm_bootstrap_fips_mode != 'check'

roles/edpm_bootstrap/tasks/main.yml

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

17-
- name: Import download_cache tasks
18-
ansible.builtin.import_tasks: download_cache.yml
17+
- name: Import edpm_bootc role
18+
ansible.builtin.import_role:
19+
name: edpm_bootc
20+
21+
- name: Include download_cache tasks
22+
ansible.builtin.include_tasks: download_cache.yml
23+
when: not bootc
1924

2025
- name: Import bootstrap tasks
2126
ansible.builtin.import_tasks: bootstrap.yml

0 commit comments

Comments
 (0)