Alex Schultz d2b23da366 Add ability to write scripts
Add the ability to write out the command being exected to a script for
the roles that aren't single action list/show/remove/etc as they would
not be something to rerun and are really for ansible-only control.

Change-Id: I11ad3c12de21fe0522d13f966783cb413b661646
2020-04-15 16:25:27 -06:00

56 lines
2.9 KiB
YAML

---
- name: Setup config overcloud admin authorize ansible facts
set_fact:
_authorize_cmd: >-
{{ tripleo_overcloud_admin_authorize_os_cloud | ternary('', "source " ~ tripleo_overcloud_admin_authorize_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud admin authorize
{{ tripleo_overcloud_admin_authorize_stack | ternary("--stack $AUTHORIZE_STACK", '') }}
{{ tripleo_overcloud_admin_authorize_ssh_user | ternary("--overcloud-ssh-user $AUTHORIZE_SSH_USER", '') }}
{{ tripleo_overcloud_admin_authorize_ssh_key | ternary("--overcloud-ssh-key $AUTHORIZE_SSH_KEY", '') }}
{{ tripleo_overcloud_admin_authorize_ssh_network | ternary("--overcloud-ssh-network $AUTHORIZE_SSH_NETWORK", '') }}
{{ tripleo_overcloud_admin_authorize_ssh_enable_timeout | ternary("--overcloud-ssh-enable-timeout $AUTHORIZE_SSH_ENABLE_TIMEOUT", '') }}
{{ tripleo_overcloud_admin_authorize_ssh_port_timeout | ternary("--overcloud-ssh-port-timeout $AUTHORIZE_SSH_PORT_TIMEOUT", '') }}
{{ tripleo_overcloud_admin_authorize_output_dir | ternary("--output-dir $AUTHORIZE_OUTPUT_DIR", '') }}
_authorize_env:
AUTHORIZE_STACK: "{{ tripleo_overcloud_admin_authorize_stack }}"
AUTHORIZE_SSH_USER: "{{ tripleo_overcloud_admin_authorize_ssh_user }}"
AUTHORIZE_SSH_KEY: "{{ tripleo_overcloud_admin_authorize_ssh_key }}"
AUTHORIZE_SSH_NETWORK: "{{ tripleo_overcloud_admin_authorize_ssh_network }}"
AUTHORIZE_SSH_ENABLE_TIMEOUT: "{{ tripleo_overcloud_admin_authorize_ssh_enable_timeout }}"
AUTHORIZE_SSH_PORT_TIMEOUT: "{{ tripleo_overcloud_admin_authorize_ssh_port_timeout }}"
AUTHORIZE_OUTPUT_DIR: "{{ tripleo_overcloud_admin_authorize_output_dir }}"
OS_CLOUD: "{{ tripleo_overcloud_admin_authorize_os_cloud }}"
- name: Show debug information
when: tripleo_overcloud_admin_authorize_debug|bool
block:
- name: Show the overcloud admin authorize command
debug:
var: _authorize_cmd
- name: Show the overcloud admin authorize ansible environment
debug:
var: _authorize_env
- name: Write reproducer script
tripleo_shell_script:
dest: "{{ tripleo_overcloud_admin_authorize_home_dir }}/tripleo_overcloud_admin_authorize.sh"
shell_command: "{{ _authorize_cmd }}"
shell_environment: "{{ _authorize_env }}"
when: tripleo_overcloud_admin_authorize_generate_scripts|bool
- name: overcloud admin authorize
shell: "{{ _authorize_cmd }}" # noqa 305
args:
executable: /bin/bash
chdir: "{{ tripleo_overcloud_admin_authorize_home_dir }}"
warn: false
environment: "{{ _authorize_env }}"
async: "{{ tripleo_overcloud_admin_authorize_timeout }}"
poll: "{{ tripleo_overcloud_admin_authorize_poll }}"
register: tripleo_overcloud_admin_authorize_result
changed_when: true
- name: Set output fact
set_fact:
tripleo_overcloud_admin_authorize_output: "{{ tripleo_overcloud_admin_authorize_result.stdout }}"