Add overcloud failures role

Adds tripleo_overcloud_failures which can be used to collect the failure
output when a deployment fails for an overcloud.

Change-Id: I44f2172069df2bf788b5b37d2bf70e381983f7a1
This commit is contained in:
Alex Schultz 2020-01-21 15:02:08 -07:00
parent 110e58deb8
commit bb480ed481
9 changed files with 190 additions and 0 deletions

View File

@ -0,0 +1,52 @@
tripleo_overcloud_failures
==========================
A role to get the deployment failures output.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_overcloud_failures_debug`: (Boolean) Flag to print out the command that is run. Default: False
* `tripleo_overcloud_failures_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_failures_rc_file`.
* `tripleo_overcloud_failures_plan`: (String) The name of the stakc/plan. Default: overcloud
* `tripleo_overcloud_failures_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"
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_failures_output`: (String) The command standard output.
* `tripleo_overcloud_failures_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example overcloud failures execution playbook
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Get overcloud failures
import_role:
name: tripleo_overcloud_failures
```
License
-------
Apache-2.0

View File

@ -0,0 +1,7 @@
---
# defaults file for tripleo_overcloud_failures
openstack_bin: openstack
tripleo_overcloud_failures_debug: false
tripleo_overcloud_failures_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_failures_plan: overcloud
tripleo_overcloud_failures_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_failures
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,31 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include tripleo_overcloud_failures"
include_role:
name: "tripleo_overcloud_failures"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_failures_debug: true
- name: Check role
assert:
that:
- tripleo_overcloud_failures_output == "overcloud failures --plan overcloud"
- name: Check parameter "tripleo_overcloud_failures_plan"
include_role:
name: "tripleo_overcloud_failures"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_failures_debug: true
tripleo_overcloud_failures_plan: test
- name: Assert "tripleo_overcloud_failures_plan"
assert:
that:
- tripleo_overcloud_failures_output == "overcloud failures --plan test"

View File

@ -0,0 +1,22 @@
---
# tasks file for tripleo_overcloud_failures
- name: Setup overcloud failures facts
set_fact:
_failures_cmd: >-
{{ tripleo_overcloud_failures_os_cloud | ternary('', "source " ~ tripleo_overcloud_failures_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud failures
{{ tripleo_overcloud_failures_plan | ternary('--plan ' ~ tripleo_overcloud_failures_plan, '') }}
- name: Show the overcloud failures command
debug:
var: _failures_cmd
when: tripleo_overcloud_failures_debug|bool
- name: Overcloud failures
shell: "{{ _failures_cmd }}" # noqa 305
register: tripleo_overcloud_failures_result
changed_when: false
- name: Set output fact
set_fact:
tripleo_overcloud_failures_output: "{{ tripleo_overcloud_failures_result.stdout }}"

View File

@ -0,0 +1 @@
localhost

View File

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

View File

@ -3,11 +3,13 @@
check:
jobs:
- tripleo-operator-molecule-tripleo_overcloud_export
- tripleo-operator-molecule-tripleo_overcloud_failures
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
gate:
jobs:
- tripleo-operator-molecule-tripleo_overcloud_export
- tripleo-operator-molecule-tripleo_overcloud_failures
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- job:
@ -25,6 +27,14 @@
vars:
tox_extra_args: tripleo_overcloud_export
- job:
files:
- ^roles/tripleo_overcloud_failures/.*
name: tripleo-operator-molecule-tripleo_overcloud_failures
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_failures
- job:
files:
- ^roles/tripleo_overcloud_node_introspect/.*