Skip to content

Commit 295b254

Browse files
committed
edpm_iscsid: Move iscsid from container to host
Update the edpm_iscsid tasks to (re)deploy the iscsid daemon on the EDPM host instead of running it in a container. This helps avoid a number of historical customer support issues, and facilitates booting an EDPM host from an iSCSI SAN volume. The new tasks support the following deployment scenarios: - Greenfield - Brownfield, where iscsid was previsouly running in a container - Adoption, where iscsid was previsouly running in a container that was managed by tripleo. Update multipathd and nova_compute volume mounts to not relabel the SELinux context on the iscsi directories. Running iscsid on the host also requires nova_compute to run iscsiadm on the host. Closes: OSPRH-17176
1 parent da6983d commit 295b254

File tree

19 files changed

+201
-182
lines changed

19 files changed

+201
-182
lines changed

roles/edpm_download_cache/tasks/container_images.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,6 @@
88
- edpm_podman
99
- download_cache
1010

11-
- name: Download images for edpm_iscsid role
12-
when: '"nova" in edpm_download_cache_running_services'
13-
ansible.builtin.include_role:
14-
name: osp.edpm.edpm_iscsid
15-
tasks_from: download_cache.yml
16-
tags:
17-
- edpm_iscsid
18-
- download_cache
19-
2011
- name: Download images for edpm_ovn role
2112
when: '"ovn" in edpm_download_cache_running_services'
2213
ansible.builtin.include_role:

roles/edpm_download_cache/tasks/packages.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@
6666
tags:
6767
- edpm_libvirt
6868
- download_cache
69+
70+
- name: Download packages for edpm_iscsid role
71+
# iscsid is part of the "nova" EDPM service
72+
when: '"nova" in edpm_download_cache_running_services'
73+
ansible.builtin.include_role:
74+
name: osp.edpm.edpm_iscsid
75+
tasks_from: download_cache.yml
76+
tags:
77+
- edpm_iscsid
78+
- download_cache

roles/edpm_iscsid/defaults/main.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,13 @@
2020
# All variables within this role should have a prefix of "edpm_iscsid"
2121

2222
# seconds between retries for download tasks
23-
edpm_iscsid_image_download_delay: "{{ edpm_download_delay | default(60) }}"
23+
edpm_iscsid_download_delay: "{{ edpm_download_delay | default(60) }}"
2424

2525
# number of retries for download tasks
26-
edpm_iscsid_image_download_retries: "{{ edpm_download_retries | default(5) }}"
26+
edpm_iscsid_download_retries: "{{ edpm_download_retries | default(5) }}"
2727

28-
edpm_iscsid_debug: "{{ (ansible_verbosity | int) >= 2 | bool }}"
29-
30-
edpm_iscsid_image: "quay.io/podified-antelope-centos9/openstack-iscsid:current-podified"
31-
edpm_iscsid_volumes:
32-
- /var/lib/kolla/config_files/iscsid.json:/var/lib/kolla/config_files/config.json:ro
33-
- /dev:/dev
34-
- /run:/run
35-
- /sys:/sys
36-
- /lib/modules:/lib/modules:ro
37-
- /etc/iscsi:/etc/iscsi:z
38-
- /etc/target:/etc/target:z
39-
- /var/lib/iscsi:/var/lib/iscsi:z
28+
edpm_iscsid_packages:
29+
- iscsi-initiator-utils
4030

4131
edpm_iscsid_chap_algs: >-
4232
{{
@@ -45,5 +35,9 @@ edpm_iscsid_chap_algs: >-
4535
default('check', true) == 'enabled') |
4636
ternary('', ',SHA1,MD5')
4737
}}
48-
# if container health check should be enabled
49-
edpm_iscsid_healthcheck: true
38+
39+
edpm_iscsid_legacy_services:
40+
- tripleo_iscsid.service
41+
- edpm_iscsid.service
42+
43+
edpm_iscsid_tripleo_config_dir: '/var/lib/config-data/puppet-generated/iscsid/etc/iscsi'
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22

