forked from infra/ansible
Add owncloud role.
This commit is contained in:
parent
69b704dac3
commit
6e954168db
@ -21,6 +21,11 @@ ntp_servers:
|
|||||||
- 172.23.1.61
|
- 172.23.1.61
|
||||||
- 172.23.2.2
|
- 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_admin: moepman@jabber.binary-kitchen.de
|
||||||
prosody_domain: jabber.binary-kitchen.de
|
prosody_domain: jabber.binary-kitchen.de
|
||||||
|
|
||||||
|
7
roles/owncloud/handlers/main.yml
Normal file
7
roles/owncloud/handlers/main.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Restart nginx
|
||||||
|
service: name=nginx state=restarted
|
||||||
|
|
||||||
|
- name: Restart php5-fpm
|
||||||
|
service: name=php5-fpm state=restarted
|
5
roles/owncloud/meta/main.yml
Normal file
5
roles/owncloud/meta/main.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- { role: certmgr }
|
||||||
|
- { role: nginx }
|
45
roles/owncloud/tasks/main.yml
Normal file
45
roles/owncloud/tasks/main.yml
Normal 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
|
15
roles/owncloud/templates/certs.j2
Normal file
15
roles/owncloud/templates/certs.j2
Normal 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'
|
38
roles/owncloud/templates/vhost.j2
Normal file
38
roles/owncloud/templates/vhost.j2
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user