153 lines
4.8 KiB
YAML
153 lines
4.8 KiB
YAML
---
|
|
# Copyright 2021 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: Get the name of the node
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: metalsmith -f value -c Hostname show {{ tripleo_backup_and_restore_overcloud_restore_name }}
|
|
register: instance_name
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Get metalsmith instance informartion
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: metalsmith -f json show {{ instance_name.stdout }}
|
|
register: instance_information
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Parse instance informatation
|
|
set_fact:
|
|
instance_information_json: "{{ instance_information.stdout | from_json }}"
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Get node name
|
|
set_fact:
|
|
node_name: "{{ instance_information_json[instance_name.stdout]['node']['name'] }}"
|
|
node_hostname: "{{ instance_name.stdout }}"
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Set kernel and initrd
|
|
set_fact:
|
|
restore_kernel: "{{ (backup_and_restore_history_path == '') | ternary(node_hostname, backup_and_restore_history_path+'/'+node_hostname) + '.kernel' }}"
|
|
restore_initrd: "{{ (backup_and_restore_history_path == '') | ternary(node_hostname, backup_and_restore_history_path+'/'+node_hostname) + '.initrd.cgz' }}"
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Power off node
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node power off {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Set node in maintenance
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node maintenance set {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Change node settings
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node set \
|
|
--instance-info kernel=file://{{ tripleo_backup_and_restore_ironic_images_path }}/{{ restore_kernel }} \
|
|
--instance-info ramdisk=file://{{ tripleo_backup_and_restore_ironic_images_path }}/{{ restore_initrd }} \
|
|
--instance-info kernel_append_params="unattended" \
|
|
--deploy-interface ramdisk \
|
|
{{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Unset node from maintenance
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node maintenance unset {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Rebuild node
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node rebuild {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Wait node is active
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node show {{ node_name }} --fields provision_state -f value
|
|
register: node_provision_state
|
|
retries: "{{ tripleo_backup_and_restore_restore_retries }}"
|
|
until: node_provision_state.stdout == 'active'
|
|
delay: "{{ tripleo_backup_and_restore_restore_delay }}"
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Wait node is power off
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node show {{ node_name }} --fields power_state -f value
|
|
register: node_power_status
|
|
retries: "{{ tripleo_backup_and_restore_restore_retries }}"
|
|
until: '"off" in node_power_status.stdout'
|
|
delay: "{{ tripleo_backup_and_restore_restore_delay }}"
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Set node to maintenance
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node maintenance set {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Change back configuration node
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node set \
|
|
--instance-info kernel="file://{{ tripleo_backup_and_restore_ironic_images_path }}/overcloud-full.vmlinuz" \
|
|
--instance-info ramdisk="file://{{ tripleo_backup_and_restore_ironic_images_path }}/overcloud-full.initrd" \
|
|
--deploy-interface direct \
|
|
{{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Change boot device to disk
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node boot device set {{ node_name }} disk
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Unset maintenance from node
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node maintenance unset {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|
|
|
|
- name: Power on instance
|
|
environment:
|
|
OS_CLOUD: undercloud
|
|
command: openstack baremetal node power on {{ node_name }}
|
|
tags:
|
|
- bar_restore_image
|