Skip to content

Commit ea70ed0

Browse files
Merge pull request openstack-k8s-operators#813 from slagle/bootc
Initial bootc support
2 parents 06d9702 + 129dea2 commit ea70ed0

File tree

12 files changed

+291
-94
lines changed

12 files changed

+291
-94
lines changed

roles/edpm_bootc/files/.gitkeep

Whitespace-only changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
argument_specs:
3+
# ./roles/edpm_bootc/tasks/main.yml entry point
4+
main:
5+
short_description: The main entry point for the edpm_bootc role.
6+
description: Multiple lines description
7+
options: {}

roles/edpm_bootc/meta/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
18+
galaxy_info:
19+
author: OpenStack
20+
description: EDPM OpenStack Role -- edpm_bootc
21+
company: Red Hat
22+
license: Apache-2.0
23+
min_ansible_version: '2.14'
24+
namespace: osp
25+
#
26+
# Provide a list of supported platforms, and for each platform a list of versions.
27+
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
28+
# To view available platforms and versions (or releases), visit:
29+
# https://galaxy.ansible.com/api/v1/platforms/
30+
#
31+
platforms:
32+
- name: 'EL'
33+
versions:
34+
- '8'
35+
- '9'
36+
37+
galaxy_tags:
38+
- edpm
39+
40+
41+
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
42+
# if you add dependencies to this list.
43+
dependencies: []
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
collections:
3+
- name: community.general
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
18+
- name: Converge
19+
hosts: all
20+
roles:
21+
- role: "edpm_bootc"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
options:
5+
role-file: collections.yml
6+
driver:
7+
name: podman
8+
platforms:
9+
- command: /sbin/init
10+
dockerfile: ../../../../molecule/common/Containerfile.j2
11+
image: ${EDPM_ANSIBLE_MOLECULE_IMAGE:-"ubi9/ubi-init"}
12+
name: instance
13+
privileged: true
14+
registry:
15+
url: ${EDPM_ANSIBLE_MOLECULE_REGISTRY:-"registry.access.redhat.com"}
16+
ulimits:
17+
- host
18+
provisioner:
19+
log: true
20+
name: ansible
21+
scenario:
22+
test_sequence:
23+
- dependency
24+
- destroy
25+
- create
26+
- prepare
27+
- converge
28+
- destroy
29+
verifier:
30+
name: ansible
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
18+
- name: Prepare
19+
hosts: all
20+
roles:
21+
- role: ../../../../molecule/common/test_deps
22+
- role: env_data

roles/edpm_bootc/tasks/main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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: Check for /bin/bootc
18+
ansible.builtin.stat:
19+
path: /bin/bootc
20+
register: bootc_stat
21+
22+
- name: Set fact for bootc
23+
ansible.builtin.set_fact:
24+
bootc: "{{ bootc_stat.stat.exists }}"
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

0 commit comments

Comments
 (0)