blob: a652e5582dbb615d5258049d940ec84da1ffdb5b [file] [log] [blame]
Adrià Vilanova Martínez0643f4f2024-07-13 12:27:28 +02001- name: Set zuul-log-path fact
2 include_role:
3 name: set-zuul-log-path-fact
4
5# Always upload (true), never upload (false) or only on failure ('failure')
6- name: Upload logs
7 when: zuul_site_upload_logs | default(true) | bool or
8 (zuul_site_upload_logs == 'failure' and not zuul_success | bool)
9 block:
10
11 - name: Create log directories
12 file:
13 path: "{{ zuul_logserver_root }}/{{ zuul_log_path }}"
14 state: directory
15 recurse: yes
16 mode: 0775
17
18 # Use chmod instead of file because ansible 2.5 file with recurse and
19 # follow can't really handle symlinks to .
20 - name: Ensure logs are readable before uploading
21 delegate_to: localhost
22 command: "chmod -R u=rwX,g=rX,o=rX {{ zuul.executor.log_root }}/"
23 # ANSIBLE0007 chmod used in place of argument mode to file
24 tags:
25 - skip_ansible_lint
26
27 - name: Upload logs to log server
28 synchronize:
29 src: "{{ zuul.executor.log_root }}/"
30 dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/"
31 owner: no
32 group: no
33 rsync_opts:
34 - "--exclude=job-output.txt"
35 - "--exclude=job-output.json"
36 no_log: "{{ not zuul_log_verbose }}"
37
38 # After this point there are no more logs
39 - name: Compress console log and json output
40 delegate_to: localhost
41 archive:
42 path: "{{ zuul.executor.log_root }}/{{ zj_log }}"
43 mode: 0644
44 with_items:
45 - job-output.txt
46 - job-output.json
47 loop_control:
48 loop_var: zj_log
49 when: zuul_log_compress | bool
50
51 - name: Upload compressed console log and json output
52 synchronize:
53 src: "{{ zuul.executor.log_root }}/{{ zj_log }}.gz"
54 dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ zj_log }}.gz"
55 verify_host: true
56 owner: no
57 group: no
58 with_items:
59 - job-output.txt
60 - job-output.json
61 loop_control:
62 loop_var: zj_log
63 when: zuul_log_compress | bool
64
65 - name: Upload console log and json output
66 synchronize:
67 src: "{{ zuul.executor.log_root }}/{{ zj_log }}"
68 dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ zj_log }}"
69 verify_host: true
70 owner: no
71 group: no
72 with_items:
73 - job-output.txt
74 - job-output.json
75 loop_control:
76 loop_var: zj_log
77 when: not zuul_log_compress | bool
78
79- name: Return log URL to Zuul
80 delegate_to: localhost
81 zuul_return:
82 data:
83 zuul:
84 log_url: "{{ zuul_log_url }}/{{ zuul_log_path }}/"
85 when: zuul_log_url is defined