1
0
mirror of https://yerbamate.ml/nutomic/peertube.social synced 2024-11-28 17:58:20 -05:00
peertube.social/peertube.yml

80 lines
2.7 KiB
YAML
Raw Normal View History

2019-04-10 15:43:16 -04:00
---
- hosts: all
# Install python if required
# https://www.josharcher.uk/code/ansible-python-connection-failure-ubuntu-server-1604/
gather_facts: False
pre_tasks:
- name: install python for Ansible
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-setuptools)
2019-07-02 15:53:41 -04:00
args:
executable: /bin/bash
2019-04-10 15:43:16 -04:00
register: output
changed_when: output.stdout != ""
- setup: # gather facts
tasks:
- name: install dependencies
apt:
pkg: ['docker-compose', 'docker.io', 'certbot']
2019-04-10 15:43:16 -04:00
2020-04-01 12:37:31 -04:00
- name: copy docker config
copy: src='files/docker-daemon.json' dest='/etc/docker/daemon.json' mode='0644'
2019-04-10 15:43:16 -04:00
- name: create peertube folder
file: path={{item.path}} state=directory
with_items:
- { path: '/peertube/volumes/' }
- { path: '/peertube/volumes/certbot/' }
2019-04-10 15:43:16 -04:00
2020-04-01 12:37:31 -04:00
- name: get latest peertube version from github
uri:
url: https://api.github.com/repos/Chocobozzz/PeerTube/releases/latest
return_content: true
register: peertube_version_response
check_mode: no
- debug:
msg: "Using Peertube version {{ peertube_version_response.json.tag_name }}"
- name: check to make sure the specified tag exists
docker_image:
name: "chocobozzz/peertube:{{ peertube_version_response.json.tag_name }}-buster"
source: pull
2019-04-10 15:43:16 -04:00
- name: add all template files
2020-04-01 12:37:31 -04:00
template: src={{item.src}} dest={{item.dest}} mode={{item.mode}}
2019-04-10 15:43:16 -04:00
with_items:
2020-04-01 12:37:31 -04:00
- { src: 'templates/docker-compose.yml.j2', dest: '/peertube/docker-compose.yml', mode: '0644' }
- { src: 'templates/nginx.conf.j2', dest: '/peertube/nginx.conf', mode: '0644' }
- { src: 'templates/env.j2', dest: '/peertube/.env', mode: '0600' }
- { src: 'templates/peertube-production.yaml.j2', dest: '/peertube/volumes/config/production.yaml', mode: '0600' }
2019-04-10 15:43:16 -04:00
vars:
2020-04-01 12:37:31 -04:00
peertube_version: "{{ peertube_version_response.json.tag_name }}"
- name: request letsencrypt certificates
command: certbot certonly --standalone --agree-tos -d '{{ domain }}' -m '{{ letsencrypt_contact_email }}'
args:
creates: '/etc/letsencrypt/live/{{domain}}/privkey.pem'
2019-04-10 15:43:16 -04:00
- name: enable and start docker service
systemd:
name: docker
enabled: yes
state: started
- name: start docker-compose
docker_compose:
2019-04-10 15:43:16 -04:00
project_src: /peertube/
state: present
pull: yes
2020-04-01 12:37:31 -04:00
# TODO: might need to restart peertube if production.yaml was changed
- name: renew certbot certificates
cron:
special_time=daily
name=certbot-renew
user=root
job="certbot certonly --webroot --webroot-path=/peertube/volumes/certbot/ -d '{{ domain }}' --deploy-hook 'docker-compose -f /peertube/docker-compose.yml exec nginx nginx -s reload'"