There are two cases when we may want to delete things: 1. if a desired node configuration or spec changes, we delete existing node resources. 2. if we use the teardown.yml playbook, cmd == teardown, delete everything, including global state. In both cases, Tenks state (state.yml), all nodes to be deleted are given a 'state' of absent'. We should therefore use this rather than the 'cmd' variable which only works in the latter case. Change-Id: Icc033340c7fd882e61d90e3d086f7ba4a5b673bf Story: 2004907 Task: 29257
50 lines
1.7 KiB
YAML
50 lines
1.7 KiB
YAML
---
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: Load state from file
|
|
include_vars:
|
|
file: "{{ state_file_path }}"
|
|
name: tenks_state
|
|
|
|
- name: Perform Virtual BMC configuration
|
|
hosts: libvirt
|
|
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 }}"
|
|
vbmc_virtualenv_path: "{{ 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
|