From a0ead2f1a794a14cdde67b652decbb1376f3a174 Mon Sep 17 00:00:00 2001 From: Jiri Stransky Date: Tue, 2 Oct 2018 18:14:47 +0200 Subject: [PATCH] Chunk up ceph-ansible output to prevent clogging the CLI The CLI commands running Ansible can crash if we send too much single-line log output their way. This was happening on upgrades, when we run Ansible with verbosity level 1. The fix is twofold: * If ceph-ansible finishes successfully, we don't print the ceph-ansible output into the main log. * If ceph-ansible fails, we do print the output, but we print it line-by-line, which should give us much better readability than before, and we shouldn't break the limits of the Mistral-Zaqar-CLI message passing. Change-Id: I6e0fc36749e74fce25f414c2547e49e2a20437ab Closes-Bug: #1795689 --- docker/services/ceph-ansible/ceph-base.yaml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/docker/services/ceph-ansible/ceph-base.yaml b/docker/services/ceph-ansible/ceph-base.yaml index 2490b10395..be482c0074 100644 --- a/docker/services/ceph-ansible/ceph-base.yaml +++ b/docker/services/ceph-ansible/ceph-base.yaml @@ -548,9 +548,23 @@ outputs: - '{{playbook_dir}}/ceph-ansible/inventory.yml' - '--extra-vars' - '@{{playbook_dir}}/ceph-ansible/extra_vars.yml' - - name: run ceph-ansible - with_items: "{{ceph_ansible_playbooks}}" - shell: "{{ceph_ansible_command}} {{item}}" + - name: run ceph-ansible (immediate log at {{playbook_dir}}/ceph-ansible/ceph_ansible_command.log) + shell: | + set -e + {% for playbook in ceph_ansible_playbooks %} + echo "Running ceph-ansible playbook {{playbook}}" + {{ceph_ansible_command}} {{playbook}} 2>&1 + {% endfor %} + # We want the output chunked into bits to prevent + # overflowing Zaqar message size + no_log: true + failed_when: false + register: outputs + - name: print ceph-ansible output in case of failure + debug: + var: outputs.stdout_lines | default([]) | union(outputs.stderr_lines | default([])) + failed_when: outputs.rc != 0 + when: outputs.rc != 0 - name: create ceph-ansible fetch directory tarball in local backup archive: path: "{{playbook_dir}}/ceph-ansible/fetch_dir"