tripleo-operator-ansible/roles/tripleo_upgrade/tasks/main.yml

108 lines
5.4 KiB
YAML

---
# 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 }}"