Files
tripleo-operator-ansible/roles/tripleo_overcloud_export/tasks/main.yml
Cédric Jeanneret 7ae7c668ed Ensure we export result only if we have an stdout
I841743fb6c2c24e4a3d86598f99322022b27804d introduced a sort of "dry-run"
capability to the operators, but it didn't take care of the possible
exposure of the shell stdout in a fact. Thus, if you enabled the
generate_scripts_only feature, your ansible run would fail on the
exposure, since the variable it refers to will not exist.

Change-Id: I07225e6b82199cf15860e55db6995c994da65931
2020-05-15 15:43:20 +02:00

52 lines
1.9 KiB
YAML

---
# tasks file for tripleo_overcloud_export
- name: Setup overcloud export facts
set_fact:
_export_cmd: >-
{{ tripleo_overcloud_export_os_cloud | ternary('', "source " ~ tripleo_overcloud_export_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud export
{{ tripleo_overcloud_export_stack | ternary('--stack ' ~ tripleo_overcloud_export_stack, '') }}
{{ tripleo_overcloud_export_output_file | ternary('--output-file ' ~ tripleo_overcloud_export_output_file, '') }}
{{ tripleo_overcloud_export_force_overwrite | ternary('--force-overwrite', '') }}
{{ tripleo_overcloud_export_config_download_dir | ternary('--config-download-dir ' ~ tripleo_overcloud_export_config_download_dir, '') }}
{{ tripleo_overcloud_export_no_password_excludes | ternary('--no-password-excludes', '') }}
_export_env:
OS_CLOUD: "{{ tripleo_overcloud_export_os_cloud }}"
- name: Show debug information
when: tripleo_overcloud_export_debug|bool
block:
- name: Show the overcloud export command
debug:
var: _export_cmd
- name: Show the overcloud export environment
debug:
var: _export_env
- name: Write reproducer script
tripleo_shell_script:
dest: "{{ tripleo_overcloud_export_home_dir }}/tripleo_overcloud_export.sh"
shell_command: "{{ _export_cmd }}"
shell_environment: "{{ _export_env }}"
when: tripleo_overcloud_export_generate_scripts|bool
- name: Overcloud export
shell: "{{ _export_cmd }}" # noqa 305
environment: "{{ _export_env }}"
args:
executable: /bin/bash
chdir: "{{ tripleo_overcloud_export_home_dir }}"
warn: false
register: tripleo_overcloud_export_result
changed_when: false
when:
- not ansible_check_mode|bool
- not tripleo_overcloud_export_generate_scripts_only|bool
- name: Set output fact
when:
- tripleo_overcloud_export_result.stdout is defined
set_fact:
tripleo_overcloud_export_output: "{{ tripleo_overcloud_export_result.stdout }}"