Skip to content

Commit 02c69ae

Browse files
committed
New Role: redfish_vbmc_podman
Add a role to set up RedFish Virtual BMC (sushy-emulator) as a podman contaner. The role creates a systemd service so managing start/stop/restart work like any other service. Assisted-By: Claude (claude-4.5-sonnet) Signed-off-by: Harald Jensås <hjensas@redhat.com>
1 parent 9641a79 commit 02c69ae

6 files changed

Lines changed: 337 additions & 0 deletions

File tree

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# redfish_vbmc_podman - ansible role
2+
3+
Role to deploy sushy-emulator (RedFish Virtual BMC) service as a Podman container
4+
on a target host.
5+
6+
The emulator is configured with the OpenStack driver as the backend. This role
7+
runs sushy-emulator as a systemd-managed podman container for automatic startup
8+
and management.
9+
10+
## Requirements
11+
12+
- Podman installed on the target host
13+
- OpenStack clouds.yaml configuration file accessible on the target host
14+
- httpd-tools package (for htpasswd generation)
15+
16+
**Note**: The `redfish_vbmc_podman_cloud_config_dir` variable should point to the directory containing `clouds.yaml` on the target host where the container will run. By default, this matches the location where the `controller` role places the clouds.yaml file (`/home/zuul/.hotcloud`).
17+
18+
## Role Variables
19+
20+
### Required Variables
21+
22+
| Variable | Description |
23+
|----------|-------------|
24+
| `redfish_vbmc_podman_instances_uuids` | List of OpenStack instance UUIDs to expose via RedFish API |
25+
26+
### Optional Variables
27+
28+
| Variable | Default | Description |
29+
|----------|---------|-------------|
30+
| `redfish_vbmc_podman_os_cloud` | `default` | OpenStack cloud name from clouds.yaml |
31+
| `redfish_vbmc_podman_cloud_config_dir` | `/home/zuul/.hotcloud` | Path to directory containing clouds.yaml |
32+
| `redfish_vbmc_podman_username` | `admin` | RedFish API username |
33+
| `redfish_vbmc_podman_password` | `password` | RedFish API password |
34+
| `redfish_vbmc_podman_image` | `quay.io/rhn_gps_hjensas/sushy-tools:dev-1761151453` | Container image to use |
35+
| `redfish_vbmc_podman_listen_port` | `8000` | Port to expose on the host |
36+
| `redfish_vbmc_podman_config_dir` | `/etc/sushy-emulator` | Configuration directory on host |
37+
| `redfish_vbmc_podman_openstack_config_dir` | `/etc/openstack` | OpenStack config mount point in container |
38+
| `redfish_vbmc_podman_debug` | `true` | Enable debug logging |
39+
| `redfish_vbmc_podman_vmedia_file_upload` | `true` | Enable file upload for virtual media |
40+
| `redfish_vbmc_podman_vmedia_delay_eject` | `true` | Delay rebuild on virtual media eject |
41+
| `redfish_vbmc_podman_ignore_boot_device` | `false` | Ignore boot device instructions |
42+
43+
## Dependencies
44+
45+
None
46+
47+
## Example Playbook
48+
49+
```yaml
50+
- name: Install RedFish Virtual BMC with Podman
51+
hosts: controller-0
52+
gather_facts: true
53+
strategy: linear
54+
pre_tasks:
55+
- name: Load stack outputs from file
56+
ansible.builtin.include_vars:
57+
file: "{{ stack_name }}-outputs.yaml"
58+
name: stack_outputs
59+
delegate_to: localhost
60+
61+
roles:
62+
- role: redfish_vbmc_podman
63+
when:
64+
- stack_outputs.sushy_emulator_uuids | default({}) | length > 0
65+
vars:
66+
redfish_vbmc_podman_instances_uuids: "{{ stack_outputs.sushy_emulator_uuids.values() }}"
67+
redfish_vbmc_podman_os_cloud: default
68+
```
69+
70+
## Testing
71+
72+
After deployment, test the RedFish API:
73+
74+
```bash
75+
# Test the API endpoint
76+
curl -u admin:password http://controller-0.example.com:8000/redfish/v1/Systems/
77+
```
78+
79+
Expected response:
80+
81+
```json
82+
{
83+
"@odata.type": "#ComputerSystemCollection.ComputerSystemCollection",
84+
"Name": "Computer System Collection",
85+
"Members@odata.count": 2,
86+
"Members": [
87+
{
88+
"@odata.id": "/redfish/v1/Systems/50cd91c3-380a-423d-80c4-8d65002c96ec"
89+
},
90+
{
91+
"@odata.id": "/redfish/v1/Systems/b6e20780-cb52-4491-96ae-2a817944dbd2"
92+
}
93+
],
94+
"@odata.context": "/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection",
95+
"@odata.id": "/redfish/v1/Systems",
96+
"@Redfish.Copyright": "Copyright 2014-2016 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
97+
}
98+
```
99+
100+
## Management Commands
101+
102+
Useful commands for managing the sushy-emulator service:
103+
104+
```bash
105+
# Check container status
106+
sudo podman ps
107+
108+
# View logs
109+
sudo podman logs sushy-emulator
110+
111+
# Restart the service
112+
sudo systemctl restart sushy-emulator
113+
114+
# Check service status
115+
sudo systemctl status sushy-emulator
116+
117+
# Stop the service
118+
sudo systemctl stop sushy-emulator
119+
120+
# Start the service
121+
sudo systemctl start sushy-emulator
122+
```
123+
124+
## License
125+
126+
Apache License, Version 2.0
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# Copyright 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+
# OpenStack cloud configuration
18+
redfish_vbmc_podman_os_cloud: default
19+
redfish_vbmc_podman_cloud_config_dir: "/home/zuul/.hotcloud"
20+
21+
# Authentication
22+
redfish_vbmc_podman_username: admin
23+
redfish_vbmc_podman_password: password
24+
25+
# Instance filtering
26+
redfish_vbmc_podman_instances_uuids: []
27+
28+
# Container configuration
29+
redfish_vbmc_podman_image: quay.io/rhn_gps_hjensas/sushy-tools:dev-1761151453
30+
redfish_vbmc_podman_listen_port: 8000
31+
32+
# Paths
33+
redfish_vbmc_podman_config_dir: /etc/sushy-emulator
34+
redfish_vbmc_podman_openstack_config_dir: /etc/openstack
35+
36+
# Sushy-emulator configuration options
37+
redfish_vbmc_podman_debug: true
38+
redfish_vbmc_podman_vmedia_file_upload: true
39+
redfish_vbmc_podman_vmedia_delay_eject: true
40+
redfish_vbmc_podman_ignore_boot_device: false
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# Copyright 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: Restart sushy-emulator service
18+
become: true
19+
ansible.builtin.systemd_service:
20+
name: sushy-emulator
21+
state: restarted
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
# Copyright 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: Install package requirements
18+
become: true
19+
ansible.builtin.dnf:
20+
name:
21+
- httpd-tools
22+
- podman
23+
state: present
24+
25+
- name: Create sushy-emulator configuration directory
26+
become: true
27+
ansible.builtin.file:
28+
path: "{{ redfish_vbmc_podman_config_dir }}"
29+
state: directory
30+
mode: '0755'
31+
owner: root
32+
group: root
33+
34+
- name: Generate htpasswd
35+
register: _htpasswd
36+
ansible.builtin.command:
37+
cmd: >-
38+
htpasswd -nbB
39+
{{ redfish_vbmc_podman_username | quote }}
40+
{{ redfish_vbmc_podman_password | quote }}
41+
changed_when: false
42+
43+
- name: Create htpasswd file
44+
become: true
45+
ansible.builtin.copy:
46+
content: "{{ _htpasswd.stdout + '\n' }}"
47+
dest: "{{ redfish_vbmc_podman_config_dir }}/.htpasswd"
48+
mode: '0600'
49+
owner: root
50+
group: root
51+
notify: Restart sushy-emulator service
52+
53+
- name: Create sushy-emulator config file
54+
become: true
55+
ansible.builtin.template:
56+
src: sushy-emulator.conf.j2
57+
dest: "{{ redfish_vbmc_podman_config_dir }}/config.conf"
58+
mode: '0644'
59+
owner: root
60+
group: root
61+
notify: Restart sushy-emulator service
62+
63+
- name: Deploy systemd service file for sushy-emulator
64+
become: true
65+
ansible.builtin.template:
66+
src: sushy-emulator.service.j2
67+
dest: /etc/systemd/system/sushy-emulator.service
68+
mode: '0644'
69+
owner: root
70+
group: root
71+
notify: Restart sushy-emulator service
72+
73+
- name: Enable and start sushy-emulator service
74+
become: true
75+
ansible.builtin.systemd_service:
76+
name: sushy-emulator
77+
enabled: true
78+
state: started
79+
daemon_reload: true
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Sushy-emulator configuration file
2+
# Generated by Ansible - do not edit manually
3+
4+
# Listen on all local IP interfaces
5+
SUSHY_EMULATOR_LISTEN_IP = '::'
6+
7+
# Bind to TCP port 8000
8+
SUSHY_EMULATOR_LISTEN_PORT = 8000
9+
10+
# Serve this SSL certificate to the clients
11+
SUSHY_EMULATOR_SSL_CERT = None
12+
13+
# If SSL certificate is being served, this is its RSA private key
14+
SUSHY_EMULATOR_SSL_KEY = None
15+
16+
# If authentication is desired, set this to an htpasswd file.
17+
SUSHY_EMULATOR_AUTH_FILE = '/etc/sushy-emulator/.htpasswd'
18+
19+
# The OpenStack cloud ID to use. This option enables OpenStack driver.
20+
SUSHY_EMULATOR_OS_CLOUD = '{{ redfish_vbmc_podman_os_cloud }}'
21+
22+
# If image should created via file upload instead of web-download based image
23+
# import OpenStack cloud virtual media
24+
SUSHY_EMULATOR_OS_VMEDIA_IMAGE_FILE_UPLOAD = {{ redfish_vbmc_podman_vmedia_file_upload | bool }}
25+
26+
# When set to true, the instance rebuild on virtual media eject
27+
# is delayed until the next a RedFish power action.
28+
SUSHY_EMULATOR_OS_VMEDIA_DELAY_EJECT = {{ redfish_vbmc_podman_vmedia_delay_eject | bool }}
29+
30+
# Instruct the libvirt driver to ignore any instructions to
31+
# set the boot device. Allowing the UEFI firmware to instead
32+
# rely on the EFI Boot Manager
33+
# Note: This sets the legacy boot element to dev="fd"
34+
# and relies on the floppy not existing, it likely won't work
35+
# your VM has a floppy drive.
36+
SUSHY_EMULATOR_IGNORE_BOOT_DEVICE = {{ redfish_vbmc_podman_ignore_boot_device | bool }}
37+
38+
# This list contains the identities of instances that the driver will filter by.
39+
# It is useful in a tenant environment where only some instances represent
40+
# virtual baremetal.
41+
SUSHY_EMULATOR_ALLOWED_INSTANCES = {{ redfish_vbmc_podman_instances_uuids }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{% set sushy_cmd = '/usr/local/bin/sushy-emulator' -%}
2+
{% set sushy_args = [] -%}
3+
{% if redfish_vbmc_podman_debug -%}
4+
{% set _ = sushy_args.append('--debug') -%}
5+
{% endif -%}
6+
{% set _ = sushy_args.append('--config /etc/sushy-emulator/config.conf') -%}
7+
[Unit]
8+
Description=Sushy Emulator - RedFish Virtual BMC
9+
After=network-online.target
10+
Wants=network-online.target
11+
12+
[Service]
13+
Environment=PODMAN_SYSTEMD_UNIT=%n
14+
Restart=always
15+
TimeoutStopSec=70
16+
ExecStartPre=/usr/bin/podman pull {{ redfish_vbmc_podman_image }}
17+
ExecStartPre=/usr/bin/podman rm -f sushy-emulator
18+
ExecStart=/usr/bin/podman run \
19+
--name sushy-emulator \
20+
--network host \
21+
--replace \
22+
-v {{ redfish_vbmc_podman_config_dir }}:/etc/sushy-emulator:ro,z \
23+
-v {{ redfish_vbmc_podman_cloud_config_dir }}:{{ redfish_vbmc_podman_openstack_config_dir }}:ro,z \
24+
{{ redfish_vbmc_podman_image }} \
25+
{{ sushy_cmd }} {{ sushy_args | join(' ') }}
26+
ExecStop=/usr/bin/podman stop -t 10 sushy-emulator
27+
ExecStopPost=/usr/bin/podman rm -f sushy-emulator
28+
29+
[Install]
30+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)