yerbamate-ml/playbooks/gitea.yml

83 lines
3.1 KiB
YAML
Raw Permalink Normal View History

2020-02-10 18:52:12 +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)
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/postgres/', owner: '70' }
2020-02-10 18:52:12 +00:00
- name: add all templates
template: src={{item.src}} dest={{item.dest}} mode={{item.mode}}
with_items:
2020-10-05 13:41:43 +00:00
- { src: '../templates/gitea.conf', dest: '/etc/nginx/sites-enabled/gitea.conf', mode: '0600' }
- { src: '../templates/weblate.conf', dest: '/etc/nginx/sites-enabled/weblate.conf', mode: '0600' }
- { src: '../templates/env', dest: '/gitea/.env', mode: '0600' }
2020-02-10 18:52:12 +00:00
- name: copy all files
copy: src={{item.src}} dest={{item.dest}} mode={{item.mode}}
with_items:
2020-10-05 13:41:43 +00:00
- { src: '../files/docker-compose.yml', dest: '/gitea/docker-compose.yml', mode: '0755' }
- { src: '../files/influxdb.conf', dest: '/gitea/influxdb.conf', mode: '0755' }
2020-02-10 18:52:12 +00:00
- name: install dependencies
apt:
2022-03-01 21:51:56 +00:00
pkg: ['docker-compose', 'docker.io', 'certbot', 'nginx', 'python3-certbot-nginx', 'python-passlib']
2020-02-10 18:52:12 +00:00
- name: enable and start docker service
systemd:
name: docker
enabled: yes
state: started
- name: start docker-compose
docker_compose:
project_src: /gitea/
state: present
pull: yes
2020-02-10 18:52:12 +00:00
- 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
2021-09-28 12:19:06 +00:00
certbot certonly --nginx --agree-tos -d 'drone.{{ domain }}' -m '{{ letsencrypt_contact_email }}' -n
2020-02-10 18:52:12 +00:00
- 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'"
2021-09-28 12:19:06 +00:00
- name: renew drone certificates
cron:
special_time=daily
name=certbot-renew-drone
user=root
job="certbot certonly --nginx -d drone.{{ domain }} -n --deploy-hook 'nginx -s reload'"