Add overcloud export role

Adds tripleo_overcloud_export role to run the overcloud export action.

Change-Id: I2066ef542acc0b339f8eb9c3477f68989e44f4c9
This commit is contained in:
Alex Schultz 2020-01-21 15:29:55 -07:00
parent f2467db214
commit 110e58deb8
9 changed files with 260 additions and 0 deletions

View File

@ -0,0 +1,58 @@
tripleo_overcloud_export
========================
A role to run an overcloud export.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_overcloud_export_config_download_dir`: (String) Directory for config-download export data.
* `tripleo_overcloud_export_debug`: (Boolean) Flag to print out the command that is run. Default: False
* `tripleo_overcloud_export_force_overwrite`: (Boolean) Overwrite the output file if it exists. Default: false
* `tripleo_overcloud_export_no_password_excludes`: (Boolean) Do not exclude certain passwords from the export. Default: false
* `tripleo_overcloud_export_os_cloud`: (String) (String) OS_CLOUD value to use when running the command. If `tripleo_os_cloud` is defined, it will be the default. Otherwise the default is ''. This variable takes precedence over `tripleo_overcloud_export_rc_file`.
* `tripleo_overcloud_export_output_file`: (String) Name of the output file for the stack data export.
* `tripleo_overcloud_export_rc_file`: (String) (String) Path to the credential file to use. If `tripleo_rc_file` is defined, it will be the default. Default: "{{ ansible_env.HOME }}/stackrc"
* `tripleo_overcloud_export_stack`: (String) The name of the stakc/plan. Default: overcloud
NOTE: Please note that this command should be run against the undercloud so the
OS_CLOUD or rc file variables should be set to use the 'undercloud' when
calling this role. If you are not defining `tripleo_os_cloud` or `tripleo_rc_file`,
stackrc will be used by default.
Output Variables
----------------
* `tripleo_overcloud_export_output`: (String) The command standard output.
* `tripleo_overcloud_export_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example overcloud export execution playbook
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Get overcloud export
import_role:
name: tripleo_overcloud_export
vars:
tripleo_overcloud_export_stack: overcloud
```
License
-------
Apache-2.0

View File

@ -0,0 +1,11 @@
---
# defaults file for tripleo_overcloud_export
openstack_bin: openstack
tripleo_overcloud_export_config_download_dir:
tripleo_overcloud_export_debug: false
tripleo_overcloud_export_force_overwrite: false
tripleo_overcloud_export_no_password_excludes: false
tripleo_overcloud_export_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_export_output_file:
tripleo_overcloud_export_stack: overcloud
tripleo_overcloud_export_rc_file: "{{ tripleo_rc_file | default(ansible_env.HOME ~ '/stackrc') }}"

View File

@ -0,0 +1,42 @@
---
# Copyright 2019 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.
galaxy_info:
author: OpenStack
description: TripleO Operator Role -- tripleo_overcloud_export
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.8
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: CentOS
versions:
- 7
- 8
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@ -0,0 +1,21 @@
---
driver:
name: delegated
options:
managed: false
ansible_connection_options:
ansible_connection: local
log: true
lint:
name: yamllint
enabled: false
platforms:
- name: instance
provisioner:
name: ansible
scenario:
name: default
test_sequence:
- syntax
- converge
- verify

View File

@ -0,0 +1,87 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include tripleo_overcloud_export"
include_role:
name: "tripleo_overcloud_export"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_export_debug: true
- name: Check role
assert:
that:
- tripleo_overcloud_export_output == "overcloud export --stack overcloud"
- name: Check parameter "tripleo_overcloud_export_stack"
include_role:
name: "tripleo_overcloud_export"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_export_debug: true
tripleo_overcloud_export_stack: test
- name: Assert "tripleo_overcloud_export_stack"
assert:
that:
- tripleo_overcloud_export_output == "overcloud export --stack test"
- name: Check parameter "tripleo_overcloud_export_output_file"
include_role:
name: "tripleo_overcloud_export"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_export_debug: true
tripleo_overcloud_export_output_file: test
- name: Assert "tripleo_overcloud_export_output_file"
assert:
that:
- tripleo_overcloud_export_output == "overcloud export --stack overcloud --output-file test"
- name: Check parameter "tripleo_overcloud_export_force_overwrite"
include_role:
name: "tripleo_overcloud_export"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_export_debug: true
tripleo_overcloud_export_force_overwrite: true
- name: Assert "tripleo_overcloud_export_force_overwrite"
assert:
that:
- tripleo_overcloud_export_output == "overcloud export --stack overcloud --force-overwrite"
- name: Check parameter "tripleo_overcloud_export_config_download_dir"
include_role:
name: "tripleo_overcloud_export"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_export_debug: true
tripleo_overcloud_export_config_download_dir: /tmp
- name: Assert "tripleo_overcloud_export_config_download_dir"
assert:
that:
- tripleo_overcloud_export_output == "overcloud export --stack overcloud --config-download-dir /tmp"
- name: Check parameter "tripleo_overcloud_export_no_password_excludes"
include_role:
name: "tripleo_overcloud_export"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_export_debug: true
tripleo_overcloud_export_no_password_excludes: true
- name: Assert "tripleo_overcloud_export_no_password_excludes"
assert:
that:
- tripleo_overcloud_export_output == "overcloud export --stack overcloud --no-password-excludes"

View File

@ -0,0 +1,26 @@
---
# tasks file for tripleo_overcloud_export
- name: Setup overcloud export facts
set_fact:
_export_cmd: >-
{{ tripleo_overcloud_export_os_cloud | ternary('', "source " ~ tripleo_overcloud_export_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud export
{{ tripleo_overcloud_export_stack | ternary('--stack ' ~ tripleo_overcloud_export_stack, '') }}
{{ tripleo_overcloud_export_output_file | ternary('--output-file ' ~ tripleo_overcloud_export_output_file, '') }}
{{ tripleo_overcloud_export_force_overwrite | ternary('--force-overwrite', '') }}
{{ tripleo_overcloud_export_config_download_dir | ternary('--config-download-dir ' ~ tripleo_overcloud_export_config_download_dir, '') }}
{{ tripleo_overcloud_export_no_password_excludes | ternary('--no-password-excludes', '') }}
- name: Show the overcloud export command
debug:
var: _export_cmd
when: tripleo_overcloud_export_debug|bool
- name: Overcloud export
shell: "{{ _export_cmd }}" # noqa 305
register: tripleo_overcloud_export_result
changed_when: false
- name: Set output fact
set_fact:
tripleo_overcloud_export_output: "{{ tripleo_overcloud_export_result.stdout }}"

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,4 @@
---
- hosts: localhost
roles:
- tripleo_overcloud_export

View File

@ -2,10 +2,12 @@
name: tripleo-operator-molecule-jobs
check:
jobs:
- tripleo-operator-molecule-tripleo_overcloud_export
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
gate:
jobs:
- tripleo-operator-molecule-tripleo_overcloud_export
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- job:
@ -15,6 +17,14 @@
success-url: "reports.html"
failure-url: "reports.html"
- job:
files:
- ^roles/tripleo_overcloud_export/.*
name: tripleo-operator-molecule-tripleo_overcloud_export
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_export
- job:
files:
- ^roles/tripleo_overcloud_node_introspect/.*