ansible/roles/gogs/tasks/main.yml

46 lines
1.4 KiB
YAML

---
- name: Enable https for apt
apt: name=apt-transport-https
- name: Enable gogs apt-key
apt_key: url="https://dl.packager.io/srv/pkgr/gogs/key"
- name: Enable gogs repository
apt_repository: repo="deb https://dl.packager.io/srv/deb/gogs/gogs/master/debian 10 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/acertmgr/{{ gogs_domain }}.conf
notify: Run acertmgr
- 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