Add basic role for undercloud function

This change adds basic wrapper roles for the undercloud install,
backup and upgrade actions.

Change-Id: I20284d57689cbbd244a324076ad95b4df535aa8c
This commit is contained in:
Alex Schultz 2019-12-16 16:00:07 -07:00
parent 20f680f6b8
commit 8c937edbae
21 changed files with 422 additions and 13 deletions

View File

@ -1,7 +1,7 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
rev: v2.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
@ -18,24 +18,23 @@ repos:
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.15.0
rev: v1.20.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/ansible/ansible-lint
rev: v4.1.1a2
rev: v4.2.0
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
entry: >-
ansible-lint --force-color -v -x "ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016,204"
# TODO(cloudnull): These codes were added to pass the lint check.
# Things found within roles.galaxy are external
# and not something maintained here.
# NOTE(mwhahaha): ignore 204 because collections make you include
# namespaces in filters so lines get REALLY long
always_run: true
pass_filenames: false
# do not add file filters here as ansible-lint does not give reliable
# results when called with individual files.
# https://github.com/ansible/ansible-lint/issues/611
verbose: true
entry: env ANSIBLE_LIBRARY=./plugins ansible-lint --force-color -p -v
- repo: https://github.com/openstack-dev/bashate.git
rev: 0.6.0
hooks:

View File

