ansible-role-collect-logs/roles/collect_logs/tasks/publish.yml

155 lines
5.5 KiB
YAML

---
# collection dir could be either a dir or a link
# file module cannot be used here, because it changes link to dir
# when called with state: directory
- name: Ensure the collection directory exists
shell: |
if [[ ! -d "{{ artcl_collect_dir }}" && ! -h "{{ artcl_collect_dir }}" ]]; then
mkdir -p "{{ artcl_collect_dir }}"
fi
changed_when: true
- name: Fetch console log
shell: >
set -o pipefail &&
curl -k "{{ artcl_build_url }}/timestamps/?time=yyyy-MM-dd%20HH:mm:ss.SSS%20|&appendLog&locale=en_GB"
> {{ artcl_collect_dir }}/console.log
args:
executable: /bin/bash
when:
- artcl_build_url is defined
- artcl_build_url|length > 0
- include: sova.yml
ignore_errors: true
- import_tasks: publish_ara.yml
when: ara_enabled|bool
ignore_errors: true
- name: fetch stackviz results to the root of the collect_dir
shell: >
if [ -d {{ artcl_collect_dir }}/undercloud/var/log/extra/stackviz/data ]; then
cp -r {{ artcl_collect_dir }}/undercloud/var/log/extra/stackviz {{ artcl_collect_dir }};
gunzip -fr {{ artcl_collect_dir }}/stackviz;
fi;
changed_when: true
- name: fetch stackviz results to the root of the collect_dir for os_tempest
shell: >
if [ -d {{ artcl_collect_dir }}/undercloud/var/log/tempest/stackviz/data ]; then
cp -r {{ artcl_collect_dir }}/undercloud/var/log/tempest/stackviz {{ artcl_collect_dir }};
gunzip -fr {{ artcl_collect_dir }}/stackviz;
fi;
when: use_os_tempest is defined
changed_when: true
- name: tempest results to the root of the collect_dir
shell: >
cp {{ artcl_collect_dir }}/undercloud/home/stack/tempest/tempest.{xml,html}{,.gz} {{ artcl_collect_dir }} || true;
gunzip {{ artcl_collect_dir }}/tempest.{xml,html}.gz || true;
changed_when: true
- name: Copy testrepository.subunit file to the root of collect_dir for os_tempest
shell: >
cp {{ artcl_collect_dir }}/undercloud/var/log/tempest/testrepository.subunit.gz {{ artcl_collect_dir }}/testrepository.subunit.gz || true
when: use_os_tempest is defined
- name: Fetch .sh and .log files from local working directory on localhost
shell: >
cp {{ item }} {{ artcl_collect_dir }}/
with_items:
- "{{ local_working_dir }}/*.sh"
- "{{ local_working_dir }}/*.log"
ignore_errors: true # noqa: ignore-errors
changed_when: true
# the doc footer for logging has been removed.
# copy the log readme into the base directory.
- name: copy in the logs README.html
shell: >
if [ -f {{ artcl_readme_path }} ]; then
cp {{ artcl_readme_path }} {{ artcl_readme_file }};
fi;
ignore_errors: true # noqa: ignore-errors
changed_when: true
- name: Rename compressed text based files to end with txt.gz extension
shell: >
set -o pipefail &&
find {{ artcl_collect_dir }}/ -type f |
awk 'function rename(orig)
{ new=orig; sub(/\.gz$/, ".txt.gz", new); system("mv " orig " " new) }
/\.(conf|ini|json|sh|log|yaml|yml|repo|cfg|j2|py)\.gz$/ { rename($0) }
/(\/var\/log\/|\/etc\/)[^ \/\.]+\.gz$/ { rename($0) }';
args:
executable: /bin/bash
when: artcl_txt_rename|bool
- name: Create the reproducer script
include_role:
name: create-reproducer-script
when: ansible_env.TOCI_JOBTYPE is defined
- name: Create the zuul-based reproducer script if we are running on zuul
include_role:
name: create-zuul-based-reproducer
when: zuul is defined
# This is where upload starts, no local change after this line
# All tags after this line are marked with "notest" to allow testing (molecule) in absence of access to log servers.
- name: upload to the artifact server using pubkey auth # noqa: command-instead-of-module
command: >
rsync -av
--quiet -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ artcl_report_server_key|default('') }}"
{{ artcl_collect_dir }}/ {{ artcl_rsync_path }}/{{ artcl_build_tag }}
async: "{{ artcl_publish_timeout }}"
poll: 15
retries: 5
delay: 60
when: artcl_use_rsync|bool and not artcl_rsync_use_daemon|bool
tags: notest
- name: upload to the artifact server using password auth # noqa: command-instead-of-module
environment:
RSYNC_PASSWORD: "{{ artcl_rsync_password | default(omit) }}"
command: rsync -av --quiet {{ artcl_collect_dir }}/ {{ artcl_rsync_path }}/{{ artcl_build_tag }}
async: "{{ artcl_publish_timeout }}"
poll: 15
retries: 5
delay: 60
when: artcl_use_rsync|bool and artcl_rsync_use_daemon|bool
tags: notest
- name: upload to swift based artifact server
shell: swift upload --quiet --header "X-Delete-After:{{ artcl_swift_delete_after }}" {{ artcl_swift_container }}/{{ artcl_build_tag }} *
args:
chdir: "{{ artcl_collect_dir }}"
changed_when: true
environment:
OS_AUTH_URL: "{{ artcl_swift_auth_url }}"
OS_USERNAME: "{{ artcl_swift_username }}"
OS_PASSWORD: "{{ artcl_swift_password }}"
OS_TENANT_NAME: "{{ artcl_swift_tenant_name }}"
async: "{{ artcl_publish_timeout }}"
poll: 15
when: artcl_use_swift|bool
tags: notest
- name: use zuul_swift_upload.py to publish the files
shell: >
"{{ artcl_zuul_swift_upload_path }}/zuul_swift_upload.py --name {{ artcl_swift_container }}
--delete-after {{ artcl_swift_delete_after }} {{ artcl_collect_dir }}"
async: "{{ artcl_publish_timeout }}"
poll: 15
when: artcl_use_zuul_swift_upload|bool
tags: notest
- name: create the artifact location redirect file
template:
src: full_logs.html.j2
dest: "{{ artcl_collect_dir }}/full_logs.html"
mode: 0644
when: artcl_env != 'tripleo-ci'
tags: notest