Merge "Add update run role"

This commit is contained in:
Zuul 2020-02-25 19:37:00 +00:00 committed by Gerrit Code Review
commit 631bf0b4b6
10 changed files with 289 additions and 0 deletions

View File

@ -0,0 +1,61 @@
tripleo_overcloud_update_run
========================
A role to execute an overcloud update prepare.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_overcloud_update_run_debug`: (Boolean) Flag to print out the command that is run. Default: false
* `tripleo_overcloud_update_run_home_dir`: (String) Home directory to where the command is run from. Default: "{{ ansible_env.HOME }}"
* `tripleo_overcloud_update_run_limit`: (String) String that identifies a single node or a list of nodes to be upgraded.
* `tripleo_overcloud_update_run_log`: (String) Path to a log file for the command output. Default: "{{ tripleo_overcloud_update_run_home_dir }}/overcloud_update_run.log"
* `tripleo_overcloud_update_run_log_combine`: (Boolean) Flag to enable captching stderr with stdout. Default: true
* `tripleo_overcloud_update_run_log_output`: (Boolean) Flag to enable logging to a file. Since the output of this command can be large, it is not recommended to disable this. Default: true
* `tripleo_overcloud_update_run_playbook`: (List) List of playbook(s) to use for the minor update. Defaults: []
* `tripleo_overcloud_update_run_poll`: (Integer) Number of seconds to wait between each checks to see if the deployment command has completed. Default: 10
* `tripleo_overcloud_update_run_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"
* `tripleo_overcloud_update_run_ssh_user`: (String) Username of user to be used as the ssh user.
* `tripleo_overcloud_update_run_static_inventory`: (String) Path to an existing ansible inventory to use.
* `tripleo_overcloud_update_run_stack`: (String) Name of the stack to deploy.
* `tripleo_overcloud_update_run_timeout`: (Integer) Number in seconds to wait for the ansible execution of the deployment command to finish. Default: 5700
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_update_run_output`: (String) The command standard output.
* `tripleo_overcloud_update_run_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example overcloud update prepare execution playbook
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Run overcloud update prepare
import_role:
name: tripleo_overcloud_update_run
```
License
-------
Apache-2.0

View File

@ -0,0 +1,17 @@
---
# defaults file for tripleo_overcloud_update_run
openstack_bin: openstack
tripleo_overcloud_update_run_debug: false
tripleo_overcloud_update_run_home_dir: "{{ ansible_env.HOME }}"
tripleo_overcloud_update_run_limit:
tripleo_overcloud_update_run_log: "{{ tripleo_overcloud_update_run_home_dir }}/overcloud_update_run.log"
tripleo_overcloud_update_run_log_combine: true
tripleo_overcloud_update_run_log_output: true
tripleo_overcloud_update_run_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_update_run_playbook: []
tripleo_overcloud_update_run_poll: 10
tripleo_overcloud_update_run_rc_file: "{{ tripleo_rc_file | default(ansible_env.HOME ~ '/stackrc') }}"
tripleo_overcloud_update_run_ssh_user:
tripleo_overcloud_update_run_stack:
tripleo_overcloud_update_run_static_inventory:
tripleo_overcloud_update_run_timeout: 5700

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_update_prepare
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,68 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_update_run_debug: true
tripleo_overcloud_update_run_log_output: false
tripleo_overcloud_update_run_log_combine: false
tripleo_overcloud_update_run_poll: 1
tasks:
- name: "Include tripleo_overcloud_update_run"
include_role:
name: "tripleo_overcloud_update_run"
- name: Check role
assert:
that:
- tripleo_overcloud_update_run_output == "overcloud update run"
- name: Check parameter "tripleo_overcloud_update_run_stack"
include_role:
name: "tripleo_overcloud_update_run"
vars:
tripleo_overcloud_update_run_stack: test
- name: Assert "tripleo_overcloud_update_run_stack"
assert:
that:
- tripleo_overcloud_update_run_output == "overcloud update run --stack test"
- name: Check parameter "tripleo_overcloud_update_run_playbook"
include_role:
name: "tripleo_overcloud_update_run"
vars:
tripleo_overcloud_update_run_playbook:
- test1
- test2
- name: Assert "tripleo_overcloud_update_run_playbook"
assert:
that:
- tripleo_overcloud_update_run_output == "overcloud update run --playbook test1 --playbook test2"
- name: Check parameter "tripleo_overcloud_update_run_ssh_user"
include_role:
name: "tripleo_overcloud_update_run"
vars:
tripleo_overcloud_update_run_ssh_user: username
- name: Assert "tripleo_overcloud_update_run_ssh_user"
assert:
that:
- tripleo_overcloud_update_run_output == "overcloud update run --ssh-user username"
- name: Check parameter "tripleo_overcloud_update_run_static_inventory"
include_role:
name: "tripleo_overcloud_update_run"
vars:
tripleo_overcloud_update_run_static_inventory: /home/foo/inventory.yml
- name: Assert "tripleo_overcloud_update_run_static_inventory"
assert:
that:
- tripleo_overcloud_update_run_output == "overcloud update run --static-inventory /home/foo/inventory.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

View File

@ -0,0 +1,8 @@
---
- name: Prepare
hosts: all
tasks:
- name: Include molecule prep
include_role:
name: test_molecule_prep

View File

@ -0,0 +1,53 @@
---
# tasks file for tripleo_overcloud_update_run
- name: Setup overcloud update run facts
set_fact:
_update_run_cmd: >-
{{ tripleo_overcloud_update_run_os_cloud | ternary('', "source " ~ tripleo_overcloud_update_run_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud update run
{{ tripleo_overcloud_update_run_limit | ternary('--limit $UPDATE_LIMIT', '') }}
{{ tripleo_overcloud_update_run_playbook | tripleo.operator.shell_arg_list('--playbook') }}
{{ tripleo_overcloud_update_run_ssh_user | ternary('--ssh-user $UPDATE_SSH_USER', '') }}
{{ tripleo_overcloud_update_run_static_inventory | ternary('--static-inventory $UPDATE_STATIC_INVENTORY', '') }}
{{ tripleo_overcloud_update_run_stack | ternary('--stack $UPDATE_STACK', '') }}
{{ tripleo_overcloud_update_run_log_output | ternary((">" ~ tripleo_overcloud_update_run_log), '') }}
{{ tripleo_overcloud_update_run_log_combine | ternary("2>&1", '') }}
_update_run_env:
UPDATE_LIMIT: "{{ tripleo_overcloud_update_run_limit | quote }}"
UPDATE_PLAYBOOK: "{{ tripleo_overcloud_update_run_playbook| list | join(' ') }}"
UPDATE_SSH_USER: "{{ tripleo_overcloud_update_run_ssh_user }}"
UPDATE_STATIC_INVENTORY: "{{ tripleo_overcloud_update_run_static_inventory }}"
UPDATE_STACK: "{{ tripleo_overcloud_update_run_stack }}"
OS_CLOUD: "{{ tripleo_overcloud_update_run_os_cloud }}"
- name: Preserve existing log file if exists
timestamp_file:
path: "{{ tripleo_overcloud_update_run_log }}"
when: tripleo_overcloud_update_run_log_output|bool
- name: Show debug information
when: tripleo_overcloud_update_run_debug|bool
block:
- name: Show the overcloud update run command
debug:
var: _update_run_cmd
- name: Show the overcloud update run environment
debug:
var: _update_run_env
- name: Overcloud update run
shell: "{{ _update_run_cmd }}" # noqa 305
environment: "{{ _update_run_env }}"
args:
chdir: "{{ tripleo_overcloud_update_run_home_dir }}"
warn: false
register: tripleo_overcloud_update_run_result
async: "{{ tripleo_overcloud_update_run_timeout }}"
poll: "{{ tripleo_overcloud_update_run_poll }}"
changed_when: false
when: not ansible_check_mode|bool
- name: Set output fact
set_fact:
tripleo_overcloud_update_run_output: "{{ tripleo_overcloud_update_run_result.stdout }}"

View File

@ -0,0 +1 @@
localhost

View File

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

View File

@ -25,6 +25,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- tripleo-operator-molecule-tripleo_overcloud_node_import
- tripleo-operator-molecule-tripleo_overcloud_update_prepare
- tripleo-operator-molecule-tripleo_overcloud_update_run
- tripleo-operator-molecule-tripleo_undercloud_backup
- tripleo-operator-molecule-tripleo_undercloud_install
- tripleo-operator-molecule-tripleo_undercloud_minion_install
@ -56,6 +57,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_introspect
- tripleo-operator-molecule-tripleo_overcloud_node_import
- tripleo-operator-molecule-tripleo_overcloud_update_prepare
- tripleo-operator-molecule-tripleo_overcloud_update_run
- tripleo-operator-molecule-tripleo_undercloud_backup
- tripleo-operator-molecule-tripleo_undercloud_install
- tripleo-operator-molecule-tripleo_undercloud_minion_install
@ -363,6 +365,20 @@
vars:
tox_extra_args: tripleo_overcloud_update_prepare
- job:
files:
- ^roles/tripleo_overcloud_update_run/.*
- ^bindep.txt
- ^galaxy.yml
- ^requirements.txt
- ^setup.cfg
- ^test-requirements.txt
- ^tox.ini
name: tripleo-operator-molecule-tripleo_overcloud_update_run
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_update_run
- job:
files:
- ^roles/tripleo_undercloud_backup/.*