tripleo-ansible/tripleo_ansible/roles/tripleo_run_cephadm/tasks/main.yml

79 lines
3.0 KiB
YAML

---
# Copyright 2021 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.
# tasks file for tripleo_run_cephadm
- name: set cephadm playbook
set_fact:
tripleo_run_cephadm_playbook: >
{{ tripleo_run_cephadm_playbook|default('/usr/share/ansible/tripleo-playbooks/cephadm.yml') }}
- name: Setup the log path
set_fact:
tripleo_run_cephadm_log_path: "{{ playbook_dir }}/cephadm/{{ tripleo_run_cephadm_command_log }}"
- name: Setup the cephadm playbook command
set_fact:
triple_run_cephadm_command_list:
- ANSIBLE_LOG_PATH="{{ tripleo_run_cephadm_log_path }}"
- ANSIBLE_HOST_KEY_CHECKING=false
- ansible-playbook
- '{% if ansible_python_interpreter is defined %}-e ansible_python_interpreter={{ ansible_python_interpreter }}{% endif %}'
- '-e @{{ playbook_dir }}/cephadm/cephadm-extra-vars-heat.yml'
- '-e @{{ playbook_dir }}/cephadm/cephadm-extra-vars-ansible.yml'
- '-e @{{ playbook_dir }}/global_vars.yaml'
- name: save cephadm playbook command to shell script
copy:
dest: "{{ playbook_dir }}/cephadm/cephadm_command.sh"
mode: '0755'
content: |
#!/usr/bin/env bash
set -e
echo "Running $0" >> {{ tripleo_run_cephadm_log_path }}
{% set inv = "-i "+ inventory_file %}
{{ triple_run_cephadm_command_list|join(' ') }} {{ inv }} {{ tripleo_run_cephadm_playbook }} 2>&1
- name: "Notify user about upcoming cephadm execution(s)"
debug:
msg: "Running {{ ceph_scripts|default(['cephadm_command.sh'])|length }} cephadm playbook(s) (immediate log at {{ tripleo_run_cephadm_log_path }})"
- name: run cephadm playbook
shell: "{{ playbook_dir + '/cephadm/cephadm_command.sh' }}"
failed_when: false
register: triple_run_cephadm_output
when: triple_run_cephadm_output.rc is undefined or triple_run_cephadm_output.rc == 0
tags:
- run_cephadm
- name: search triple_run_cephadm_output of cephadm run(s) non-zero return codes
set_fact:
tripleo_run_cephadm_std_out_err: "{{ triple_run_cephadm_output.stdout_lines | default([]) | union(triple_run_cephadm_output.stderr_lines | default([])) }}"
no_log: "{{ tripleo_run_cephadm_hide_sensitive_logs | bool }}"
when:
- triple_run_cephadm_output.rc is defined
- triple_run_cephadm_output.rc != 0
tags:
- run_cephadm
- name: print cephadm triple_run_cephadm_output in case of failure
debug:
var: tripleo_run_cephadm_std_out_err
when:
- tripleo_run_cephadm_std_out_err is defined
failed_when:
- tripleo_run_cephadm_std_out_err is defined
tags:
- run_cephadm