ansible-playbooks/playbookconfig/src/playbooks/roles/backup-restore/prepare-env/tasks/main.yml

45 lines
1.3 KiB
YAML

---
#
# Copyright (c) 2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# ROLE DESCRIPTION:
# This role contains common components (tasks, vars, etc.) that
# can be shared by all the backup and restore playbooks.
- name: Check archive dir
stat:
path: "{{ backup_dir }}"
register: backup_dir_result
- name: Fail if archive dir does not exist
fail:
msg: " Archive directory {{ backup_dir }} does not exist!"
when: backup_dir_result.stat.exists == false
- name: Retrieve software version number
# lookup module does not work with /etc/build.info as it does not have ini
# format. Resort to shell source.
shell: source /etc/build.info; echo $SW_VERSION
register: sw_version_result
- name: Fail if software version is not defined
fail:
msg: "SW_VERSION is missing in /etc/build.info"
when: sw_version_result.stdout_lines|length == 0
- name: Retrieve system type
shell: source /etc/platform/platform.conf; echo $system_type
register: system_type_result
- name: Fail if system type is not defined
fail:
msg: "system_type is missing in /etc/platform/platform.conf"
when: system_type_result.stdout_lines|length == 0
- name: Set software version fact
set_fact:
software_version: "{{ sw_version_result.stdout_lines[0] }}"
system_type: "{{ system_type_result.stdout_lines[0] }}"