3-
- name: Record the iscsid container restart is required
3+
- name: Restart the iscsid service
44
become: true
5-
ansible.builtin.file:
6-
path: /etc/iscsi/.iscsid_restart_required
7-
state: touch
8-
mode: "0600"
5+
ansible.builtin.systemd_service:
6+
name: iscsid
7+
state: restarted

roles/edpm_iscsid/meta/argument_specs.yml

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,33 @@ argument_specs:
44
main:
55
short_description: The main entry point for the edpm_iscsid role.
66
options:
7-
edpm_iscsid_image_download_delay:
7+
edpm_iscsid_download_delay:
88
type: int
9-
default: 5
9+
default: 60
1010
description: The seconds between retries for failed download tasks
11-
edpm_iscsid_image_download_retries:
11+
edpm_iscsid_download_retries:
1212
type: int
1313
default: 5
1414
description: The number of retries for failed download tasks
15-
edpm_iscsid_debug:
16-
type: bool
17-
default: false
18-
description: |
19-
Produce additional text messages describing role operation.
20-
Set to false by default using following template:
21-
{{ (ansible_verbosity | int) >= 2 | bool }}
22-
edpm_iscsid_image:
23-
type: str
24-
default: "quay.io/podified-antelope-centos9/openstack-iscsid:current-podified"
25-
description: URL of the iscsid container image.
26-
edpm_iscsid_volumes:
15+
edpm_iscsid_packages:
2716
type: list
17+
description: The list of packages to install for iscsid.
2818
default:
29-
- /var/lib/kolla/config_files/iscsid.json:/var/lib/kolla/config_files/config.json:ro
30-
- /dev:/dev
31-
- /run:/run
32-
- /sys:/sys
33-
- /lib/modules:/lib/modules:ro
34-
- /etc/iscsi:/etc/iscsi:z
35-
- /etc/target:/etc/target:z
36-
- /var/lib/iscsi:/var/lib/iscsi:z
37-
description: List of iscsid volume mounts with permissions.
19+
- iscsi-initiator-utils
3820
edpm_iscsid_chap_algs:
3921
type: str
4022
default: 'SHA3-256,SHA256,SHA1,MD5'
4123
description: List of allowed CHAP algorithms.
42-
edpm_iscsid_healthcheck:
43-
type: bool
44-
default: true
24+
edpm_iscsid_legacy_services:
25+
type: list
26+
description: |
27+
The list of legacy containerized services associated with adoption
28+
and brownfield deployment scenarios.
29+
default:
30+
- tripleo_iscsid.service
31+
- edpm_iscsid.service
32+
edpm_iscsid_tripleo_config_dir:
33+
type: str
34+
default: '/var/lib/config-data/puppet-generated/iscsid/etc/iscsi'
4535
description: |
46-
Enable container health check injection
36+
The directory containing the iscsid configuration generated by tripleo.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# Copyright 2025 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: Gather services facts
18+
ansible.builtin.service_facts:
19+
20+
- name: Identify legacy iscsid containerized services
21+
ansible.builtin.set_fact:
22+
legacy_iscsid_services: "{{ edpm_iscsid_legacy_services | intersect(ansible_facts.services.keys()) }}"
23+
24+
- name: Clean up legacy iscsid containerized services
25+
become: true
26+
when: legacy_iscsid_services | default([]) | length > 0
27+
block:
28+
- name: Stop and disable legacy iscsid containerized services
29+
# The edpm_tripleo_cleanup role works for stopping and disabling the
30+
# legacy tripleo_iscsid.service (adoption scenario) or edpm_iscsid.service
31+
# (update scenario).
32+
ansible.builtin.include_role:
33+
role: osp.edpm.edpm_tripleo_cleanup
34+
vars:
35+
edpm_old_tripleo_services: "{{ legacy_iscsid_services }}"
36+
37+
- name: Delete containerized healthcheck script
38+
ansible.builtin.file:
39+
path: /var/lib/openstack/healthchecks/iscsid
40+
state: absent

