forked from infra/ansible
Add gogs role.
This commit is contained in:
parent
107136e1c6
commit
86df50da48
@ -2,6 +2,11 @@
|
||||
|
||||
certmgr_mode: webserver
|
||||
|
||||
gogs_domain: git.binary-kitchen.de
|
||||
gogs_dbname: gogs
|
||||
gogs_dbuser: gogs
|
||||
gogs_dbpass: UbRoiq4fuRL3MvxghPww
|
||||
|
||||
ldap_ca: /etc/ldap/ssl/BKCA.crt
|
||||
ldap_uri: ldaps://ldap.binary.kitchen/
|
||||
ldap_host: ldap.binary.kitchen
|
||||
|
4
roles/gogs/handlers/main.yml
Normal file
4
roles/gogs/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
- name: Restart nginx
|
||||
service: name=nginx state=restarted
|
5
roles/gogs/meta/main.yml
Normal file
5
roles/gogs/meta/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
dependencies:
|
||||
- { role: certmgr }
|
||||
- { role: nginx }
|
44
roles/gogs/tasks/main.yml
Normal file
44
roles/gogs/tasks/main.yml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
|
||||
- name: Enable https for apt
|
||||
apt: name=apt-transport-https state=present
|
||||
|
||||
- name: Enable gogs apt-key
|
||||
apt_key: url='https://deb.packager.io/key'
|
||||
|
||||
- name: Enable gogs repository
|
||||
apt_repository: repo='deb https://deb.packager.io/gh/pkgr/gogs jessie pkgr'
|
||||
|
||||
- name: Install gogs
|
||||
apt: name=gogs state=latest
|
||||
|
||||
- name: Install PostgreSQL
|
||||
apt: name={{ item }} state=present
|
||||
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
|
15
roles/gogs/templates/certs.j2
Normal file
15
roles/gogs/templates/certs.j2
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
|
||||
{{ gogs_domain }}:
|
||||
- path: /etc/nginx/ssl/{{ gogs_domain }}.key
|
||||
user: root
|
||||
group: root
|
||||
perm: '400'
|
||||
format: key
|
||||
action: 'service nginx restart'
|
||||
- path: /etc/nginx/ssl/{{ gogs_domain }}.crt
|
||||
user: root
|
||||
group: root
|
||||
perm: '400'
|
||||
format: crt,ca
|
||||
action: 'service nginx restart'
|
32
roles/gogs/templates/vhost.j2
Normal file
32
roles/gogs/templates/vhost.j2
Normal file
@ -0,0 +1,32 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {{ gogs_domain }};
|
||||
|
||||
location /.well-known/acme-challenge {
|
||||
default_type "text/plain";
|
||||
alias /var/www/acme-challenge;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://{{ gogs_domain }}$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
|
||||
server_name {{ gogs_domain }};
|
||||
|
||||
ssl_certificate_key /etc/nginx/ssl/{{ gogs_domain }}.key;
|
||||
ssl_certificate /etc/nginx/ssl/{{ gogs_domain }}.crt;
|
||||
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_pass http://localhost:3000;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
|
||||
dependencies:
|
||||
- { role: nginx }
|
||||
- { role: certmgr }
|
||||
- { role: nginx }
|
||||
|
@ -40,7 +40,7 @@
|
||||
copy: src=www.conf dest=/etc/php5/fpm/pool.d/www.conf
|
||||
notify: Restart php5-fpm
|
||||
|
||||
- name: Enable vhosts
|
||||
- name: Enable vhost
|
||||
file: src=/etc/nginx/sites-available/owncloud dest=/etc/nginx/sites-enabled/owncloud state=link
|
||||
notify: Restart nginx
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user