Add owncloud role.

This commit is contained in:
Markus 2016-04-05 08:44:23 +02:00
parent 69b704dac3
commit 6e954168db
7 changed files with 120 additions and 0 deletions

View File

@ -21,6 +21,11 @@ ntp_servers:
- 172.23.1.61
- 172.23.2.2
owncloud_domain: oc.binary-kitchen.de
owncloud_dbname: owncloud
owncloud_dbuser: owncloud
owncloud_dbpass: tnEykTqtsC9pECz7wAUJ
prosody_admin: moepman@jabber.binary-kitchen.de
prosody_domain: jabber.binary-kitchen.de

View File

@ -0,0 +1,7 @@
---
- name: Restart nginx
service: name=nginx state=restarted
- name: Restart php5-fpm
service: name=php5-fpm state=restarted

View File

@ -0,0 +1,5 @@
---
dependencies:
- { role: certmgr }
- { role: nginx }

View File

@ -0,0 +1,45 @@
---
- name: Install packages
apt: name={{ item }} state=present
with_items:
- php5-curl
- php5-fpm
- php5-gd
- php5-pgsql
- postgresql
- python-psycopg2
- name: Configure PostgreSQL database
postgresql_db: name={{ owncloud_dbname }} owner={{ owncloud_dbuser }}
become: true
become_user: postgres
- name: Configure PostgreSQL user
postgresql_user: db={{ owncloud_dbname }} name={{ owncloud_dbuser }} password={{ owncloud_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/{{ owncloud_domain }}.key -out /etc/nginx/ssl/{{ owncloud_domain }}.crt -days 730 -subj "/CN={{ owncloud_domain }}" creates=/etc/nginx/ssl/{{ owncloud_domain }}.crt
notify: Restart nginx
- name: Configure certificate manager for owncloud
template: src=certs.j2 dest=/etc/acme/domains.d/{{ owncloud_domain }}.conf
- name: Create vhost directory
file: path=/var/www/owncloud state=directory owner=www-data group=www-data
- name: Configure vhost
template: src=vhost.j2 dest=/etc/nginx/sites-available/owncloud
notify: Restart nginx
- name: Enable vhosts
file: src=/etc/nginx/sites-available/owncloud dest=/etc/nginx/sites-enabled/owncloud state=link
notify: Restart nginx
- name: Start php5-fpm
service: name=php5-fpm state=started enabled=yes
- name: Start PostgreSQL
service: name=postgresql state=started enabled=yes

View File

@ -0,0 +1,15 @@
---
{{ owncloud_domain }}:
- path: /etc/nginx/ssl/{{ owncloud_domain }}.crt
user: root
group: root
perm: '400'
format: crt
notify: 'service nginx restart'
- path: /etc/nginx/ssl/{{ owncloud_domain }}.key
user: root
group: root
perm: '400'
format: key
notify: 'service nginx restart'

View File

@ -0,0 +1,38 @@
server {
listen 80;
listen [::]:80;
server_name {{ owncloud_domain }};
location /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/acme-challenge/;
}
location / {
return 301 https://{{ owncloud_domain }}$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name {{ owncloud_domain }};
ssl_certificate_key /etc/nginx/ssl/{{ owncloud_domain }}.key;
ssl_certificate /etc/nginx/ssl/{{ owncloud_domain }}.crt;
root /var/www/owncloud/;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}

View File

@ -21,6 +21,11 @@
roles:
- prosody
- name: Setup owncloud server
hosts: nitrogen.binary-kitchen.net
roles:
- owncloud
- name: Setup member server
hosts: oxygen.binary-kitchen.net
roles: