Browse Source

Adds overcloud roles generate role - creates roles_data.yaml

Tracked by tripleo squad at [1]. Implements the openstack
overcloud roles generate command to create the roles.yml
file from your THT directory /roles. Tracked by tripleo-ci squad
with [2].

[1] https://etherpad.openstack.org/p/tripleo-operator-ansible
[2] https://tree.taiga.io/project/tripleo-ci-board/task/1598
Change-Id: I0352eb5d6c22c7c9bd31e09c295cb052f61c158e
tags/0.2.0
Marios Andreou 3 months ago
parent
commit
dc24575484
8 changed files with 256 additions and 0 deletions
  1. +58
    -0
      roles/tripleo_overcloud_roles_generate/README.md
  2. +12
    -0
      roles/tripleo_overcloud_roles_generate/defaults/main.yml
  3. +42
    -0
      roles/tripleo_overcloud_roles_generate/meta/main.yml
  4. +60
    -0
      roles/tripleo_overcloud_roles_generate/molecule/default/converge.yml
  5. +19
    -0
      roles/tripleo_overcloud_roles_generate/molecule/default/molecule.yml
  6. +8
    -0
      roles/tripleo_overcloud_roles_generate/molecule/default/prepare.yml
  7. +41
    -0
      roles/tripleo_overcloud_roles_generate/tasks/main.yml
  8. +16
    -0
      zuul.d/molecule.yaml

+ 58
- 0
roles/tripleo_overcloud_roles_generate/README.md View File

@@ -0,0 +1,58 @@
tripleo_overcloud_roles_generate
========================

A role to run 'openstack overcloud roles generate' for generation of the
roles_data.yaml, from the TripleO Roles defined in the tripleo-heat-templates
roles/ directory.

Requirements
------------

None.

Role Variables
--------------

* `tripleo_overcloud_roles_generate_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false
* `tripleo_overcloud_roles_generate_generate_scripts`: (Boolean) Write out a shell script that can be used to reproduce the command being executed. By default uses the value of `tripleo_generate_scripts` or False if `tripleo_generate_scripts` is not defined.
* `tripleo_overcloud_roles_generate_home_dir`: (String) Home directory to where the command is run from. Default: "{{ ansible_env.HOME }}"
* `tripleo_overcloud_roles_generate_roles_path`: Filesystem path containing the role yaml files. By default this is in tripleo-heat-templates/roles.
* `tripleo_overcloud_roles_generate_output_file`: File to capture all output to. For example, roles_data.yaml
* `tripleo_overcloud_roles_generate_skip_validate`: Skip role metadata type validation when generating the roles_data.yaml
* `tripleo_overcloud_roles_generate_roles`: REQUIRED - list of roles to use to generate the roles_data.yaml file for the deployment. NOTE: Ordering is important if no role has the "primary" and "controller" tags. If no role is tagged then the first role listed will be considered the primary role. This usually is the controller role.
* `tripleo_overcloud_roles_generate_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_roles_generate_rc_file`.
* `tripleo_overcloud_roles_generate_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"




Output Variables
----------------

* `tripleo_overcloud_roles_generate_output`: (String) The command standard output.
* `tripleo_overcloud_roles_generate_result`: Ansible shell execution results

Dependencies
------------

None.

Example Playbook
----------------

Example overcloud node delete playbook

```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Generate overcloud roles_data.yaml
import_role:
name: tripleo_overcloud_roles_generate
```

License
-------

Apache-2.0

+ 12
- 0
roles/tripleo_overcloud_roles_generate/defaults/main.yml View File

@@ -0,0 +1,12 @@
---
# defaults file for tripleo_overcloud_roles_generate
openstack_bin: openstack
tripleo_overcloud_roles_generate_debug: false
tripleo_overcloud_roles_generate_generate_scripts: "{{ tripleo_generate_scripts | default(False) }}"
tripleo_overcloud_roles_generate_home_dir: "{{ ansible_env.HOME }}"
tripleo_overcloud_roles_generate_roles_path: /usr/share/openstack-tripleo-heat-templates/roles
tripleo_overcloud_roles_generate_output_file: "{{ tripleo_overcloud_roles_generate_home_dir }}/roles_data.yaml"
tripleo_overcloud_roles_generate_skip_validate: false
tripleo_overcloud_roles_generate_roles: []
tripleo_overcloud_roles_generate_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_roles_generate_rc_file: "{{ tripleo_rc_file | default(ansible_env.HOME ~ '/stackrc') }}"

+ 42
- 0
roles/tripleo_overcloud_roles_generate/meta/main.yml 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_roles_generate
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: []

+ 60
- 0
roles/tripleo_overcloud_roles_generate/molecule/default/converge.yml View File

@@ -0,0 +1,60 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_roles_generate_debug: true
tasks:

- name: Test --output-file
vars:
tripleo_overcloud_roles_generate_roles: ['Compute']
tripleo_overcloud_roles_generate_output_file: "molecule_roles_test1.yml"
test_name: "--output-file"
block:
- name: 'Run test {{ test_name }}'
include_role:
name: "tripleo_overcloud_roles_generate"
- name: 'Check output {{ test_name }}'
assert:
that:
- tripleo_overcloud_roles_generate_output ==
"overcloud roles generate --roles-path /usr/share/openstack-tripleo-heat-templates/roles
--output-file molecule_roles_test1.yml Compute"

- name: Test --roles-path --output-file
vars:
tripleo_overcloud_roles_generate_roles_path: /foo
tripleo_overcloud_roles_generate_roles: ['Controller']
tripleo_overcloud_roles_generate_output_file: "molecule_roles_test2.yml"
test_name: "--roles-path --output-file"
block:
- name: 'Run test {{ test_name }}'
include_role:
name: "tripleo_overcloud_roles_generate"
- name: 'Check output {{ test_name }}'
assert:
that:
- tripleo_overcloud_roles_generate_output ==
"overcloud roles generate --roles-path /foo --output-file molecule_roles_test2.yml Controller"

- name: Test all --roles-path --output-file --skip-validate
vars:
tripleo_overcloud_roles_generate_roles_path: /bar
tripleo_overcloud_roles_generate_skip_validate: true
tripleo_overcloud_roles_generate_output_file: "molecule_roles_test3.yml"
tripleo_overcloud_roles_generate_roles: ['Controller', 'Compute']
test_name: "--roles-path --output-file --skip-validate"
block:
- name: 'Run test {{ test_name }}'
include_role:
name: "tripleo_overcloud_roles_generate"
- name: 'Check output {{ test_name }}'
assert:
that:
- tripleo_overcloud_roles_generate_output ==
"overcloud roles generate --roles-path /bar --output-file molecule_roles_test3.yml
--skip-validate Controller Compute"

+ 19
- 0
roles/tripleo_overcloud_roles_generate/molecule/default/molecule.yml 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

+ 8
- 0
roles/tripleo_overcloud_roles_generate/molecule/default/prepare.yml View File

@@ -0,0 +1,8 @@
---
- name: Prepare
hosts: all
tasks:

- name: Include molecule prep
include_role:
name: test_molecule_prep

+ 41
- 0
roles/tripleo_overcloud_roles_generate/tasks/main.yml View File

@@ -0,0 +1,41 @@
---
# tasks file for tripleo_overcloud_roles_generate
- name: setup overcloud roles generate
set_fact:
_generate_roles_cmd: >-
{{ tripleo_overcloud_roles_generate_os_cloud | ternary('', "source " ~ tripleo_overcloud_roles_generate_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud roles generate
{{ tripleo_overcloud_roles_generate_roles_path | ternary('--roles-path ' ~ tripleo_overcloud_roles_generate_roles_path, '') }}
{{ tripleo_overcloud_roles_generate_output_file | ternary('--output-file ' ~ tripleo_overcloud_roles_generate_output_file, '') }}
{{ tripleo_overcloud_roles_generate_skip_validate | ternary('--skip-validate', '') }}
{{ tripleo_overcloud_roles_generate_roles | tripleo.operator.shell_arg_list() }}
_generate_roles_env:
OS_CLOUD: "{{ tripleo_overcloud_roles_generate_os_cloud }}"

- name: Debug the _generate_roles_cmd
when: tripleo_overcloud_roles_generate_debug|bool
block:
- name: Show the roles generate command
debug:
var: _generate_roles_cmd

- name: Show the roles generate environment
debug:
var: _generate_roles_env

- name: Write reproducer script
tripleo_shell_script:
dest: "{{ tripleo_overcloud_roles_generate_home_dir }}/tripleo_overcloud_roles_generate.sh"
shell_command: "{{ _generate_roles_cmd }}"
shell_environment: "{{ _generate_roles_env }}"
when: tripleo_overcloud_roles_generate_generate_scripts|bool

- name: run roles generate
shell: "{{ _generate_roles_cmd }}" # noqa 305
environment: "{{ _generate_roles_env }}"
register: tripleo_overcloud_roles_generate_result
changed_when: true

- name: Set output fact
set_fact:
tripleo_overcloud_roles_generate_output: "{{ tripleo_overcloud_roles_generate_result.stdout }}"

+ 16
- 0
zuul.d/molecule.yaml View File

@@ -44,6 +44,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_provision
- tripleo-operator-molecule-tripleo_overcloud_node_unprovision
- tripleo-operator-molecule-tripleo_overcloud_raid_create
- tripleo-operator-molecule-tripleo_overcloud_roles_generate
- tripleo-operator-molecule-tripleo_overcloud_roles_list
- tripleo-operator-molecule-tripleo_overcloud_roles_show
- tripleo-operator-molecule-tripleo_overcloud_support_report_collect
@@ -103,6 +104,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_provision
- tripleo-operator-molecule-tripleo_overcloud_node_unprovision
- tripleo-operator-molecule-tripleo_overcloud_raid_create
- tripleo-operator-molecule-tripleo_overcloud_roles_generate
- tripleo-operator-molecule-tripleo_overcloud_roles_list
- tripleo-operator-molecule-tripleo_overcloud_roles_show
- tripleo-operator-molecule-tripleo_overcloud_support_report_collect
@@ -699,6 +701,20 @@
vars:
tox_extra_args: tripleo_overcloud_roles_show

- job:
files:
- ^roles/tripleo_overcloud_roles_generate/.*
- ^bindep.txt
- ^galaxy.yml
- ^requirements.txt
- ^setup.cfg
- ^test-requirements.txt
- ^tox.ini
name: tripleo-operator-molecule-tripleo_overcloud_roles_generate
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_roles_generate

- job:
files:
- ^roles/tripleo_container_image_prepare/.*


Loading…
Cancel
Save