project-config/roles/test-upload-logs/tasks/main.yaml
Clark Boylan 2db422f0b8 Run ansible-lint on Ubuntu Noble
We ran into issues getting ansible-lint to run on Noble without updating
everything to current ish versions due to Python 3.12 compatibility
issues. Updating everything in this way created a bunch of new lint
errors we need to fix so we worked around the problem previously by
pinning back to Jammy.

Now we move the job back to Noble (the default Nodeset) and update the
tooling and fix the linter errors. This should allow us to move forward
in a productive manner on modern platforms.

The linter errors we fix include:

 * Naming every play
 * Ensuring every play name starts with a capital letter
 * Using fully qualified collection names for action modules
   (archive, git_config, and synchronize)
 * Quoting octal file modes

Change-Id: I96560c5ce2a5af39d39b3fc339862932a856bd13
2024-08-21 12:55:46 -07:00

61 lines
1.9 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
ansible.posix.synchronize:
src: "{{ zuul.executor.log_root }}/"
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/"
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
community.general.archive:
path: "{{ zuul.executor.log_root }}/{{ item }}"
with_items:
- job-output.txt
- job-output.json
- name: Upload console log and json output
ansible.posix.synchronize:
src: "{{ zuul.executor.log_root }}/{{ item }}.gz"
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ item }}.gz"
verify_host: true
with_items:
- job-output.txt
- job-output.json
- 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