From a8d43fa37d4c33f5e55ee4a0432e5340e55c5393 Mon Sep 17 00:00:00 2001 From: David J Peacock Date: Wed, 30 Sep 2020 15:12:02 -0400 Subject: [PATCH] add role to show tripleo validation With this patch, validator show can be used by operators in automation. Change-Id: Iedad29583c104ecd98d38455bf3422bb353a37d9 --- roles/tripleo_validator_show/README.md | 44 +++++++++++++++++++ .../tripleo_validator_show/defaults/main.yml | 3 ++ roles/tripleo_validator_show/meta/main.yml | 42 ++++++++++++++++++ .../molecule/default/converge.yml | 23 ++++++++++ .../molecule/default/molecule.yml | 19 ++++++++ .../molecule/default/prepare.yml | 8 ++++ roles/tripleo_validator_show/tasks/main.yml | 36 +++++++++++++++ zuul.d/molecule.yaml | 16 +++++++ 8 files changed, 191 insertions(+) create mode 100644 roles/tripleo_validator_show/README.md create mode 100644 roles/tripleo_validator_show/defaults/main.yml create mode 100644 roles/tripleo_validator_show/meta/main.yml create mode 100644 roles/tripleo_validator_show/molecule/default/converge.yml create mode 100644 roles/tripleo_validator_show/molecule/default/molecule.yml create mode 100644 roles/tripleo_validator_show/molecule/default/prepare.yml create mode 100644 roles/tripleo_validator_show/tasks/main.yml diff --git a/roles/tripleo_validator_show/README.md b/roles/tripleo_validator_show/README.md new file mode 100644 index 0000000..3c1d0f0 --- /dev/null +++ b/roles/tripleo_validator_show/README.md @@ -0,0 +1,44 @@ +tripleo_validator_show +===================== + +A role to show tripleo validations + +Requirements +------------ + +None. + +Role Variables +-------------- + +* `tripleo_validator_show_debug`: (Boolean) Flag to print out the delete command. Default: False +* `tripleo_validator_show_validation`: (String) Group of validations to inspect + +Output Variables +---------------- + +* `tripleo_validator_show_result`: Ansible shell execution results + +Dependencies +------------ + +None. + +Example Playbook +---------------- + +Example validator show playbook + +```yaml +- hosts: undercloud + gather_facts: true + tasks: + - name: Show validation + import_role: + name: tripleo_validator_show +``` + +License +------- + +Apache-2.0 diff --git a/roles/tripleo_validator_show/defaults/main.yml b/roles/tripleo_validator_show/defaults/main.yml new file mode 100644 index 0000000..bb9b854 --- /dev/null +++ b/roles/tripleo_validator_show/defaults/main.yml @@ -0,0 +1,3 @@ +--- +tripleo_validator_show_debug: false +tripleo_validator_show_validation: [] diff --git a/roles/tripleo_validator_show/meta/main.yml b/roles/tripleo_validator_show/meta/main.yml new file mode 100644 index 0000000..a114536 --- /dev/null +++ b/roles/tripleo_validator_show/meta/main.yml @@ -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_validator_show + 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: [] diff --git a/roles/tripleo_validator_show/molecule/default/converge.yml b/roles/tripleo_validator_show/molecule/default/converge.yml new file mode 100644 index 0000000..7ec20d1 --- /dev/null +++ b/roles/tripleo_validator_show/molecule/default/converge.yml @@ -0,0 +1,23 @@ +--- +- name: Converge + hosts: all + collections: + - tripleo.operator + vars: + openstack_bin: echo + tripleo_os_cloud: undercloud + tripleo_validator_show_debug: true + tasks: + + - name: Check parameter "tripleo_validator_show_validation" as a single element + include_role: + name: "tripleo_validator_show" + vars: + tripleo_validator_show_validation: + - 'check_ram' + + - name: Assert "tripleo_validator_show_validation" + assert: + that: + - tripleo_validator_show_result.stdout == + "tripleo validator show --validation check_ram" diff --git a/roles/tripleo_validator_show/molecule/default/molecule.yml b/roles/tripleo_validator_show/molecule/default/molecule.yml new file mode 100644 index 0000000..2841806 --- /dev/null +++ b/roles/tripleo_validator_show/molecule/default/molecule.yml @@ -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 diff --git a/roles/tripleo_validator_show/molecule/default/prepare.yml b/roles/tripleo_validator_show/molecule/default/prepare.yml new file mode 100644 index 0000000..63bb6ab --- /dev/null +++ b/roles/tripleo_validator_show/molecule/default/prepare.yml @@ -0,0 +1,8 @@ +--- +- name: Prepare + hosts: all + tasks: + + - name: Include molecule prep + include_role: + name: test_molecule_prep diff --git a/roles/tripleo_validator_show/tasks/main.yml b/roles/tripleo_validator_show/tasks/main.yml new file mode 100644 index 0000000..73a309d --- /dev/null +++ b/roles/tripleo_validator_show/tasks/main.yml @@ -0,0 +1,36 @@ +--- +- name: Fail if we do not pass validation + fail: + msg: "Please pass either tripleo_validator_show_validation" + when: + - tripleo_validator_show_validation | length == 0 + +- name: Setup validator show facts + set_fact: + _validator_show_cmd: >- + {{ openstack_bin }} tripleo validator show --validation + {{ tripleo_validator_show_validation | ternary(' "${TRIPLEO_VALIDATOR_SHOW_VALIDATION}"', '') }} + _validator_show_env: + TRIPLEO_VALIDATOR_SHOW_VALIDATION: >- + {%- if tripleo_validator_show_validation is string -%} + {{ tripleo_validator_show_validation }} + {%- else -%} + {{ tripleo_validator_show_validation | join(',') }} + {%- endif -%} + +- name: Show debug information + when: + tripleo_validator_show_debug|bool + block: + - name: Show validator show environment + debug: + var: _validator_show_env + - name: Show validator show command + debug: + var: _validator_show_cmd + +- name: Show validation + shell: "{{ _validator_show_cmd }}" + environment: "{{ _validator_show_env }}" + register: tripleo_validator_show_result + changed_when: true diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index f71e843..cd65acc 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -64,6 +64,7 @@ - tripleo-operator-molecule-tripleo_undercloud_upgrade - tripleo-operator-molecule-tripleo_validator_list - tripleo-operator-molecule-tripleo_validator_run + - tripleo-operator-molecule-tripleo_validator_show - tripleo-operator-molecule-tripleo_validator_show_parameter gate: @@ -130,6 +131,7 @@ - tripleo-operator-molecule-tripleo_undercloud_upgrade - tripleo-operator-molecule-tripleo_validator_list - tripleo-operator-molecule-tripleo_validator_run + - tripleo-operator-molecule-tripleo_validator_show - tripleo-operator-molecule-tripleo_validator_show_parameter - job: @@ -1037,6 +1039,20 @@ vars: tox_extra_args: tripleo_validator_run +- job: + files: + - ^roles/tripleo_validator_show/.* + - ^bindep.txt + - ^galaxy.yml + - ^requirements.txt + - ^setup.cfg + - ^test-requirements.txt + - ^tox.ini + name: tripleo-operator-molecule-tripleo_validator_show + parent: tripleo-operator-molecule-base + vars: + tox_extra_args: tripleo_validator_show + - job: files: - ^roles/tripleo_validator_show_parameter/.*