peertube.social/peertube.yml

84 lines
2.9 KiB
YAML
Raw Normal View History

2019-04-10 19:43:16 +00: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 19:53:41 +00:00
args:
executable: /bin/bash
2019-04-10 19:43:16 +00:00
register: output
changed_when: output.stdout != ""
- setup: # gather facts
tasks:
- name: install dependencies
apt:
pkg: ['docker-compose', 'docker.io', 'certbot']
2019-04-10 19:43:16 +00:00
- name: create peertube folders
file: path={{item.path}} state=directory
with_items:
- { path: '/peertube/volumes/' }
- { path: '/peertube/volumes/certbot/' }
- { path: '/peertube/volumes/config/' }
- name: copy docker config
copy: src={{item.src}} dest={{item.dest}} mode='0644'
with_items:
- { src: 'files/docker-daemon.json', dest: '/etc/docker/daemon.json' }
- { src: 'files/local-production.json', dest: '/peertube/volumes/config/local-production.json' }
2019-04-10 19:43:16 +00:00
2020-04-01 16:37:31 +00: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 19:43:16 +00:00
- name: add all template files
2020-04-01 16:37:31 +00:00
template: src={{item.src}} dest={{item.dest}} mode={{item.mode}}
2019-04-10 19:43:16 +00:00
with_items:
2020-04-01 16:37:31 +00: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 19:43:16 +00:00
vars:
2020-04-01 16:37:31 +00: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 19:43:16 +00:00
- name: enable and start docker service
systemd:
name: docker
enabled: yes
state: started
- name: start docker-compose
docker_compose:
2019-04-10 19:43:16 +00:00
project_src: /peertube/
state: present
pull: yes
2020-04-01 16:37:31 +00: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'"