zuul-jobs/test-playbooks/upload-logs-s3.yaml
Artem Goncharov e7d7575eaf Fix zuul-jobs-test-upload-logs-s3 job
Since the security update we are not able to modify
zuul.executor.log_root variable in the role testing.
Replace this with explicit log folder creation on the test node.

Change-Id: Ie6cff6f9e9c5594167ddda6cd345f9c3d9f2f470
2021-11-16 16:20:33 +00:00

68 lines
1.9 KiB
YAML

- hosts: all
vars:
zuul_log_aws_access_key: minioadmin
zuul_log_aws_secret_key: minioadmin
zuul_log_bucket: zuul
test_content: "123abc"
_undocumented_test_worker_node_: "{{ inventory_hostname }}"
roles:
- ensure-docker
- ensure-pip
tasks:
- name: Install boto
pip:
name:
- boto3
- botocore
- name: Start minio server
command: >-
docker run -d -p 9000:9000
-e MINIO_ACCESS_KEY={{ zuul_log_aws_access_key }}
-e MINIO_SECRET_KEY={{ zuul_log_aws_secret_key }}
minio/minio server /data
- name: Make sure bucket exists
s3_bucket:
name: "{{ zuul_log_bucket }}"
state: present
s3_url: 'http://localhost:9000'
aws_access_key: "{{ zuul_log_aws_access_key }}"
aws_secret_key: "{{ zuul_log_aws_secret_key }}"
- name: Create Logdir
become: true
file:
state: directory
path: "{{ zuul.executor.log_root }}"
mode: "0755"
group: "zuul"
owner: "zuul"
register: fake_zuul_logdir
- name: Add content to tempfile
copy:
content: "{{ test_content }}"
dest: "{{ fake_zuul_logdir.path }}/testfile"
- name: Upload file to s3
include_role:
name: upload-logs-s3
vars:
upload_logs_s3_endpoint: 'http://localhost:9000'
- name: Download mc
get_url:
url: https://dl.min.io/client/mc/release/linux-amd64/mc
dest: "{{ fake_zuul_logdir.path }}/mc"
mode: 0755
- name: Add localhost minio host
command: "{{ fake_zuul_logdir.path }}/mc config host add local http://localhost:9000 {{ zuul_log_aws_access_key }} {{ zuul_log_aws_secret_key }}"
- name: List files in minio bucket
command: "{{ fake_zuul_logdir.path }}/mc find local/zuul"
- name: Check for testfile in minio bucket
command: "{{ fake_zuul_logdir.path }}/mc find local/zuul/{{ zuul_log_path }}/testfile"