Add tripleo_overcloud_node_introspect role

Change-Id: I313032895c5f8862c6c1507ae2c19858c03626ba
This commit is contained in:
Sagi Shnaidman 2020-01-27 10:42:57 +02:00
parent 835a030fe7
commit 77d0c6f1f6
12 changed files with 346 additions and 0 deletions

View File

@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default
rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable

View File

@ -0,0 +1,54 @@
tripleo_overcloud_node_introspect
=================================
A role to run node introspect.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_overcloud_node_introspect_node_uuids`: Baremetal Node UUIDs for the node(s) to be introspected.
* `tripleo_overcloud_node_introspect_all_manageable`: Introspect all nodes currently in 'manageable' state.
* `tripleo_overcloud_node_introspect_provide`: Provide (make available) the nodes once introspected.
* `tripleo_overcloud_node_introspect_run_validations`: Run the pre-deployment validations.
These external validations are from the TripleO Validations project.
* `tripleo_overcloud_node_introspect_concurrency`: Maximum number of nodes to introspect at once.
* `tripleo_overcloud_node_configure_os_cloud`: (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_node_configure_rc_file`.
* `tripleo_overcloud_node_configure_rc_file`: (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_node_introspect_output`: (String) The command standard output.
* `tripleo_overcloud_node_introspect_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example overcloud node introspect playbook
- hosts: undercloud
gather_facts: true
tasks:
- name: Introspect node
import_role:
name: tripleo_overcloud_node_introspect
License
-------
Apache-2.0

View File

@ -0,0 +1,11 @@
---
# defaults file for tripleo_overcloud_node_introspect
openstack_bin: openstack
tripleo_overcloud_node_introspect_debug: false
tripleo_overcloud_node_introspect_node_uuids: []
tripleo_overcloud_node_introspect_all_manageable: false
tripleo_overcloud_node_introspect_provide: false
tripleo_overcloud_node_introspect_run_validations: false
tripleo_overcloud_node_introspect_concurrency:
tripleo_overcloud_node_configure_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_node_configure_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_node_introspect
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,107 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include tripleo_overcloud_node_introspect"
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
- name: Check role
assert:
that:
- tripleo_overcloud_node_introspect_output == "overcloud node introspect"
- name: Check parameter "tripleo_overcloud_node_introspect_node_uuids"
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
tripleo_overcloud_node_introspect_node_uuids: ['test1', 'test2']
- name: Assert "tripleo_overcloud_node_introspect_node_uuids"
assert:
that:
- tripleo_overcloud_node_introspect_output == "overcloud node introspect test1 test2"
- name: Check parameter "tripleo_overcloud_node_introspect_all_manageable"
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
tripleo_overcloud_node_introspect_all_manageable: true
- name: Assert "tripleo_overcloud_node_introspect_all_manageable"
assert:
that:
- tripleo_overcloud_node_introspect_output == "overcloud node introspect --all-manageable"
- name: Check parameter "tripleo_overcloud_node_introspect_provide"
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
tripleo_overcloud_node_introspect_provide: true
- name: Assert "tripleo_overcloud_node_introspect_provide"
assert:
that:
- tripleo_overcloud_node_introspect_output == "overcloud node introspect --provide"
- name: Check parameter "tripleo_overcloud_node_introspect_run_validations"
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
tripleo_overcloud_node_introspect_run_validations: true
- name: Assert "tripleo_overcloud_node_introspect_run_validations"
assert:
that:
- tripleo_overcloud_node_introspect_output == "overcloud node introspect --run-validations"
- name: Check parameter "tripleo_overcloud_node_introspect_concurrency"
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
tripleo_overcloud_node_introspect_concurrency: value
- name: Assert "tripleo_overcloud_node_introspect_concurrency"
assert:
that:
- tripleo_overcloud_node_introspect_output == "overcloud node introspect --concurrency value"
- name: Check all parameters for role tripleo_overcloud_node_introspect
include_role:
name: "tripleo_overcloud_node_introspect"
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_node_introspect_debug: true
tripleo_overcloud_node_introspect_node_uuids: ['value1', 'value2']
tripleo_overcloud_node_introspect_all_manageable: true
tripleo_overcloud_node_introspect_provide: true
tripleo_overcloud_node_introspect_run_validations: true
tripleo_overcloud_node_introspect_concurrency: value
- name: Assert all parameters for role tripleo_overcloud_node_introspect
assert:
that:
- tripleo_overcloud_node_introspect_output ==
"overcloud node introspect value1 value2 --all-manageable --provide --run-validations --concurrency value"

View File

@ -0,0 +1,27 @@
---
# tasks file for tripleo_overcloud_node_introspect
- name: Setup overcloud node introspect command
set_fact:
_introspect_cmd: >-
{{ tripleo_overcloud_node_configure_os_cloud | ternary('', "source " ~ tripleo_overcloud_node_configure_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud node introspect
{{ tripleo_overcloud_node_introspect_node_uuids | join(' ') }}
{{ tripleo_overcloud_node_introspect_all_manageable | ternary('--all-manageable', '') }}
{{ tripleo_overcloud_node_introspect_provide | ternary('--provide', '') }}
{{ tripleo_overcloud_node_introspect_run_validations | ternary('--run-validations', '') }}
{{ tripleo_overcloud_node_introspect_concurrency | ternary('--concurrency ' ~ tripleo_overcloud_node_introspect_concurrency, '') }}
- name: Show the node introspect command
debug:
var: _introspect_cmd
when: tripleo_overcloud_node_introspect_debug|bool
- name: Introspect node
shell: "{{ _introspect_cmd }}" # noqa 305
register: tripleo_overcloud_node_introspect_result
changed_when: true
- name: Set output fact
set_fact:
tripleo_overcloud_node_introspect_output: "{{ tripleo_overcloud_node_introspect_result.stdout }}"

View File

@ -0,0 +1 @@
localhost

View File

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

21
tox.ini
View File

@ -119,3 +119,24 @@ basepython = python3
deps = -r{toxinidir}/ansible-requirements.txt
commands =
ansible-galaxy collection build --force --output-path {toxinidir}/build/ .
[testenv:molecule]
setenv =
ANSIBLE_FORCE_COLOR=1
ANSIBLE_CALLBACK_WHITELIST=profile_tasks
ANSIBLE_SHOW_CUSTOM_STATS=1
deps =
ansi2html # GPL (soft-dependency of pytest-html)
ansible>=2.9
docker>=4.0.1
mock
molecule>=3.0a5
paramiko>=2.5.0 # LGPL (soft-dependency of docker that enables ssh protocol)
pytest-cov # MIT
pytest-html # MPL 2.0
pytest-molecule>=1.2.4 # MIT
pytest-xdist
selinux>=0.2.1 # MIT
oslotest
commands =
python -m pytest -ra --continue-on-collection-errors -v --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} -k {posargs}

View File

@ -1,6 +1,7 @@
- project:
templates:
- openstack-python3-ussuri-jobs
- tripleo-operator-molecule-jobs
check:
jobs:
- openstack-tox-linters

24
zuul.d/molecule.yaml Normal file
View File

@ -0,0 +1,24 @@
- project-template:
name: tripleo-operator-molecule-jobs
check:
jobs:
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
gate:
jobs:
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- job:
name: tripleo-operator-molecule-base
abstract: true
parent: openstack-tox-molecule
success-url: "reports.html"
failure-url: "reports.html"
- job:
files:
- ^roles/tripleo_overcloud_node_introspect/.*
name: tripleo-operator-molecule-tripleo_overcloud_node_introspect
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_node_introspect