Git initial commit
This commit is contained in:
commit
ef61def8c9
9
LICENSE
Executable file
9
LICENSE
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) <year> <copyright holders>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
3
README.md
Executable file
3
README.md
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
# cloud-nextcloud
|
||||||
|
|
||||||
|
Ansible role to provide nextcloud
|
||||||
31
defaults/main.yml
Executable file
31
defaults/main.yml
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
cloud_apps: /opt
|
||||||
|
cloud_storage: /opt/storage
|
||||||
|
cloud_stage: prod
|
||||||
|
cloud_update: false
|
||||||
|
|
||||||
|
nextcloud_version: 27.0.2
|
||||||
|
|
||||||
|
www_group: www-data
|
||||||
|
|
||||||
|
ncloud_db:
|
||||||
|
type: pgsql
|
||||||
|
name: ncloud_db
|
||||||
|
user: ncloud_dbu
|
||||||
|
pass: ncloud_dbpw
|
||||||
|
host: localhost
|
||||||
|
|
||||||
|
ncloud_admin_user: "nc-admin"
|
||||||
|
ncloud_admin_pass: "nc-password"
|
||||||
|
ncloud_data_location: "{{ cloud_storage }}/nextcloud"
|
||||||
|
ncloud_npush_port: 7867
|
||||||
|
|
||||||
|
ncloud_domain:
|
||||||
|
- my_domain.tld
|
||||||
|
ncloud_config:
|
||||||
|
- key: default_phone_region
|
||||||
|
value: "'DE'"
|
||||||
|
|
||||||
|
|
||||||
|
redis_port: 6379
|
||||||
|
redis_remote_url: ""
|
||||||
18
handlers/main.yml
Executable file
18
handlers/main.yml
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
- name: restart redis
|
||||||
|
systemd:
|
||||||
|
name: redis
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
- name: setup notify_push
|
||||||
|
command:
|
||||||
|
chdir: "{{ ncloud_dir }}"
|
||||||
|
cmd: "php occ notify_push:setup https://{{ ncloud_domain[0] }}/push"
|
||||||
|
become: yes
|
||||||
|
become_user: "{{ www_group }}"
|
||||||
|
|
||||||
|
- name: restart notify_push
|
||||||
|
systemd:
|
||||||
|
name: notify_push
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: yes
|
||||||
17
meta/main.yml
Executable file
17
meta/main.yml
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
role_name: nextcloud
|
||||||
|
namespace: hahn-cloud
|
||||||
|
author: Lars Hahn
|
||||||
|
company: OpenDevChain
|
||||||
|
license: MIT
|
||||||
|
description: Role to setup nextcloud; shoudld be used in combination with an DB-, HTTP-Server and letsencrypt.
|
||||||
|
min_ansible_version: 2.7
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- 11
|
||||||
|
galaxy_tags:
|
||||||
|
- nextcloud
|
||||||
|
dependencies:
|
||||||
|
- php
|
||||||
44
tasks/file_hpb.yml
Executable file
44
tasks/file_hpb.yml
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
- name: install notify_push
|
||||||
|
command:
|
||||||
|
chdir: "{{ ncloud_dir }}"
|
||||||
|
creates: "{{ ncloud_dir }}/apps/notify_push"
|
||||||
|
cmd: php occ app:install notify_push
|
||||||
|
become: yes
|
||||||
|
become_user: "{{ www_group }}"
|
||||||
|
notify: setup notify_push
|
||||||
|
register: notify_push
|
||||||
|
|
||||||
|
- name: enable notify_push
|
||||||
|
command:
|
||||||
|
chdir: "{{ ncloud_dir }}"
|
||||||
|
creates: "{{ ncloud_dir }}/apps/notify_push"
|
||||||
|
cmd: php occ app:enable notify_push
|
||||||
|
become: yes
|
||||||
|
become_user: "{{ www_group }}"
|
||||||
|
when: notify_push.changed
|
||||||
|
|
||||||
|
- name: configure trusted proxies
|
||||||
|
blockinfile:
|
||||||
|
marker: "// {mark} ANSIBLE MANAGED BLOCK"
|
||||||
|
path: "{{ ncloud_dir }}/config/config.php"
|
||||||
|
block: |
|
||||||
|
'trusted_proxies' =>
|
||||||
|
array (
|
||||||
|
{% for proxy in ncloud_notify_trusted_proxies %}
|
||||||
|
{{ loop.index - 1}} => '{{ proxy }}',
|
||||||
|
{% endfor %}
|
||||||
|
),
|
||||||
|
insertbefore: "\\);"
|
||||||
|
|
||||||
|
- name: setup notify_push systemd unit
|
||||||
|
template:
|
||||||
|
src: etc/systemd/system/notify_push.service.j2
|
||||||
|
dest: /etc/systemd/system/notify_push.service
|
||||||
|
|
||||||
|
- name: enable notify_push systemd unit
|
||||||
|
systemd:
|
||||||
|
name: notify_push
|
||||||
|
enabled: yes
|
||||||
|
daemon_reload: yes
|
||||||
|
state: started
|
||||||
44
tasks/main.yml
Executable file
44
tasks/main.yml
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
- name: setup nextcloud group
|
||||||
|
group:
|
||||||
|
name: "{{ ncgrp }}"
|
||||||
|
state: "present"
|
||||||
|
|
||||||
|
- name: setup nextcloud user
|
||||||
|
user:
|
||||||
|
name: "{{ ncusr }}"
|
||||||
|
group: "{{ ncgrp }}"
|
||||||
|
groups:
|
||||||
|
- "{{ ncgrp }}"
|
||||||
|
comment: Virtual Nextcloud User
|
||||||
|
shell: /sbin/nologin
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: setup nextcloud storage folder
|
||||||
|
file:
|
||||||
|
path: "{{ ncloud_data_location }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ www_group }}"
|
||||||
|
group: "{{ ncgrp }}"
|
||||||
|
mode: "o="
|
||||||
|
|
||||||
|
|
||||||
|
- name: install nextcloud recommendations
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
state: "{% if cloud_update | bool %}latest{% else %}present{% endif %}"
|
||||||
|
install_recommends: yes
|
||||||
|
pkg:
|
||||||
|
- "libxml2"
|
||||||
|
- "openssl"
|
||||||
|
- "ffmpeg"
|
||||||
|
- "libreoffice"
|
||||||
|
- "redis-server"
|
||||||
|
- "unzip"
|
||||||
|
|
||||||
|
- name: install basic nextcloud
|
||||||
|
include_tasks: nextcloud.yml
|
||||||
|
|
||||||
|
- name: install notify_push (file high-performance-backend)
|
||||||
|
include_tasks: file_hpb.yml
|
||||||
|
|
||||||
112
tasks/nextcloud.yml
Executable file
112
tasks/nextcloud.yml
Executable file
@ -0,0 +1,112 @@
|
|||||||
|
---
|
||||||
|
- name: download nextcloud and unarchive
|
||||||
|
unarchive:
|
||||||
|
src: "https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.zip"
|
||||||
|
dest: "{{ cloud_apps }}"
|
||||||
|
remote_src: yes
|
||||||
|
owner: "{{ www_group }}"
|
||||||
|
group: "{{ ncgrp }}"
|
||||||
|
mode: "o="
|
||||||
|
creates: "{{ ncloud_dir }}"
|
||||||
|
|
||||||
|
- name: install nextcloud
|
||||||
|
command:
|
||||||
|
chdir: "{{ ncloud_dir }}"
|
||||||
|
creates: "{{ ncloud_data_location }}/index.html"
|
||||||
|
cmd: >
|
||||||
|
php occ maintenance:install
|
||||||
|
--database '{{ ncloud_db_mapping[ncloud_db.type] }}'
|
||||||
|
--database-name '{{ ncloud_db.name }}'
|
||||||
|
--database-user '{{ ncloud_db.user }}'
|
||||||
|
--database-pass '{{ ncloud_db.pass }}'
|
||||||
|
--database-host '{{ ncloud_db.host | default("127.0.0.1") }}'
|
||||||
|
--admin-user '{{ ncloud_admin_user }}'
|
||||||
|
--admin-pass '{{ ncloud_admin_pass }}'
|
||||||
|
--data-dir '{{ ncloud_data_location }}'
|
||||||
|
become: yes
|
||||||
|
become_user: "{{ www_group }}"
|
||||||
|
register: ncloud_installation
|
||||||
|
|
||||||
|
- name: set nextcloud folder permission
|
||||||
|
file:
|
||||||
|
path: "{{ ncloud_data_location }}"
|
||||||
|
owner: "{{ www_group }}"
|
||||||
|
group: "{{ ncusr }}"
|
||||||
|
mode: "o="
|
||||||
|
recurse: yes
|
||||||
|
|
||||||
|
- name: configure php cron jobs
|
||||||
|
cron:
|
||||||
|
name: nextcloud-php
|
||||||
|
minute: "*/5"
|
||||||
|
job: "php -f {{ ncloud_dir }}/cron.php"
|
||||||
|
user: "{{ www_group }}"
|
||||||
|
|
||||||
|
- name: configure local memory caching APCu
|
||||||
|
lineinfile:
|
||||||
|
path: "{{ ncloud_dir }}/config/config.php"
|
||||||
|
regexp: "\\s*'memcache.local' => "
|
||||||
|
line: " 'memcache.local' => '\\OC\\Memcache\\APCu',"
|
||||||
|
insertbefore: "\\);"
|
||||||
|
when: ncloud_installation.changed
|
||||||
|
|
||||||
|
- name: configure redis conig
|
||||||
|
lineinfile:
|
||||||
|
path: "/etc/redis/redis.conf"
|
||||||
|
regexp: "(# |){{ item.key }} "
|
||||||
|
line: "{{ item.key }} {{ item.value }}"
|
||||||
|
loop:
|
||||||
|
- key: unixsocket
|
||||||
|
value: "{{ redis_socket }}"
|
||||||
|
- key: unixsocketperm
|
||||||
|
value: 775
|
||||||
|
- key: bind
|
||||||
|
value: 127.0.0.1
|
||||||
|
- key: daemonize
|
||||||
|
value: !unsafe yes
|
||||||
|
- key: stop-writes-on-bgsave-error
|
||||||
|
value: !unsafe no
|
||||||
|
- key: rdbcompression
|
||||||
|
value: !unsafe yes
|
||||||
|
- key: maxmemory
|
||||||
|
value: 50M
|
||||||
|
- key: maxmemory-policy
|
||||||
|
value: allkeys-lru
|
||||||
|
when: redis_remote_url | length == 0
|
||||||
|
notify: restart redis
|
||||||
|
|
||||||
|
- name: configure distributed memory caching APCu
|
||||||
|
lineinfile:
|
||||||
|
path: "{{ ncloud_dir }}/config/config.php"
|
||||||
|
regexp: "\\s*'{{ item.key }}' => "
|
||||||
|
line: " '{{ item.key }}' => {{ item.value }},"
|
||||||
|
insertbefore: "\\);"
|
||||||
|
loop:
|
||||||
|
- key: memcache.locking
|
||||||
|
value: "'\\OC\\Memcache\\Redis'"
|
||||||
|
# - key: memcache.distributed
|
||||||
|
# value: "'\\OC\\Memcache\\Redis'"
|
||||||
|
# - key: redis
|
||||||
|
# value: "['host' => '{% if redis_remote_url | length > 0 %}{{ redis_remote_url }}{% else %}{{ redis_socket }}{% endif %}','port' => {% if redis_remote_url | length > 0 %}{{ redis_port }}{% else %}0{% endif %}]"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.key }}"
|
||||||
|
when: ncloud_installation.changed
|
||||||
|
|
||||||
|
- name: configure other settings
|
||||||
|
lineinfile:
|
||||||
|
path: "{{ ncloud_dir }}/config/config.php"
|
||||||
|
regexp: "\\s*'{{ item.key }}' => "
|
||||||
|
line: " '{{ item.key }}' => {{ item.value }},"
|
||||||
|
insertbefore: "\\);"
|
||||||
|
loop: "{{ ncloud_config }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.key }}"
|
||||||
|
when: ncloud_installation.changed
|
||||||
|
|
||||||
|
|
||||||
|
- name: configure nextcloud domain
|
||||||
|
replace:
|
||||||
|
path: "{{ ncloud_dir }}/config/config.php"
|
||||||
|
regexp: "^\\s*'trusted_domains'\\s*=>\\s*array\\s*\\((.*\\n)+\\s*\\),$"
|
||||||
|
replace: " 'trusted_domains' => \\n array ({% for domain in ncloud_domain %}\\n {{ loop.index - 1}} => '{{ domain }}',{% endfor %}\\n ),"
|
||||||
|
when: ncloud_installation.changed
|
||||||
12
templates/etc/systemd/system/notify_push.service.j2
Executable file
12
templates/etc/systemd/system/notify_push.service.j2
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Push daemon for Nextcloud clients
|
||||||
|
Documentation=https://github.com/nextcloud/notify_push
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=PORT={{ ncloud_npush_port }}
|
||||||
|
Environment=NEXTCLOUD_URL=https://{{ ncloud_domain[0] }}
|
||||||
|
ExecStart={{ ncloud_dir }}/apps/notify_push/bin/x86_64/notify_push {{ ncloud_dir }}/config/config.php
|
||||||
|
User={{ www_group }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy = multi-user.target
|
||||||
19
vars/main.yml
Executable file
19
vars/main.yml
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
ncusr: "ncloud"
|
||||||
|
ncgrp: "{{ ncusr }}"
|
||||||
|
|
||||||
|
ncloud_dir: "{{ cloud_apps }}/nextcloud"
|
||||||
|
|
||||||
|
redis_socket: "/var/run/redis/redis-server.sock"
|
||||||
|
|
||||||
|
ncloud_notify_trusted_proxies:
|
||||||
|
- "127.0.0.1"
|
||||||
|
- "::1"
|
||||||
|
- "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
|
||||||
|
- "{{ hostvars[inventory_hostname]['ansible_default_ipv6']['address'] }}"
|
||||||
|
|
||||||
|
ncloud_db_mapping: {
|
||||||
|
'pgsql': 'postgres',
|
||||||
|
'mariadb': 'mysql',
|
||||||
|
'mysql': 'mysql'
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user