]> Untitled Git - lemmy.git/blob - ansible/lemmy.yml
Spanish translations
[lemmy.git] / ansible / lemmy.yml
1 ---
2 - hosts: all
3
4   # Install python if required
5   # https://www.josharcher.uk/code/ansible-python-connection-failure-ubuntu-server-1604/
6   gather_facts: False
7   pre_tasks:
8     - name: install python for Ansible
9       raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-setuptools)
10       args:
11         executable: /bin/bash
12       register: output
13       changed_when: output.stdout != ""
14     - setup: # gather facts
15
16   tasks:
17   - name: install dependencies
18     apt:
19       pkg: ['nginx', 'docker-compose', 'docker.io', 'certbot', 'python-certbot-nginx']
20
21   - name: request initial letsencrypt certificate
22     command: certbot certonly --nginx --agree-tos -d '{{ domain }}' -m '{{ letsencrypt_contact_email }}'
23     args:
24       creates: '/etc/letsencrypt/live/{{domain}}/privkey.pem'
25
26   - name: create lemmy folder
27     file: path={{item.path}} state=directory
28     with_items:
29       - { path: '/lemmy/' }
30       - { path: '/lemmy/volumes/' }
31
32   - name:  add all template files
33     template: src={{item.src}} dest={{item.dest}}
34     with_items:
35       - { src: 'templates/env', dest: '/lemmy/.env' }
36       - { src: '../docker/prod/docker-compose.yml', dest: '/lemmy/docker-compose.yml' }
37       - { src: 'templates/nginx.conf', dest: '/etc/nginx/sites-enabled/lemmy.conf' }
38     vars:
39       postgres_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/postgres chars=ascii_letters,digits') }}"
40       jwt_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/jwt chars=ascii_letters,digits') }}"
41
42   - name: set env file permissions
43     file:
44       path: "/lemmy/.env"
45       state: touch
46       mode: 0600
47       access_time: preserve
48       modification_time: preserve
49
50   - name: enable and start docker service
51     systemd:
52       name: docker
53       enabled: yes
54       state: started
55
56   - name: start docker-compose
57     docker_compose:
58       project_src: /lemmy/
59       state: present
60       pull: yes
61
62   - name: reload nginx with new config
63     shell: nginx -s reload
64
65   - name: certbot renewal cronjob
66     cron:
67       special_time=daily
68       name=certbot-renew-lemmy
69       user=root
70       job="certbot certonly --nginx -d '{{ domain }}' --deploy-hook 'docker-compose -f /peertube/docker-compose.yml exec nginx nginx -s reload'"