68 lines
2.1 KiB
YAML
68 lines
2.1 KiB
YAML
---
|
|
#
|
|
# Copyright (c) 2019 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# SUB-TASKS DESCRIPTION:
|
|
# These tasks do the preparation specifically for the platform restore
|
|
#
|
|
- block:
|
|
- name: Set config path facts for restore
|
|
set_fact:
|
|
branding_permdir: "{{ config_permdir }}/branding"
|
|
banner_permdir: "{{ config_permdir }}/banner/etc"
|
|
ssh_config_permdir: "{{ config_permdir }}/ssh_config"
|
|
pxe_config_permdir: "{{ config_permdir }}/pxelinux.cfg"
|
|
armada_permdir: "{{ platform_path }}/armada/"
|
|
helm_overrides_permdir: "{{ platform_path + '/helm/' + software_version }}"
|
|
sysinv_config_permdir: "{{ platform_path + '/sysinv/' + software_version }}"
|
|
|
|
# To work around an ansible quirk that regex_replace filter
|
|
# is ignored when it is applied to variables in the command module
|
|
- name: Strip the leading slash in dirname and assign it to a new variable
|
|
set_fact:
|
|
short_branding_permdir: "{{ branding_permdir | regex_replace('^\\/', '') }}"
|
|
short_banner_permdir: "{{ banner_permdir | regex_replace('^\\/', '') }}"
|
|
|
|
- name: Restore branding tar file
|
|
command: >-
|
|
tar -C /opt/branding -xpf {{ target_backup_dir }}/{{ backup_filename }} --transform='s,.*/,,'
|
|
{{ short_branding_permdir }}
|
|
args:
|
|
warn: false
|
|
|
|
- name: Remove unwanted directory
|
|
file:
|
|
path: /opt/branding/branding
|
|
state: absent
|
|
|
|
- name: Look for banner directory in the backup tarball
|
|
shell: "tar -tf {{ target_backup_dir }}/{{ backup_filename }} | grep -F 'banner/etc'"
|
|
args:
|
|
warn: false
|
|
failed_when: false
|
|
register: banner_result
|
|
|
|
- block:
|
|
- name: Create banner directory
|
|
file:
|
|
path: /opt/banner
|
|
state: directory
|
|
|
|
- name: Restore banner files if they exist in the backup tarball
|
|
command: >-
|
|
tar -C /opt/banner -xpf {{ target_backup_dir }}/{{ backup_filename }} --transform='s,.*/,,'
|
|
{{ short_banner_permdir }}
|
|
args:
|
|
warn: false
|
|
|
|
- name: Remove unwanted directory
|
|
file:
|
|
path: /opt/banner/etc
|
|
state: absent
|
|
when: banner_result.rc == 0
|
|
|
|
become: yes
|
|
become_user: root
|