roles/edpm_iscsid/tasks/configure.yml

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

17-
1817
- name: Check if the iSCSI initiator name (IQN) has been reset
18+
become: true
1919
ansible.builtin.stat:
2020
path: /etc/iscsi/.initiator_reset
2121
register: initiator_reset_state
@@ -29,16 +29,10 @@
2929
when: not initiator_reset_state.stat.exists
3030
become: true
3131
block:
32-
3332
- name: Generate a unique IQN
34-
containers.podman.podman_container:
35-
name: iscsid_config
36-
image: "{{ edpm_iscsid_image }}"
37-
rm: true
38-
tty: true
39-
detach: false
40-
command: /usr/sbin/iscsi-iname
33+
ansible.builtin.command: /usr/sbin/iscsi-iname
4134
register: iscsi_iname
35+
changed_when: true
4236

4337
- name: Save the new IQN
4438
ansible.builtin.copy:
@@ -51,21 +45,8 @@
5145
path: /etc/iscsi/.initiator_reset
5246
mode: "0600"
5347
state: touch
54-
55-
- name: Check if /etc/iscsi/iscsid.conf exists on the host
56-
ansible.builtin.stat:
57-
path: /etc/iscsi/iscsid.conf
58-
register: result
59-
60-
- name: Copy iscsid.conf from the iscsid container to the host
61-
when: not result.stat.exists
62-
containers.podman.podman_container:
63-
name: iscsid_config
64-
image: "{{ edpm_iscsid_image }}"
65-
rm: true
66-
command: cp /etc/iscsi/iscsid.conf /host/etc/iscsi/
67-
volume:
68-
- /etc/iscsi:/host/etc/iscsi
48+
notify:
49+
- Restart the iscsid service
6950

7051
- name: Write CHAP algorithms
7152
become: true
@@ -74,4 +55,5 @@
7455
line: "node.session.auth.chap_algs = {{ edpm_iscsid_chap_algs }}"
7556
regexp: "^node.session.auth.chap_algs"
7657
insertafter: "^#node.session.auth.chap.algs"
77-
notify: Record the iscsid container restart is required
58+
notify:
59+
- Restart the iscsid service
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22

3-
- name: Download needed container
4-
containers.podman.podman_image:
5-
name: "{{ edpm_iscsid_image }}"
6-
auth_file: "{{ edpm_download_cache_podman_auth_file }}"
3+
- name: Download iscsid packages
4+
ansible.builtin.dnf:
5+
name: "{{ edpm_iscsid_packages }}"
6+
download_only: true
77
become: true
8-
register: edpm_iscsid_image_download
9-
until: edpm_iscsid_image_download.failed == false
10-
retries: "{{ edpm_iscsid_image_download_retries }}"
11-
delay: "{{ edpm_iscsid_image_download_delay }}"
8+
register: edpm_iscsid_packages_install
9+
until: edpm_iscsid_packages_install is succeeded
10+
retries: "{{ edpm_iscsid_download_retries }}"
11+
delay: "{{ edpm_iscsid_download_delay }}"

