yerbamate-ml/gitea.yml

94 lines
3.7 KiB
YAML
Raw Normal View History

2020-02-10 18:52:12 +00:00
---
- hosts: all
become: yes
# 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)
args:
executable: /bin/bash
register: output
changed_when: output.stdout != ""
- setup: # gather facts
tasks:
- name: create app folder
2020-06-28 12:19:29 +00:00
file: path={{item.path}} state=directory owner={{item.owner}} group={{item.owner}}
2020-02-10 18:52:12 +00:00
with_items:
2020-06-28 12:19:29 +00:00
- { path: '/gitea/', owner: 'root' }
- { path: '/gitea/volumes/', owner: 'root' }
- { path: '/gitea/volumes/gitea/', owner: 'root' }
- { path: '/gitea/volumes/redis/', owner: 'root' }
- { path: '/gitea/volumes/weblate/', owner: '1000' }
- { path: '/gitea/volumes/grafana/', owner: '472' }
- { path: '/gitea/volumes/postgres/', owner: '70' }
2020-06-29 17:05:22 +00:00
- { path: '/gitea/volumes/influxdb/', owner: 'root' }
2020-02-10 18:52:12 +00:00
- name: add all templates
template: src={{item.src}} dest={{item.dest}} mode={{item.mode}}
with_items:
- { src: 'templates/gitea.conf', dest: '/etc/nginx/sites-enabled/gitea.conf', mode: '0600' }
2020-02-29 19:42:45 +00:00
- { src: 'templates/weblate.conf', dest: '/etc/nginx/sites-enabled/weblate.conf', mode: '0600' }
2020-06-28 12:19:29 +00:00
- { src: 'templates/grafana.conf', dest: '/etc/nginx/sites-enabled/grafana.conf', mode: '0600' }
2020-02-10 18:52:12 +00:00
- { src: 'templates/env', dest: '/gitea/.env', mode: '0600' }
2020-02-29 19:42:45 +00:00
vars:
weblate_admin_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/weblate_admin_password chars=ascii_letters,digits') }}"
weblate_postgres_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/weblate_postgres_password chars=ascii_letters,digits') }}"
2020-06-29 17:05:22 +00:00
influxdb_password: "{{ lookup('password', 'passwords/{{ inventory_hostname }}/influxdb_password chars=ascii_letters,digits') }}"
2020-02-10 18:52:12 +00:00
- name: copy all files
copy: src={{item.src}} dest={{item.dest}} mode={{item.mode}}
with_items:
- { src: 'files/docker-compose.yml', dest: '/gitea/docker-compose.yml', mode: '0755' }
2020-06-29 17:05:22 +00:00
- { src: 'files/influxdb.conf', dest: '/gitea/influxdb.conf', mode: '0755' }
2020-02-10 18:52:12 +00:00
- name: install dependencies
apt:
pkg: ['docker-compose', 'docker.io', 'certbot', 'nginx', 'python-certbot-nginx']
- name: enable and start docker service
systemd:
name: docker
enabled: yes
state: started
- name: start docker-compose
docker_compose:
project_src: /gitea/
state: present
stopped: yes
services: nginx
- name: request letsencrypt certificates
2020-02-29 19:42:45 +00:00
shell: |
certbot certonly --nginx --agree-tos -d '{{ domain }}' -m '{{ letsencrypt_contact_email }}' -n
certbot certonly --nginx --agree-tos -d 'weblate.{{ domain }}' -m '{{ letsencrypt_contact_email }}' -n
2020-06-28 12:19:29 +00:00
certbot certonly --nginx --agree-tos -d 'grafana.{{ domain }}' -m '{{ letsencrypt_contact_email }}' -n
2020-02-10 18:52:12 +00:00
- name: start docker-compose
docker_compose:
project_src: /gitea/
state: present
pull: yes
- name: reload nginx config and certs
shell: nginx -s reload
- name: renew gitea certificates
cron:
special_time=daily
name=certbot-renew-gitea
user=root
2020-03-18 12:46:18 +00:00
job="certbot certonly --nginx -d {{ domain }} -n --deploy-hook 'nginx -s reload'"
2020-02-10 18:52:12 +00:00
2020-02-29 19:42:45 +00:00
- name: renew weblate certificates
cron:
special_time=daily
2020-06-19 19:58:08 +00:00
name=certbot-renew-weblate
2020-02-29 19:42:45 +00:00
user=root
2020-03-18 12:46:18 +00:00
job="certbot certonly --nginx -d weblate.{{ domain }} -n --deploy-hook 'nginx -s reload'"
2020-02-29 19:42:45 +00:00