Add overcloud config download

Adds tripleo_ovecloud_config_download to wrap the config download
command.

Change-Id: I4285e2a02c2e8d4e988c374e27ee77169416774b
This commit is contained in:
Alex Schultz 2020-03-11 16:32:14 -06:00
parent 9aaec8e4e7
commit 12039affd1
10 changed files with 289 additions and 0 deletions

View File

@ -0,0 +1,60 @@
tripleo_overcloud_config_download
=================================
A role to perform an overcloud config download.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_overcloud_config_download_config_dir`: (String) Directory where the files will be downloaded to
* `tripleo_overcloud_config_download_config_type`: (String) Type of object config to extract from the deployment
* `tripleo_overcloud_config_download_debug`: (Boolean) Flag to print out the delete command. Default: False
* `tripleo_overcloud_config_download_home_dir`: (String) Home directory to where the command is run from. Default: "{{ ansible_env.HOME }}"
* `tripleo_overcloud_config_download_log_combine`: (Boolean) Flag to enable captching stderr with stdout. Default: true
* `tripleo_overcloud_config_download_log_output`: (Boolean) Flag to enable logging to a file. Since the output of this command can be large, it is not recommended to disable this. Default: true
* `tripleo_overcloud_config_download_log`: (String) Path to a log file for the command output. Default: "{{ tripleo_overcloud_config_download_home_dir }}/overcloud_config_download.log"
* `tripleo_overcloud_config_download_name`: (String) Name of the plan
* `tripleo_overcloud_config_download_no_preserve_config`: (Boolean) If set to `true` the config dir will be removed prior to download. Default: false
* `tripleo_overcloud_config_download_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_config_download_rc_file`.
* `tripleo_overcloud_config_download_poll`: (Integer) Number of seconds to wait between each checks to see if the command has completed. Default: 10
* `tripleo_overcloud_config_download_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_config_download_timeout`: (Integer) Number in seconds to wait for the ansible execution of the command to finish. Default: 3600
Output Variables
----------------
* `tripleo_overcloud_config_download_output`: (String) The command standard output.
* `tripleo_overcloud_config_download_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example config download
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: overcloud config download
import_role:
name: tripleo_overcloud_config_download
var:
tripleo_overcloud_config_download_debug: true
tripleo_overcloud_config_download_name: overcloud
tripleo_overcloud_config_download_config_dir: /home/stack/config
```
License
-------
Apache-2.0

View File

@ -0,0 +1,16 @@
---
# defaults file for tripleo_overcloud_config_download
openstack_bin: openstack
tripleo_overcloud_config_download_config_dir:
tripleo_overcloud_config_download_config_type:
tripleo_overcloud_config_download_debug: false
tripleo_overcloud_config_download_home_dir: "{{ ansible_env.HOME }}"
tripleo_overcloud_config_download_log: "{{ tripleo_overcloud_config_download_home_dir }}/overcloud_config_download.log"
tripleo_overcloud_config_download_log_combine: true
tripleo_overcloud_config_download_log_output: true
tripleo_overcloud_config_download_name:
tripleo_overcloud_config_download_no_preserve_config: false
tripleo_overcloud_config_download_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_config_download_poll: 10
tripleo_overcloud_config_download_rc_file: "{{ tripleo_rc_file | default(ansible_env.HOME ~ '/stackrc') }}"
tripleo_overcloud_config_download_timeout: 3600

View File

@ -0,0 +1,42 @@
---
# Copyright 2020 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_config_download
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,69 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_config_download_log_output: false
tripleo_overcloud_config_download_poll: 1
tripleo_overcloud_config_download_debug: true
tasks:
- name: "Include tripleo_overcloud_config_download"
include_role:
name: "tripleo_overcloud_config_download"
- name: Check role
assert:
that:
- tripleo_overcloud_config_download_output == "overcloud config download"
- name: Assert "tripleo_overcloud_config_download_name"
include_role:
name: "tripleo_overcloud_config_download"
vars:
tripleo_overcloud_config_download_name: foo
- name: Verify tripleo_overcloud_config_download_name
assert:
that:
- tripleo_overcloud_config_download_output ==
"overcloud config download --name foo"
- name: Assert "tripleo_overcloud_config_download_config_dir"
include_role:
name: "tripleo_overcloud_config_download"
vars:
tripleo_overcloud_config_download_config_dir: /foo
- name: Verify tripleo_overcloud_config_download_config_dir
assert:
that:
- tripleo_overcloud_config_download_output ==
"overcloud config download --config-dir /foo"
- name: Assert "tripleo_overcloud_config_download_config_type"
include_role:
name: "tripleo_overcloud_config_download"
vars:
tripleo_overcloud_config_download_config_type: bar
- name: Verify tripleo_overcloud_config_download_config_type
assert:
that:
- tripleo_overcloud_config_download_output ==
"overcloud config download --config-type bar"
- name: Assert "tripleo_overcloud_config_download_no_preserve_config"
include_role:
name: "tripleo_overcloud_config_download"
vars:
tripleo_overcloud_config_download_no_preserve_config: true
- name: Verify tripleo_overcloud_config_download_no_preserve_config
assert:
that:
- tripleo_overcloud_config_download_output ==
"overcloud config download --no-preserve-config"

View File

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

View File

@ -0,0 +1,8 @@
---
- name: Prepare
hosts: all
tasks:
- name: Include molecule prep
include_role:
name: test_molecule_prep

View File

@ -0,0 +1,53 @@
---
# tasks file for _skeleton
- name: Set overcloud config download facts
set_fact:
_download_cmd: >-
{{ tripleo_overcloud_config_download_os_cloud | ternary('', "source " ~ tripleo_overcloud_config_download_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud config download
{{ tripleo_overcloud_config_download_name | ternary('--name $DOWNLOAD_NAME', '') }}
{{ tripleo_overcloud_config_download_config_dir | ternary('--config-dir $DOWNLOAD_CONFIG_DIR', '') }}
{{ tripleo_overcloud_config_download_config_type | ternary('--config-type $DOWNLOAD_CONFIG_TYPE', '') }}
{{ tripleo_overcloud_config_download_no_preserve_config | ternary('--no-preserve-config', '') }}
{{ tripleo_overcloud_config_download_log_output | ternary((">" ~ tripleo_overcloud_config_download_log), '') }}
{{ tripleo_overcloud_config_download_log_combine | ternary("2>&1", '') }}
_download_env:
DOWNLOAD_NAME: "{{ tripleo_overcloud_config_download_name | quote }}"
DOWNLOAD_CONFIG_DIR: "{{ tripleo_overcloud_config_download_config_dir | quote }}"
DOWNLOAD_CONFIG_TYPE: "{{ tripleo_overcloud_config_download_config_type | quote }}"
OS_CLOUD: "{{ tripleo_overcloud_config_download_os_cloud }}"
- name: Preserve existing log file if exists
timestamp_file:
path: "{{ tripleo_overcloud_config_download_log }}"
when: tripleo_overcloud_config_download_log_output|bool
- name: Show debug information
when: tripleo_overcloud_config_download_debug|bool
block:
- name: Show the command
debug:
var: _download_cmd
- name: Show the environment
debug:
var: _download_env
- name: Run overcloud config download
shell: "{{ _download_cmd }}" # noqa 305
environment: "{{ _download_env }}"
args:
executable: /bin/bash
chdir: "{{ tripleo_overcloud_config_download_home_dir }}"
warn: false
register: tripleo_overcloud_config_download_result
async: "{{ tripleo_overcloud_config_download_timeout }}"
poll: "{{ tripleo_overcloud_config_download_poll }}"
changed_when: false
when: not ansible_check_mode|bool
- name: Set output fact
set_fact:
tripleo_overcloud_config_download_output: "{{ tripleo_overcloud_config_download_result.stdout }}"

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo_overcloud_config_download

View File

@ -14,6 +14,7 @@
- tripleo-operator-molecule-tripleo_deploy
- tripleo-operator-molecule-tripleo_overcloud_admin_authorize
- tripleo-operator-molecule-tripleo_overcloud_cell_export
- tripleo-operator-molecule-tripleo_overcloud_config_download
- tripleo-operator-molecule-tripleo_overcloud_container_image_build
- tripleo-operator-molecule-tripleo_overcloud_deploy
- tripleo-operator-molecule-tripleo_overcloud_export
@ -52,6 +53,7 @@
- tripleo-operator-molecule-tripleo_deploy
- tripleo-operator-molecule-tripleo_overcloud_admin_authorize
- tripleo-operator-molecule-tripleo_overcloud_cell_export
- tripleo-operator-molecule-tripleo_overcloud_config_download
- tripleo-operator-molecule-tripleo_overcloud_container_image_build
- tripleo-operator-molecule-tripleo_overcloud_deploy
- tripleo-operator-molecule-tripleo_overcloud_export
@ -225,6 +227,20 @@
vars:
tox_extra_args: tripleo_overcloud_cell_export
- job:
files:
- ^roles/tripleo_overcloud_config_download/.*
- ^bindep.txt
- ^galaxy.yml
- ^requirements.txt
- ^setup.cfg
- ^test-requirements.txt
- ^tox.ini
name: tripleo-operator-molecule-tripleo_overcloud_config_download
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_config_download
- job:
files:
- ^roles/tripleo_overcloud_container_image_build/.*