roles/edpm_iscsid/tasks/install.yml

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,64 @@
1313
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
16+
17+
- name: Gather ansible_local facts
18+
ansible.builtin.setup:
19+
gather_subset:
20+
- "!all"
21+
- "!min"
22+
- "local"
23+
when:
24+
- ansible_local is not defined
25+
26+
- name: Clean up legacy containerized iscsid
27+
ansible.builtin.include_tasks: cleanup_containers.yml
28+
1629
- name: Run iscsid install tasks with root privileges
1730
become: true
1831
block:
19-
- name: Create persistent directories
20-
ansible.builtin.file:
21-
path: "{{ item.path }}"
22-
state: directory
23-
setype: "{{ item.setype | default(omit) }}"
24-
selevel: "{{ item.selevel | default(omit) }}"
25-
recurse: "{{ item.recurse | default(omit) }}"
26-
mode: "{{ item.mode | default(omit) }}"
27-
loop:
28-
- {'path': /etc/iscsi, 'setype': container_file_t, 'mode': '0755'}
29-
- {'path': /etc/target, 'setype': container_file_t}
30-
- {'path': /var/lib/iscsi, 'setype': container_file_t}
31-
- {'path': /var/lib/config-data, 'setype': container_file_t, 'selevel': s0, 'mode': '0755'}
32-
- {'path': /var/lib/config-data/ansible-generated/iscsid, 'setype': container_file_t, 'mode': '0755'}
33-
34-
- name: Stat /lib/systemd/system/iscsid.socket
32+
- name: Install iscsid packages
33+
tags:
34+
- install
35+
- edpm_iscsid
36+
ansible.builtin.dnf:
37+
name: "{{ edpm_iscsid_packages }}"
38+
state: present
39+
register: edpm_iscsid_packages_install
40+
until: edpm_iscsid_packages_install is succeeded
41+
retries: "{{ edpm_iscsid_download_retries }}"
42+
delay: "{{ edpm_iscsid_download_delay }}"
43+
when: ansible_local.bootc is not defined or not ansible_local.bootc
44+
45+
- name: Detect whether the data plane is being adopted
3546
ansible.builtin.stat:
36-
path: /lib/systemd/system/iscsid.socket
37-
register: stat_iscsid_socket
38-
39-
- name: Stop and disable iscsid.socket service
40-
ansible.builtin.systemd:
41-
name: iscsid.socket
42-
state: stopped
43-
enabled: false
44-
when: stat_iscsid_socket.stat.exists
45-
46-
- name: Gather services facts
47-
ansible.builtin.service_facts:
48-
49-
- name: Stop and disable iscsi.service and iscsi-starter.service
50-
ansible.builtin.systemd:
51-
name: "{{ item }}"
52-
state: stopped
53-
enabled: false
47+
path: "{{ edpm_iscsid_tripleo_config_dir }}"
48+
register: tripleo_iscsid_config_dir
49+
50+
- name: Adopt the iscsid configuration
51+
when:
52+
- tripleo_iscsid_config_dir.stat.exists
53+
- tripleo_iscsid_config_dir.stat.isdir
54+
block:
55+
- name: Copy the containerized iscsid configuration to the host
56+
ansible.builtin.copy:
57+
src: "{{ edpm_iscsid_tripleo_config_dir }}/"
58+
dest: /etc/iscsi
59+
remote_src: true
60+
mode: preserve
61+
62+
- name: Mark the iscsid adoption complete
63+
ansible.builtin.command: |
64+
mv "{{ edpm_iscsid_tripleo_config_dir }}" "{{ edpm_iscsid_tripleo_config_dir }}.adopted"
65+
changed_when: true
66+
67+
- name: Check SELinux context of iSCSI directories
68+
ansible.builtin.command: "/usr/sbin/restorecon -nvr /etc/iscsi /var/lib/iscsi"
69+
changed_when: false
70+
register: iscsi_selinux_status
71+
72+
- name: Restore SELinux context of iSCSI directories
73+
ansible.builtin.command: "/usr/sbin/restorecon -rF /etc/iscsi /var/lib/iscsi"
5474
when:
55-
- ansible_facts.services[item] is defined
56-
- ansible_facts.services[item]["status"] != "not-found"
57-
- ansible_facts.services[item]["status"] == "enabled"
58-
loop:
59-
- iscsi.service
60-
- iscsi-starter.service
75+
- iscsi_selinux_status.stdout_lines | length > 0
76+
changed_when: true

0 commit comments

Comments
 (0)