---
- name: "π PEERTUBE | Ensure the design directory exists"
ansible.builtin.file:
path: "{{ PEERTUBE_DESIGN_DIR }}"
state: directory
mode: "0755"
- name: "π PEERTUBE | Find the marks of the logos the role uploaded"
ansible.builtin.find:
paths: "{{ PEERTUBE_DESIGN_DIR }}"
patterns: "*.mark"
register: peertube_design_mark_files
- name: "π₯ PEERTUBE | Read the marks of the logos the role uploaded"
ansible.builtin.slurp:
src: "{{ [PEERTUBE_DESIGN_DIR, item.type ~ '.mark'] | path_join }}"
loop: "{{ PEERTUBE_DESIGN_LOGOS }}"
loop_control:
label: "{{ item.type }}"
when: ([PEERTUBE_DESIGN_DIR, item.type ~ '.mark'] | path_join) in (peertube_design_mark_files.files | map(attribute='path'))
register: peertube_design_marks
- name: "πΌοΈ PEERTUBE | Render the corporate logo set"
ansible.builtin.include_role:
name: sys-front-inj-design
tasks_from: assets.yml
vars:
design_assets_dest: "{{ PEERTUBE_DESIGN_DIR }}"
- name: "π PEERTUBE | Checksum the rendered logos"
ansible.builtin.stat:
path: "{{ [PEERTUBE_DESIGN_DIR, item.file] | path_join }}"
checksum_algorithm: sha256
loop: "{{ PEERTUBE_DESIGN_LOGOS }}"
loop_control:
label: "{{ item.type }}"
register: peertube_design_rendered
- name: "π€ PEERTUBE | Upload the corporate logos over fallback or own upload"
ansible.builtin.command:
argv:
- curl
- --silent
- --show-error
- --fail
- --request
- POST
- --header
- "@-"
- --header
- "Host: {{ PEERTUBE_HOSTNAME }}"
- --form
- "logofile=@{{ [PEERTUBE_DESIGN_DIR, item.0.file] | path_join }};type=image/png"
- "{{ PEERTUBE_INTERNAL_URL }}/api/v1/config/instance-logo/{{ item.0.type }}/pick"
stdin: "Authorization: Bearer {{ peertube_design_token.json.access_token }}"
vars:
_served: "{{ peertube_design_config.json.instance.logo | selectattr('type', 'equalto', item.0.type) | first }}"
_mark: "{{ [] if item.1 is skipped else (item.1.content | b64decode).split() }}"
loop: "{{ PEERTUBE_DESIGN_LOGOS | zip(peertube_design_marks.results, peertube_design_rendered.results) | list }}"
loop_control:
label: "{{ item.0.type }}"
when: >-
_served.isFallback
or (_mark | length == 2
and _mark[0] == (_served.fileUrl | urlsplit('path'))
and _mark[1] != item.2.stat.checksum)
register: peertube_design_uploads
changed_when: true
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
- name: "π PEERTUBE | Read the logo files PeerTube serves after the upload"
uri_retry:
url: "{{ PEERTUBE_INTERNAL_URL }}/api/v1/config"
headers:
Host: "{{ PEERTUBE_HOSTNAME }}"
return_content: true
when: peertube_design_uploads is changed
register: peertube_design_config_uploaded
- name: "π·οΈ PEERTUBE | Mark the logos the role uploaded"
ansible.builtin.copy:
dest: "{{ [PEERTUBE_DESIGN_DIR, item.0.type ~ '.mark'] | path_join }}"
content: "{{ (peertube_design_config_uploaded.json.instance.logo | selectattr('type', 'equalto', item.0.type) | first).fileUrl | urlsplit('path') }} {{ item.2.stat.checksum
}}\n"
mode: "0644"
loop: "{{ PEERTUBE_DESIGN_LOGOS | zip(peertube_design_uploads.results, peertube_design_rendered.results) | list }}"
loop_control:
label: "{{ item.0.type }}"
when: item.1 is changed