1
0
forked from infra/ansible
infra/roles/gogs/tasks/main.yml

45 lines
1.3 KiB
YAML

---
- name: Enable https for apt
apt: name=apt-transport-https
- name: Enable gogs apt-key
apt_key: url='https://deb.packager.io/key'
- name: Enable gogs repository
apt_repository: repo="deb https://dl.packager.io/srv/deb/pkgr/gogs/pkgr/debian 9 main"
- name: Install gogs
apt: name=gogs
- name: Install PostgreSQL
apt: name={{ item }}
with_items:
- postgresql
- python-psycopg2
- name: Configure PostgreSQL database
postgresql_db: name={{ gogs_dbname }}
become: true
become_user: postgres
- name: Configure PostgreSQL user
postgresql_user: db={{ gogs_dbname }} name={{ gogs_dbuser }} password={{ gogs_dbpass }} priv=ALL state=present
become: true
become_user: postgres
- name: Ensure certificates are available
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/{{ gogs_domain }}.key -out /etc/nginx/ssl/{{ gogs_domain }}.crt -days 730 -subj "/CN={{ gogs_domain }}" creates=/etc/nginx/ssl/{{ gogs_domain }}.crt
notify: Restart nginx
- name: Configure certificate manager for gogs
template: src=certs.j2 dest=/etc/acme/domains.d/{{ gogs_domain }}.conf
- name: Configure vhost
template: src=vhost.j2 dest=/etc/nginx/sites-available/gogs
notify: Restart nginx
- name: Enable vhost
file: src=/etc/nginx/sites-available/gogs dest=/etc/nginx/sites-enabled/gogs state=link
notify: Restart nginx