You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB
YAML

- name: Check if peertube deployment is present
ansible.builtin.stat:
path: "{{ item }}"
loop:
- "{{ peertube_install_dir }}/compose.yaml"
- "{{ peertube_install_dir }}/env"
register: peertube_files
- name: "docker compose down"
community.docker.docker_compose_v2:
state: "absent"
project_src: "{{ peertube_install_dir }}"
when: peertube_files.results | map(attribute='stat.exists') | select('equalto', false) | list | length == 0
- name: "Create the peertube directory"
file:
path: "{{ peertube_install_dir }}"
state: "directory"
- name: Normalize peertube version (strip leading 'v' if present)
ansible.builtin.set_fact:
peertube_version: "{{ peertube_version | regex_replace('^v', '') }}"
- name: Query Docker Hub for peertube tags
ansible.builtin.uri:
url: "https://hub.docker.com/v2/namespaces/chocobozzz/repositories/peertube/tags?page_size=100"
return_content: true
register: peertube_tags_page
# If the repository has more than 100 tags, follow pagination until
# either a match is found or there are no more pages.
- name: Search for matching version tag (handling pagination)
ansible.builtin.set_fact:
peertube_image_tag: >-
{{
(
peertube_tags_page.json.results
| map(attribute='name')
| select('match', '^v?' ~ peertube_version ~ '-')
| list
| first
)
if (
peertube_tags_page.json.results
| map(attribute='name')
| select('match', '^v?' ~ peertube_version ~ '-')
| list
| length > 0
)
else (
(lookup('ansible.builtin.url', peertube_tags_page.json.next, wantlist=False) | from_json).results
| map(attribute='name')
| select('match', '^v?' ~ peertube_version ~ '-')
| list
| first
)
if peertube_tags_page.json.next is not none
else ''
}}
- name: Fail if no matching tag was found
ansible.builtin.fail:
msg: "No Docker tag found for PeerTube version {{ peertube_version }}"
when: peertube_image_tag | length == 0
- name: Set the full image name
ansible.builtin.set_fact:
peertube_image: "chocobozzz/peertube:{{ peertube_image_tag }}"
- name: Create docker-compose.yml file for Peertube
template:
src: docker-compose.yml.j2
dest: "{{ peertube_install_dir }}/docker-compose.yml"
- name: Create .env file for Peertube
template:
src: "env.j2"
dest: "{{ peertube_install_dir }}/env"
- name: "docker compose up -d peertube"
community.docker.docker_compose_v2:
state: "present"
pull: policy
project_src: "{{ peertube_install_dir }}"
- ansible.builtin.lineinfile:
path: "/backup-dirs"
line: "{{ item }}"
loop:
- "{{ peertube_install_dir }}"
- "{{ peertube_files_dir }}"
- "{{ peertube_config_dir }}"
- "{{ peertube_db_dir }}"
- "{{ peertube_redis_dir }}"
- ansible.builtin.lineinfile:
path: "/backup-dirs-exclude"
line: "{{ item }}"
loop:
- "{{ peertube_files_dir }}/bin"
- "{{ peertube_files_dir }}/.pnpm-store"
- "{{ peertube_files_dir }}/tmp"