@ -28,4 +28,4 @@ Here is an example directory of the majority of plugins currently supported by A
└── vars
```
A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html).
A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html).

View File

@ -0,0 +1,46 @@
tripleo-undercloud-backup
=========================
A role to run backup of a TripleO undercloud.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_undercloud_backup_add_path`: (List) List of additional filesystem paths to backup. Default: []
* `tripleo_undercloud_backup_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false
* `tripleo_undercloud_backup_exclude_path`: (List) List of filesystems path to skip backing up. Default: []
* `tripleo_undercloud_backup_home_dir`: (String) Home directory for the undercloud user. Default: "{{ ansible_env.HOME }}"
* `tripleo_undercloud_backup_log_combine`: (Boolean) Flag to combine stdout and stderr in the logfile. Default: true
* `tripleo_undercloud_backup_log_output`: (Boolean) Flag to log the output to a file rather than show it in the ansible output. Default: true
* `tripleo_undercloud_backup_timeout`: (Number) Timeout for the backup command. Default: 7200
* `tripleo_undercloud_backup_log`: (String) Backup log file path. Default: "{{ tripleo_undercloud_backup_home_dir }}/undercloud_backup.log"
Dependencies
------------
None.
Example Playbook
----------------
Example backup execution playbook
- hosts: undercloud
gather_facts: true
tasks:
- name: Backup undercloud
import_role:
name: tripleo-undercloud-backup
vars:
tripleo_undercloud_backup_debug: true
License
-------
Apache-2.0

View File

@ -0,0 +1,10 @@
---
# defaults file for tripleo-undercloud-backup
tripleo_undercloud_backup_add_path: []
tripleo_undercloud_backup_debug: false
tripleo_undercloud_backup_exclude_path: []
tripleo_undercloud_backup_home_dir: "{{ ansible_env.HOME }}"
tripleo_undercloud_backup_log_combine: true
tripleo_undercloud_backup_log_output: true
tripleo_undercloud_backup_timeout: 7200
tripleo_undercloud_backup_log: "{{ tripleo_undercloud_backup_home_dir }}/undercloud_backup.log"

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-undercloud-backup
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,27 @@
---
- name: Setup undercloud backup facts
set_fact:
_backup_cmd: >-
openstack undercloud backup
{{ tripleo_undercloud_backup_add_path | tripleo.operator.shell_arg_list(parameter='--add-path') }}
{{ tripleo_undercloud_backup_exclude_path | tripleo.operator.shell_arg_list(parameter='--exclude-path') }}
{{ tripleo_undercloud_backup_log_output | ternary((">" ~ tripleo_undercloud_backup_log), '') }}
{{ tripleo_undercloud_backup_log_combine | ternary("2>&1", '') }}
- name: Preserve existing log file if exists
timestamp_file:
path: "{{ tripleo_undercloud_backup_log }}"
- name: Show the underclound backup command
debug:
var: _backup_cmd
when: tripleo_undercloud_backup_debug|bool
- name: undercloud backup
shell: "{{ _backup_cmd }}" # noqa 305
args:
chdir: "{{ tripleo_undercloud_backup_home_dir }}"
warn: false
async: "{{ tripleo_undercloud_backup_timeout }}"
poll: 10
changed_when: true

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo-undercloud-backup

View File

@ -0,0 +1,49 @@
tripleo-undercloud-install
==========================
A role to run the install of a TripleO undercloud.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_undercloud_install_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false
* `tripleo_undercloud_install_dry_run`: (Boolean) Flag to add --dry-run to the install. Default: false
* `tripleo_undercloud_install_force_stack_update`: (Boolean) Flag to add --force-stack-update to the install. Default: false
* `tripleo_undercloud_install_home_dir`: (String) Home directory for the undercloud user. Default: "{{ ansible_env.HOME }}"
* `tripleo_undercloud_install_inflight_validations`: (Boolean) Flag to add --inflight-validations to the install. Default: false
* `tripleo_undercloud_install_log_combine`: (Boolean) Flag to combine stdout and stderr in the logfile. Default: true
* `tripleo_undercloud_install_log_output`: (Boolean) Flag to log the output to a file rather than show it in the ansible output. Default: true
* `tripleo_undercloud_install_no_validations`: (Boolean) Flag to add --no-validations to the install. Default: false
* `tripleo_undercloud_install_timeout`: (Number) Timeout for the install command. Default: 7200
* `tripleo_undercloud_install_yes`: (Boolean) Flag to add --yes to the install. Default: false
* `tripleo_undercloud_install_log`: (String) Install log file path. Default: "{{ tripleo_undercloud_install_home_dir }}/undercloud_install.log"
Dependencies
------------
None.
Example Playbook
----------------
Example install execution playbook
- hosts: undercloud
gather_facts: true
tasks:
- name: Install undercloud
import_role:
name: tripleo-undercloud-install
vars:
tripleo_undercloud_install_debug: true
License
-------
Apache-2.0

View File

@ -0,0 +1,13 @@
---
# defaults file for tripleo-undercloud-install
tripleo_undercloud_install_debug: false
tripleo_undercloud_install_dry_run: false
tripleo_undercloud_install_force_stack_update: false
tripleo_undercloud_install_home_dir: "{{ ansible_env.HOME }}"
tripleo_undercloud_install_inflight_validations: false
tripleo_undercloud_install_log_combine: true
tripleo_undercloud_install_log_output: true
tripleo_undercloud_install_no_validations: false
tripleo_undercloud_install_timeout: 7200
tripleo_undercloud_install_yes: false
tripleo_undercloud_install_log: "{{ tripleo_undercloud_install_home_dir }}/undercloud_install.log"

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-undercloud-install
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,30 @@
---
- name: Setup undercloud install facts
set_fact:
_install_cmd: >-
openstack undercloud install
{{ tripleo_undercloud_install_force_stack_update | ternary("--force-stack-update", '') }}
{{ tripleo_undercloud_install_no_validations | ternary("--no-validations", '') }}
{{ tripleo_undercloud_install_inflight_validations | ternary("--inflight-validations", '') }}
{{ tripleo_undercloud_install_dry_run | ternary("--dry-run", '') }}
{{ tripleo_undercloud_install_yes | ternary("--yes", '') }}
{{ tripleo_undercloud_install_log_output | ternary((">" ~ tripleo_undercloud_install_log), '') }}
{{ tripleo_undercloud_install_log_combine | ternary("2>&1", '') }}
- name: Preserve existing log file if exists
timestamp_file:
path: "{{ tripleo_undercloud_install_log }}"
- name: Show the underclound install command
debug:
var: _install_cmd
when: tripleo_undercloud_install_debug|bool
- name: undercloud install
shell: "{{ _install_cmd }}" # noqa 305
args:
chdir: "{{ tripleo_undercloud_install_home_dir }}"
warn: false
async: "{{ tripleo_undercloud_install_timeout }}"
poll: 10
changed_when: true

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo-undercloud-install

View File

@ -0,0 +1,49 @@
tripleo-undercloud-upgrade
==========================
A role to run the upgrade of a TripleO undercloud.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_undercloud_upgrade_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false
* `tripleo_undercloud_upgrade_dry_run`: (Boolean) Flag to add --dry-run to the upgrade command. Default: false
* `tripleo_undercloud_upgrade_force_stack_update`: (Boolean) Flag to add --force-stack-update to the upgrade command. Default: false
* `tripleo_undercloud_upgrade_home_dir`: (String) Home directory for the undercloud user. Default: "{{ ansible_env.HOME }}"
* `tripleo_undercloud_upgrade_inflight_validations`: (Boolean) Flag to add --inflight-validations to the upgrade. Default: false
* `tripleo_undercloud_upgrade_log_combine`: (Boolean) Flag to combine stdout and stderr in the logfile. Default: true
* `tripleo_undercloud_upgrade_log_output`: (Boolean) Flag to log the output to a file rather than show it in the ansible output. Default: true
* `tripleo_undercloud_upgrade_no_validations`: (Boolean) Flag to add --no-validations to the upgrade. Default: false
* `tripleo_undercloud_upgrade_timeout`: (Number) Timeout for the upgrade command. Default: 7200
* `tripleo_undercloud_upgrade_yes`: (Boolean) Flag to add --yes to the upgrade. Default: false
* `tripleo_undercloud_upgrade_log`: (String) Upgrade log file path. Default: "{{ tripleo_undercloud_upgrade_home_dir }}/undercloud_upgrade.log"
Dependencies
------------
None.
Example Playbook
----------------
Example upgrade execution playbook
- hosts: undercloud
gather_facts: true
tasks:
- name: Upgrade undercloud
import_role:
name: tripleo-undercloud-upgrade
vars:
tripleo_undercloud_upgrade_debug: true
License
-------
Apache-2.0

View File

@ -0,0 +1,13 @@
---
# defaults file for tripleo-undercloud
tripleo_undercloud_upgrade_debug: false
tripleo_undercloud_upgrade_dry_run: false
tripleo_undercloud_upgrade_force_stack_update: false
tripleo_undercloud_upgrade_home_dir: "{{ ansible_env.HOME }}"
tripleo_undercloud_upgrade_inflight_validations: false
tripleo_undercloud_upgrade_log_combine: true
tripleo_undercloud_upgrade_log_output: true
tripleo_undercloud_upgrade_no_validations: false
tripleo_undercloud_upgrade_timeout: 7200
tripleo_undercloud_upgrade_yes: false
tripleo_undercloud_upgrade_log: "{{ tripleo_undercloud_upgrade_home_dir }}/undercloud_upgrade.log"

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-undercloud-upgrade
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,30 @@
---
- name: Setup undercloud upgrade facts
set_fact:
_upgrade_cmd: >-
openstack undercloud upgrade
{{ tripleo_undercloud_upgrade_force_stack_update | ternary("--force-stack-update", '') }}
{{ tripleo_undercloud_upgrade_no_validations | ternary("--no-validations", '') }}
{{ tripleo_undercloud_upgrade_inflight_validations | ternary("--inflight-validations", '') }}
{{ tripleo_undercloud_upgrade_dry_run | ternary("--dry-run", '') }}
{{ tripleo_undercloud_upgrade_yes | ternary("--yes", '') }}
{{ tripleo_undercloud_upgrade_log_output | ternary((">" ~ tripleo_undercloud_upgrade_log), '') }}
{{ tripleo_undercloud_upgrade_log_combine | ternary("2>&1", '') }}
- name: Preserve existing log file if exists
timestamp_file:
path: "{{ tripleo_undercloud_upgrade_log }}"
- name: Show the underclound upgrade command
debug:
var: _upgrade_cmd
when: tripleo_undercloud_upgrade_debug|bool
- name: undercloud upgrade
shell: "{{ _upgrade_cmd }}" # noqa 305
args:
chdir: "{{ tripleo_undercloud_upgrade_home_dir }}"
warn: false
async: "{{ tripleo_undercloud_upgrade_timeout }}"
poll: 10
changed_when: true

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo-undercloud-upgrade

View File

@ -119,4 +119,3 @@ basepython = python3
deps = -r{toxinidir}/ansible-requirements.txt
commands =
ansible-galaxy collection build --force --output-path {toxinidir}/build/ .