6d23d20f2f
This is preparation for a later version of ansbile-lint, which finds missing names on blocks. This seems a reasonable rule, and the Ansible manual says [1] Names for blocks have been available since Ansible 2.3. We recommend using names in all tasks, within blocks or elsewhere, for better visibility into the tasks being executed when you run the playbook. This simply adds a name tag for blocks that are missing it. This should have no operational change, but allows us to update the linter in a follow-on change. [1] https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html Change-Id: I92ed4616775650aced352bc9088a07e919f1a25f
86 lines
2.5 KiB
YAML
86 lines
2.5 KiB
YAML
- name: Set zuul-log-path fact
|
|
include_role:
|
|
name: set-zuul-log-path-fact
|
|
|
|
# Always upload (true), never upload (false) or only on failure ('failure')
|
|
- name: Upload logs
|
|
when: zuul_site_upload_logs | default(true) | bool or
|
|
(zuul_site_upload_logs == 'failure' and not zuul_success | bool)
|
|
block:
|
|
|
|
- name: Create log directories
|
|
file:
|
|
path: "{{ zuul_logserver_root }}/{{ zuul_log_path }}"
|
|
state: directory
|
|
recurse: yes
|
|
mode: 0775
|
|
|
|
# Use chmod instead of file because ansible 2.5 file with recurse and
|
|
# follow can't really handle symlinks to .
|
|
- name: Ensure logs are readable before uploading
|
|
delegate_to: localhost
|
|
command: "chmod -R u=rwX,g=rX,o=rX {{ zuul.executor.log_root }}/"
|
|
# ANSIBLE0007 chmod used in place of argument mode to file
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Upload logs to log server
|
|
synchronize:
|
|
src: "{{ zuul.executor.log_root }}/"
|
|
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/"
|
|
owner: no
|
|
group: no
|
|
rsync_opts:
|
|
- "--exclude=job-output.txt"
|
|
- "--exclude=job-output.json"
|
|
no_log: "{{ not zuul_log_verbose }}"
|
|
|
|
# After this point there are no more logs
|
|
- name: gzip console log and json output
|
|
delegate_to: localhost
|
|
archive:
|
|
path: "{{ zuul.executor.log_root }}/{{ zj_log }}"
|
|
mode: 0644
|
|
with_items:
|
|
- job-output.txt
|
|
- job-output.json
|
|
loop_control:
|
|
loop_var: zj_log
|
|
when: zuul_log_compress | bool
|
|
|
|
- name: Upload compressed console log and json output
|
|
synchronize:
|
|
src: "{{ zuul.executor.log_root }}/{{ zj_log }}.gz"
|
|
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ zj_log }}.gz"
|
|
verify_host: true
|
|
owner: no
|
|
group: no
|
|
with_items:
|
|
- job-output.txt
|
|
- job-output.json
|
|
loop_control:
|
|
loop_var: zj_log
|
|
when: zuul_log_compress | bool
|
|
|
|
- name: Upload console log and json output
|
|
synchronize:
|
|
src: "{{ zuul.executor.log_root }}/{{ zj_log }}"
|
|
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ zj_log }}"
|
|
verify_host: true
|
|
owner: no
|
|
group: no
|
|
with_items:
|
|
- job-output.txt
|
|
- job-output.json
|
|
loop_control:
|
|
loop_var: zj_log
|
|
when: not zuul_log_compress | bool
|
|
|
|
- name: Return log URL to Zuul
|
|
delegate_to: localhost
|
|
zuul_return:
|
|
data:
|
|
zuul:
|
|
log_url: "{{ zuul_log_url }}/{{ zuul_log_path }}/"
|
|
when: zuul_log_url is defined
|