--- # Copyright Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Converge hosts: all roles: - role: virtualbmc tasks: - name: Inject compute-0 in VBMC vars: cifmw_virtualbmc_machine: "cifmw-compute-0" cifmw_virtualbmc_ipmi_port: >- {{ cifmw_virtualbmc_ipmi_base_port + 1 }} cifmw_virtualbmc_action: 'add' ansible.builtin.import_role: name: virtualbmc tasks_from: manage_host - name: Stop VM using IPMI ansible.builtin.command: cmd: >- ipmitool -I lanplus -U admin -P password -H 127.0.0.1 -p 6241 power off - name: List VMs from the hypervisor register: _vms community.libvirt.virt: command: info name: "cifmw-compute-0" - name: Ensure VM is stopped ansible.builtin.assert: that: - _vms['cifmw-compute-0'].state == 'shutdown' - name: Get known hosts ansible.builtin.import_role: name: virtualbmc tasks_from: list_hosts.yml - name: Ensure we have the needed fact ansible.builtin.assert: that: - cifmw_virtualbmc_known_hosts is defined - cifmw_virtualbmc_known_hosts | length != 0 - name: Expose known hosts ansible.builtin.debug: var: cifmw_virtualbmc_known_hosts - name: Remove compute-0 from VBMC vars: cifmw_virtualbmc_machine: "cifmw-compute-0" cifmw_virtualbmc_action: 'delete' ansible.builtin.import_role: name: virtualbmc tasks_from: manage_host - name: Get known hosts ansible.builtin.import_role: name: virtualbmc tasks_from: list_hosts.yml - name: Ensure we have the needed fact ansible.builtin.assert: that: - cifmw_virtualbmc_known_hosts is defined - cifmw_virtualbmc_known_hosts | length == 0