From 1d330c9996fdd0086525539fc0a0e142b6af7994 Mon Sep 17 00:00:00 2001 From: Jose Luis Franco Arza Date: Mon, 8 Nov 2021 11:05:44 +0100 Subject: [PATCH] Add tripleo_upgrade role. Includes the role to automate the execution of the openstack tripleo upgrade command. As most of the code is shared with tripleo-deploy this role is mostly based on tripleo-deploy. The only appreciable difference is that the --upgrade parameter is not being passed (as that is being passed to true when invoking the Deploy class [0]). [0] - https://github.com/openstack/python-tripleoclient/blob/master/tripleoclient/v1/tripleo_upgrade.py#L41 Change-Id: Ie2eb2c220fef9284bf5fa6ef6908a00839589649 --- roles/tripleo_deploy/README.md | 2 +- roles/tripleo_upgrade/README.md | 85 ++++ roles/tripleo_upgrade/defaults/main.yml | 43 ++ roles/tripleo_upgrade/meta/main.yml | 44 ++ .../molecule/default/converge.yml | 420 ++++++++++++++++++ .../molecule/default/molecule.yml | 19 + .../molecule/default/prepare.yml | 8 + roles/tripleo_upgrade/tasks/main.yml | 107 +++++ roles/tripleo_upgrade/tests/inventory | 1 + roles/tripleo_upgrade/tests/test.yml | 4 + zuul.d/layout.yaml | 1 + zuul.d/molecule.yaml | 17 + 12 files changed, 750 insertions(+), 1 deletion(-) create mode 100644 roles/tripleo_upgrade/README.md create mode 100644 roles/tripleo_upgrade/defaults/main.yml create mode 100644 roles/tripleo_upgrade/meta/main.yml create mode 100644 roles/tripleo_upgrade/molecule/default/converge.yml create mode 100644 roles/tripleo_upgrade/molecule/default/molecule.yml create mode 100644 roles/tripleo_upgrade/molecule/default/prepare.yml create mode 100644 roles/tripleo_upgrade/tasks/main.yml create mode 100644 roles/tripleo_upgrade/tests/inventory create mode 100644 roles/tripleo_upgrade/tests/test.yml diff --git a/roles/tripleo_deploy/README.md b/roles/tripleo_deploy/README.md index 142b43e..8343f3e 100644 --- a/roles/tripleo_deploy/README.md +++ b/roles/tripleo_deploy/README.md @@ -48,7 +48,7 @@ Role Variables * `tripleo_deploy_templates`: (String) Path to the directory containing heat templates for the deployment. Default: /usr/share/openstack-tripleo-heat-templates * `tripleo_deploy_timeout`: (Integer) Number in seconds to wait for the ansible execution of the deployment command to finish. This should be larger than the `tripleo_deploy_timeout_arg` value. Default: 5700 * `tripleo_deploy_timeout_arg`: (Integer) Number in minutes for the deployment to run. Default: 90 -* `tripleo_deploy_upgrade`: (Boolean) Flag to indicate upgrade an existing deployment. Default: true +* `tripleo_deploy_upgrade`: (Boolean) Flag to indicate upgrade an existing deployment. Default: false * `tripleo_deploy_yes`: (Boolean) Flag to skip yes/no prompts. Default: true Output Variables diff --git a/roles/tripleo_upgrade/README.md b/roles/tripleo_upgrade/README.md new file mode 100644 index 0000000..ec1beb2 --- /dev/null +++ b/roles/tripleo_upgrade/README.md @@ -0,0 +1,85 @@ +tripleo_upgrade +============== + +A role to execute a single node standalone upgrade. + +Requirements +------------ + +None. + +Role Variables +-------------- + +* `tripleo_upgrade_become`: (Boolean) Execute command with escalated privileges. Default: true +* `tripleo_upgrade_cleanup`: (Boolean) Cleanup temporary files after execution. Default: false +* `tripleo_upgrade_control_virtual_ip`: (String) Control plain VIP address. +* `tripleo_upgrade_debug`: (Boolean) Flag to print out the command that is run. Default: false +* `tripleo_upgrade_debug_arg`: (Boolean) Flag for ansible to use -vv. Default: false +* `tripleo_upgrade_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_upgrade_generate_scripts_only`: (Boolean) Do not run the actual command - to be used in conjunction with `tripleo_upgrade_generate_scripts`. By default uses the value of `tripleo_generate_scripts_only` or False if `tripleo_generate_scripts_only` is not defined. +* `tripleo_upgrade_deployment_python_interpreter`: (String) Path to a python interpreter for the deployment actions. +* `tripleo_upgrade_deployment_user`: (String) User who is executing the tripleo deployment via sudo. Defaults: "{{ ansible_env.USER }}" +* `tripleo_upgrade_environment_files`: (List) A list of environment file paths for the deployment. +* `tripleo_upgrade_force_stack_create`: (Boolean) Flag to force stack create. Default: false +* `tripleo_upgrade_force_stack_update`: (Boolean) Flag to force stack update. Default: false +* `tripleo_upgrade_heat_api_port`: (Number) Heat API port to use for the installer. +* `tripleo_upgrade_heat_container_image`: (String) Full container image location for the openstack-heat-all container. +* `tripleo_upgrade_heat_user`: (String) User to execute the non-privileged heat-all process. +* `tripleo_upgrade_hieradata_override`: (String) Path to hiera data override file. +* `tripleo_upgrade_home_dir`: (String) Path to the directory to execute the command in. Default: "{{ ansible_env.HOME }}" +* `tripleo_upgrade_inflight_validations`: (Boolean) Flag to enable in-flight validations. Default: false +* `tripleo_upgrade_keep_running`: (Boolean) Flag to keep the heat instance running after the deploy has run. Default: false +* `tripleo_upgrade_local_domain`: (String): Local domain for standalone cloud and the endpoints. +* `tripleo_upgrade_local_ip`: (String) Local IP address to use for the cloud traffic. REQUIRED. +* `tripleo_upgrade_log`: (String) Path to a log file for the command output. Default: "{{ tripleo_upgrade_home_dir }}/overcloud_deploy.log" +* `tripleo_upgrade_log_combine`: (Boolean) Flag to enable capturing stderr with stdout. Default: true +* `tripleo_upgrade_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_upgrade_networks_file`: (String) File path to a networks file for the deployment. +* `tripleo_upgrade_output_dir`: (String) Directory to write output data to. +* `tripleo_upgrade_output_only`: (String) Flag to skip ansible execution and only output the deployment scripts. Default: false +* `tripleo_upgrade_plan_environment_file`: (String) File path to a plan environment file. +* `tripleo_upgrade_poll`: (Integer) Number of seconds to wait between each checks to see if the deployment command has completed. Default: 10 +* `tripleo_upgrade_public_virtual_ip`: (String) Public network VIP. +* `tripleo_upgrade_roles_file`: (String) File path to an upgrade roles file. +* `tripleo_upgrade_stack`: (String) Name for ephemeral stack. Default: standalone +* `tripleo_upgrade_standalone`: (Boolean) Flag to indicate that a standalone cloud is being deployed. Should be false after the Victoria. Default: false +* `tripleo_upgrade_standalone_role`: (String) Role name to upgrade. Default: Standalone +* `tripleo_upgrade_templates`: (String) Path to the directory containing heat templates for the deployment. Default: /usr/share/openstack-tripleo-heat-templates +* `tripleo_upgrade_timeout`: (Integer) Number in seconds to wait for the ansible execution of the deployment command to finish. This should be larger than the `tripleo_upgrade_timeout_arg` value. Default: 5700 +* `tripleo_upgrade_timeout_arg`: (Integer) Number in minutes for the upgrade to run. Default: 90 +* `tripleo_upgrade_yes`: (Boolean) Flag to skip yes/no prompts. Default: true + +Output Variables +---------------- + +* `tripleo_upgrade_output`: (String) The command standard output. +* `tripleo_upgrade_result`: Ansible shell execution results + +Dependencies +------------ + +None. + +Example Playbook +---------------- + +Example overcloud upgrade execution playbook + +```yaml +- hosts: standalone + gather_facts: true + tasks: + - name: Run standalone upgrade + import_role: + name: tripleo_upgrade + vars: + tripleo_upgrade_local_ip: 192.168.24.2/24 + tripleo_upgrade_environment_files: + - /usr/share/openstack-tripleo-heat-templates/environments/enable-swap.yaml +``` + +License +------- + +Apache-2.0 diff --git a/roles/tripleo_upgrade/defaults/main.yml b/roles/tripleo_upgrade/defaults/main.yml new file mode 100644 index 0000000..dc11ca8 --- /dev/null +++ b/roles/tripleo_upgrade/defaults/main.yml @@ -0,0 +1,43 @@ +--- +# defaults file for tripleo_upgrade +openstack_bin: openstack +tripleo_upgrade_become: true +tripleo_upgrade_cleanup: false +tripleo_upgrade_control_virtual_ip: +tripleo_upgrade_debug: false +tripleo_upgrade_debug_arg: false +tripleo_upgrade_deployment_python_interpreter: +tripleo_upgrade_deployment_user: "{{ ansible_env.USER }}" +tripleo_upgrade_environment_files: [] +tripleo_upgrade_force_stack_create: false +tripleo_upgrade_force_stack_update: false +tripleo_upgrade_generate_scripts: "{{ tripleo_generate_scripts | default(False) }}" +tripleo_upgrade_generate_scripts_only: "{{ tripleo_generate_scripts_only | default(False) }}" +tripleo_upgrade_heat_api_port: +tripleo_upgrade_heat_container_image: +tripleo_upgrade_heat_user: +tripleo_upgrade_hieradata_override: +tripleo_upgrade_home_dir: "{{ ansible_env.HOME }}" +tripleo_upgrade_inflight_validations: false +tripleo_upgrade_keep_running: false +tripleo_upgrade_local_domain: +tripleo_upgrade_local_ip: +tripleo_upgrade_log: "{{ tripleo_upgrade_home_dir }}/standalone_upgrade.log" +tripleo_upgrade_log_combine: true +tripleo_upgrade_log_output: true +tripleo_upgrade_networks_file: +tripleo_upgrade_output_dir: +tripleo_upgrade_output_only: false +tripleo_upgrade_override_ansible_cfg: +tripleo_upgrade_plan_environment_file: +tripleo_upgrade_poll: 10 +tripleo_upgrade_public_virtual_ip: +tripleo_upgrade_roles_file: "{{ tripleo_upgrade_templates }}/roles/Standalone.yaml" +tripleo_upgrade_stack: standalone +tripleo_upgrade_standalone: false +tripleo_upgrade_standalone_role: Standalone +tripleo_upgrade_templates: /usr/share/openstack-tripleo-heat-templates +tripleo_upgrade_timeout: 5700 +tripleo_upgrade_timeout_arg: 90 +tripleo_upgrade_yes: true +tripleo_upgrade_reproducer_command: false diff --git a/roles/tripleo_upgrade/meta/main.yml b/roles/tripleo_upgrade/meta/main.yml new file mode 100644 index 0000000..67d6bea --- /dev/null +++ b/roles/tripleo_upgrade/meta/main.yml @@ -0,0 +1,44 @@ +--- +# 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: + role_name: tripleo_upgrade + namespace: openstack + author: OpenStack + description: TripleO Operator Role -- tripleo_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: [] diff --git a/roles/tripleo_upgrade/molecule/default/converge.yml b/roles/tripleo_upgrade/molecule/default/converge.yml new file mode 100644 index 0000000..eb9aacb --- /dev/null +++ b/roles/tripleo_upgrade/molecule/default/converge.yml @@ -0,0 +1,420 @@ +--- +- name: Converge + hosts: all + collections: + - tripleo.operator + vars: + openstack_bin: echo + tripleo_upgrade_become: false + tripleo_upgrade_debug: true + tripleo_upgrade_log_output: false + tripleo_upgrade_log_combine: false + tripleo_upgrade_poll: 1 + tripleo_upgrade_local_ip: 192.168.24.2/24 + tripleo_upgrade_deployment_user: + tripleo_upgrade_roles_file: + tripleo_upgrade_yes: false + tasks: + + - name: "Include tripleo_upgrade" + include_role: + name: "tripleo_upgrade" + + - name: Check role + assert: + that: + - tripleo_upgrade_output == + "tripleo upgrade --templates /usr/share/openstack-tripleo-heat-templates " + "--stack standalone --standalone-role Standalone --timeout 90 " + "--local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_stack" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: test + tripleo_upgrade_standalone: true + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + + - name: Assert "tripleo_upgrade_stack" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --standalone --stack test --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_yes" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_yes: true + + - name: Assert "tripleo_upgrade_yes" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --yes --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_output_dir" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_output_dir: /foo + + - name: Assert "tripleo_upgrade_output_dir" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --output-dir /foo --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_output_only" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_output_only: true + + - name: Assert "tripleo_upgrade_output_only" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --output-only --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_environment_files" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_environment_files: + - /foo/bar.yml + - /foo/baz.yml + + - name: Assert "tripleo_upgrade_environment_files" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade -e /foo/bar.yml -e /foo/baz.yml --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_roles_file" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_roles_file: roles.yaml + + - name: Assert "tripleo_upgrade_roles_file" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade -r roles.yaml --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_networks_file" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_networks_file: net.yaml + + - name: Assert "tripleo_upgrade_networks_file" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade -n net.yaml --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_plan_environment_file" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_plan_environment_file: plan.yaml + + - name: Assert "tripleo_upgrade_plan_environment_file" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade -p plan.yaml --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_heat_api_port" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_heat_api_port: 1111 + + - name: Assert "tripleo_upgrade_heat_api_port" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --heat-api-port 1111 --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_heat_container_image" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_heat_container_image: quay.io/tripleomaster/openstack-heat-all:foo + + - name: Assert "tripleo_upgrade_heat_api_port" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --heat-container-image quay.io/tripleomaster/openstack-heat-all:foo --local-ip 192.168.24.2/24" + + + - name: Check parameter "tripleo_upgrade_heat_user" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_heat_user: foo + + - name: Assert "tripleo_upgrade_heat_user" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --heat-user foo --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_deployment_user" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_deployment_user: user + + - name: Assert "tripleo_upgrade_deployment_user" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --deployment-user user --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_deployment_python_interpreter" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_deployment_python_interpreter: python2 + + - name: Assert "tripleo_upgrade_deployment_python_interpreter" + assert: + that: + - tripleo_upgrade_output == + "tripleo upgrade --deployment-python-interpreter python2 --local-ip 192.168.24.2/24" + + - name: Check parameter "tripleo_upgrade_control_virtual_ip" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_control_virtual_ip: 1.1.1.12 + + - name: Assert "tripleo_upgrade_control_virtual_ip" + assert: + that: + - tripleo_upgrade_output == + "tripleo upgrade --local-ip 192.168.24.2/24 --control-virtual-ip 1.1.1.12" + + - name: Check parameter "tripleo_upgrade_public_virtual_ip" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_public_virtual_ip: 1.1.1.13 + + - name: Assert "tripleo_upgrade_public_virtual_ip" + assert: + that: + - tripleo_upgrade_output == + "tripleo upgrade --local-ip 192.168.24.2/24 --public-virtual-ip 1.1.1.13" + + - name: Check parameter "tripleo_upgrade_local_domain" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_local_domain: rh.local + + - name: Assert "tripleo_upgrade_local_domain" + assert: + that: + - tripleo_upgrade_output == + "tripleo upgrade --local-ip 192.168.24.2/24 --local-domain rh.local" + + - name: Check parameter "tripleo_upgrade_cleanup" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_cleanup: true + + - name: Assert "tripleo_upgrade_cleanup" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --local-ip 192.168.24.2/24 --cleanup" + + - name: Check parameter "tripleo_upgrade_hieradata_override" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_hieradata_override: /foo.yml + + - name: Assert "tripleo_upgrade_hieradata_override" + assert: + that: + - tripleo_upgrade_output == + "tripleo upgrade --local-ip 192.168.24.2/24 --hieradata-override /foo.yml" + + - name: Check parameter "tripleo_upgrade_keep_running" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_keep_running: true + + - name: Assert "tripleo_upgrade_keep_running" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --local-ip 192.168.24.2/24 --keep-running" + + - name: Check parameter "tripleo_upgrade_inflight_validations" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_inflight_validations: true + + - name: Assert "tripleo_upgrade_inflight_validations" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --local-ip 192.168.24.2/24 --inflight-validations" + + - name: Check parameter "tripleo_upgrade_force_stack_create" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_force_stack_create: true + + - name: Assert "tripleo_upgrade_force_stack_create" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --local-ip 192.168.24.2/24 --force-stack-create" + + - name: Check parameter "tripleo_upgrade_force_stack_update" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_force_stack_update: true + + - name: Assert "tripleo_upgrade_force_stack_update" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --local-ip 192.168.24.2/24 --force-stack-update" + + - name: Check parameter "tripleo_upgrade_reproducer_command" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_reproducer_command: true + + - name: Assert "tripleo_upgrade_reproducer_command" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --local-ip 192.168.24.2/24 --reproduce-command" + + - name: Check parameter "tripleo_upgrade_debug_arg" + include_role: + name: "tripleo_upgrade" + vars: + tripleo_upgrade_templates: + tripleo_upgrade_stack: + tripleo_upgrade_standalone: false + tripleo_upgrade_standalone_role: + tripleo_upgrade_timeout_arg: + tripleo_upgrade_debug_arg: true + + - name: Assert "tripleo_upgrade_debug_arg" + assert: + that: + - tripleo_upgrade_output == "tripleo upgrade --debug --local-ip 192.168.24.2/24" diff --git a/roles/tripleo_upgrade/molecule/default/molecule.yml b/roles/tripleo_upgrade/molecule/default/molecule.yml new file mode 100644 index 0000000..2841806 --- /dev/null +++ b/roles/tripleo_upgrade/molecule/default/molecule.yml @@ -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 diff --git a/roles/tripleo_upgrade/molecule/default/prepare.yml b/roles/tripleo_upgrade/molecule/default/prepare.yml new file mode 100644 index 0000000..63bb6ab --- /dev/null +++ b/roles/tripleo_upgrade/molecule/default/prepare.yml @@ -0,0 +1,8 @@ +--- +- name: Prepare + hosts: all + tasks: + + - name: Include molecule prep + include_role: + name: test_molecule_prep diff --git a/roles/tripleo_upgrade/tasks/main.yml b/roles/tripleo_upgrade/tasks/main.yml new file mode 100644 index 0000000..1be24fc --- /dev/null +++ b/roles/tripleo_upgrade/tasks/main.yml @@ -0,0 +1,107 @@ +--- +# tasks file for tripleo_upgrade +- name: Validate local ip is set + fail: + msg: "tripleo_upgrade_local_ip must be configured" + when: not tripleo_upgrade_local_ip + +- name: Setup standalone upgrade facts + set_fact: + _upgrade_cmd: >- + {{ openstack_bin }} tripleo upgrade + {{ tripleo_upgrade_debug_arg | ternary('--debug', '') }} + {{ tripleo_upgrade_templates | ternary('--templates $UPGRADE_TEMPLATES', '') }} + {{ tripleo_upgrade_standalone | ternary('--standalone', '') }} + {{ tripleo_upgrade_yes | ternary('--yes', '') }} + {{ tripleo_upgrade_output_dir | ternary('--output-dir $UPGRADE_OUTPUT_DIR', '') }} + {{ tripleo_upgrade_output_only | ternary('--output-only', '') }} + {{ tripleo_upgrade_stack | ternary('--stack $UPGRADE_STACK', '') }} + {{ tripleo_upgrade_standalone_role | ternary('--standalone-role $UPGRADE_STANDALONE_ROLE', '') }} + {{ tripleo_upgrade_timeout_arg | ternary('--timeout $UPGRADE_TIMEOUT_ARG', '') }} + {{ tripleo_upgrade_environment_files | tripleo.operator.shell_arg_list(parameter='-e') }} + {{ tripleo_upgrade_roles_file | ternary('-r $UPGRADE_ROLES_FILE', '') }} + {{ tripleo_upgrade_networks_file | ternary('-n $UPGRADE_NETWORKS_FILE', '') }} + {{ tripleo_upgrade_plan_environment_file | ternary('-p $UPGRADE_PLAN_ENV_FILE', '') }} + {{ tripleo_upgrade_heat_api_port | ternary('--heat-api-port $UPGRADE_HEAT_API_PORT', '') }} + {{ tripleo_upgrade_heat_container_image | ternary('--heat-container-image $UPGRADE_HEAT_CONTAINER_IMAGE', '') }} + {{ tripleo_upgrade_heat_user | ternary('--heat-user $UPGRADE_HEAT_USER', '') }} + {{ tripleo_upgrade_deployment_user | ternary('--deployment-user $UPGRADE_DEPLOYMENT_USER', '') }} + {{ tripleo_upgrade_deployment_python_interpreter | ternary('--deployment-python-interpreter $UPGRADE_PYTHON_INTERPRETER', '') }} + {{ tripleo_upgrade_local_ip | ternary('--local-ip $UPGRADE_LOCAL_IP', '') }} + {{ tripleo_upgrade_control_virtual_ip | ternary('--control-virtual-ip $UPGRADE_CONTROL_VIP', '') }} + {{ tripleo_upgrade_public_virtual_ip | ternary('--public-virtual-ip $UPGRADE_PUBLIC_VIP', '') }} + {{ tripleo_upgrade_local_domain | ternary('--local-domain $UPGRADE_LOCAL_DOMAIN', '') }} + {{ tripleo_upgrade_cleanup | ternary('--cleanup', '') }} + {{ tripleo_upgrade_hieradata_override | ternary('--hieradata-override $UPGRADE_HIERADATA_OVERRIDE', '') }} + {{ tripleo_upgrade_keep_running | ternary('--keep-running', '') }} + {{ tripleo_upgrade_inflight_validations | ternary('--inflight-validations', '') }} + {{ tripleo_upgrade_force_stack_create | ternary('--force-stack-create', '') }} + {{ tripleo_upgrade_force_stack_update | ternary('--force-stack-update', '') }} + {{ tripleo_upgrade_reproducer_command | ternary('--reproduce-command', '') }} + {{ tripleo_upgrade_log_output | ternary((">" ~ tripleo_upgrade_log), '') }} + {{ tripleo_upgrade_log_combine | ternary("2>&1", '') }} + _upgrade_env: + UPGRADE_CONTROL_VIP: "{{ tripleo_upgrade_control_virtual_ip }}" + UPGRADE_DEPLOYMENT_USER: "{{ tripleo_upgrade_deployment_user }}" + UPGRADE_HEAT_API_PORT: "{{ tripleo_upgrade_heat_api_port }}" + UPGRADE_HEAT_CONTAINER_IMAGE: "{{ tripleo_upgrade_heat_container_image }}" + UPGRADE_HEAT_USER: "{{ tripleo_upgrade_heat_user }}" + UPGRADE_HIERADATA_OVERRIDE: "{{ tripleo_upgrade_hieradata_override }}" + UPGRADE_LOCAL_DOMAIN: "{{ tripleo_upgrade_local_domain }}" + UPGRADE_LOCAL_IP: "{{ tripleo_upgrade_local_ip }}" + UPGRADE_NETWORKS_FILE: "{{ tripleo_upgrade_networks_file }}" + UPGRADE_OUTPUT_DIR: "{{ tripleo_upgrade_output_dir }}" + UPGRADE_PLAN_ENV_FILE: "{{ tripleo_upgrade_plan_environment_file }}" + UPGRADE_PUBLIC_VIP: "{{ tripleo_upgrade_public_virtual_ip }}" + UPGRADE_PYTHON_INTERPRETER: "{{ tripleo_upgrade_deployment_python_interpreter }}" + UPGRADE_ROLES_FILE: "{{ tripleo_upgrade_roles_file }}" + UPGRADE_STACK: "{{ tripleo_upgrade_stack }}" + UPGRADE_STANDALONE_ROLE: "{{ tripleo_upgrade_standalone_role }}" + UPGRADE_TEMPLATES: "{{ tripleo_upgrade_templates }}" + UPGRADE_TIMEOUT_ARG: "{{ tripleo_upgrade_timeout_arg }}" + + +- name: Preserve existing log file if exists + timestamp_file: + path: "{{ tripleo_upgrade_log }}" + when: tripleo_upgrade_log_output|bool + +- name: Show debug information + when: tripleo_upgrade_debug|bool + block: + - name: Show the standalone upgrade command + debug: + var: _upgrade_cmd + + - name: Show the standalone upgrade environment + debug: + var: _upgrade_env + +- name: Write reproducer script + tripleo_shell_script: + dest: "{{ tripleo_upgrade_home_dir }}/tripleo_upgrade.sh" + shell_command: "{{ _upgrade_cmd }}" + shell_environment: "{{ _upgrade_env }}" + when: tripleo_upgrade_generate_scripts|bool + +- name: Standalone upgrade + shell: "{{ _upgrade_cmd }}" # noqa 305 + environment: "{{ _upgrade_env }}" + args: + executable: /bin/bash + chdir: "{{ tripleo_upgrade_home_dir }}" + warn: false + become: "{{ tripleo_upgrade_become }}" + register: tripleo_upgrade_result + async: "{{ tripleo_upgrade_timeout }}" + poll: "{{ tripleo_upgrade_poll }}" + changed_when: false + when: + - not ansible_check_mode|bool + - not tripleo_upgrade_generate_scripts_only|bool + +- name: Set output fact + when: + - tripleo_upgrade_result.stdout is defined + set_fact: + tripleo_upgrade_output: "{{ tripleo_upgrade_result.stdout }}" diff --git a/roles/tripleo_upgrade/tests/inventory b/roles/tripleo_upgrade/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/roles/tripleo_upgrade/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/roles/tripleo_upgrade/tests/test.yml b/roles/tripleo_upgrade/tests/test.yml new file mode 100644 index 0000000..395f9e6 --- /dev/null +++ b/roles/tripleo_upgrade/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: localhost + roles: + - tripleo_upgrade diff --git a/zuul.d/layout.yaml b/zuul.d/layout.yaml index 52a4a7d..f0a1351 100644 --- a/zuul.d/layout.yaml +++ b/zuul.d/layout.yaml @@ -76,6 +76,7 @@ files: &standalone_files - ^roles/tripleo_deploy/.*$ - ^roles/tripleo_container_image_prepare_default/.*$ + #TODO(jfrancoa): Add standalone-upgrade job when job is stable gate: jobs: - openstack-tox-linters diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index e30a676..6e17ef9 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -13,6 +13,7 @@ - tripleo-operator-molecule-tripleo_container_image_show - tripleo-operator-molecule-tripleo_overcloud_image_upload - tripleo-operator-molecule-tripleo_deploy + - tripleo-operator-molecule-tripleo_upgrade - tripleo-operator-molecule-tripleo_overcloud_admin_authorize - tripleo-operator-molecule-tripleo_overcloud_backup - tripleo-operator-molecule-tripleo_overcloud_cell_export @@ -83,6 +84,7 @@ - tripleo-operator-molecule-tripleo_container_image_show - tripleo-operator-molecule-tripleo_overcloud_image_upload - tripleo-operator-molecule-tripleo_deploy + - tripleo-operator-molecule-tripleo_upgrade - tripleo-operator-molecule-tripleo_overcloud_admin_authorize - tripleo-operator-molecule-tripleo_overcloud_backup - tripleo-operator-molecule-tripleo_overcloud_cell_export @@ -284,6 +286,21 @@ vars: tox_extra_args: tripleo_deploy +- job: + files: + - ^bindep.txt + - ^galaxy.yml + - ^molecule-requirements.txt + - ^requirements.txt + - ^roles/tripleo_upgrade/.* + - ^setup.cfg + - ^test-requirements.txt + - ^tox.ini + name: tripleo-operator-molecule-tripleo_upgrade + parent: tripleo-operator-molecule-base + vars: + tox_extra_args: tripleo_upgrade + - job: files: - ^bindep.txt