tenks/ansible/node_bmc.yml
Mark Goddard 13de0edd6c Install virtualbmc to system when SELinux is enabled
CentOS 8 nodepool images come with SELinux enabled, and prevent systemd
from accessing files in users' home directories. This prevents vbmcd
from starting.

To resolve this, install virtualbmc to the system when SELinux is
enabled.

Change-Id: I5d30aca2b1e1ae897568f6e11fceda39e0b06e17
2020-02-27 15:47:44 +00:00

59 lines
2.2 KiB
YAML

---
- hosts: localhost
tags:
- node-bmc
tasks:
- name: Load state from file
include_vars:
file: "{{ state_file_path }}"
name: tenks_state
- name: Perform Virtual BMC configuration
hosts: libvirt
tags:
- node-bmc
vars:
# List of ironic drivers that require virtualbmc.
vbmc_drivers: >-
{{ bmc_emulators.items() |
selectattr('1', 'eq', 'virtualbmc') |
map(attribute='0') |
list }}
# List of ironic nodes using drivers that require virtualbmc.
vbmc_nodes: >-
{{ hostvars.localhost.tenks_state[inventory_hostname].nodes |
default([]) |
selectattr('ironic_driver', 'in', vbmc_drivers) |
list }}
tasks:
- name: Check that enough ports are available for Virtual BMC
fail:
msg: >
{{ vbmc_nodes | count }} nodes were specified to be added to Virtual
BMC, but only {{ ipmi_port_range_end - ipmi_port_range_start }} ports
are available for use by Virtual BMC.
when: >-
(vbmc_nodes | count) > (ipmi_port_range_end - ipmi_port_range_start)
- name: Register domains with Virtual BMC
include_role:
name: virtualbmc-domain
vars:
vbmc_domain: "{{ domain.name }}"
vbmc_libvirt_uri: "{{ libvirt_local_uri }}"
vbmc_ipmi_address: "{{ ipmi_address }}"
vbmc_ipmi_username: "{{ ipmi_username }}"
vbmc_ipmi_password: "{{ ipmi_password }}"
vbmc_ipmi_port: "{{ domain.ipmi_port }}"
# NOTE(mgoddard): On CentOS 8 if SELinux is enabled, install virtualbmc
# to the system rather than a virtualenv. SELinux prevents systemd from
# accessing files in users' home directories.
selinux_enabled: "{{ ansible_selinux.status | default('disabled') == 'enabled' }}"
is_centos8: "{{ ansible_os_family == 'RedHat' and ansible_distribution_major_version | int == 8 }}"
vbmc_virtualenv_path: "{{ '' if is_centos8 and selinux_enabled else virtualenv_path }}"
vbmc_log_directory: "{{ log_directory }}"
vbmc_state: "{{ domain.get('state', 'present') }}"
loop: "{{ vbmc_nodes | sort(attribute='name') | list }}"
loop_control:
loop_var: domain