ansible-roles/nextcloud/tasks/config.yml
Jérémy Lecour 28be7d1218 nextcloud: intall one instance at a time
* introduce many variable with sensible defaults
* generate an admin password if none is provided (default)
* execute occ commands as unprivileged user
2018-03-29 08:35:26 +02:00

104 lines
2.8 KiB
YAML

---
- name: Create data directory
file:
dest: "{{ nextcloud_data | mandatory }}"
state: directory
mode: "0770"
owner: "{{ nextcloud_user }}"
group: "{{ nextcloud_user }}"
tags:
- nextcloud
- name: Link config dir to global config dir
file:
src: "{{ nextcloud_home }}/config/config.php"
dest: "{{ nextcloud_webroot }}/config/config.php"
owner: "{{ nextcloud_user }}"
group: "{{ nextcloud_user }}"
state: link
force: True
tags:
- nextcloud
- block:
- name: Generate admin password
command: 'apg -n 1 -m 16 -M lcN'
register: nextcloud_admin_password_apg
check_mode: no
changed_when: False
- debug:
var: nextcloud_admin_password_apg
verbosity: 1
- set_fact:
nextcloud_admin_password: "{{ nextcloud_admin_password_apg.stdout }}"
- debug:
msg: "WARNING: your generated admin password is '{{ nextcloud_admin_password }}'."
tags:
- nextcloud
when: nextcloud_admin_password == ""
- name: Install Nextcloud
command: "php ./occ maintenance:install --database mysql --database-name {{ nextcloud_db_name | mandatory }} --database-user {{ nextcloud_db_user | mandatory }} --database-pass {{ nextcloud_db_pass | mandatory }} --admin-user {{ nextcloud_admin_login | mandatory }} --admin-pass {{ nextcloud_admin_password | mandatory }} --data-dir {{ nextcloud_data | mandatory }}"
args:
chdir: "{{ nextcloud_webroot }}"
creates: "{{ nextcloud_home }}/config/config.php"
become_user: "{{ nextcloud_user }}"
tags:
- nextcloud
- name: Configure Nextcloud Mysql password
replace:
dest: "{{ nextcloud_home }}/config/config.php"
regexp: "'dbpassword' => '([^']*)',"
replace: "'dbpassword' => '{{ nextcloud_db_pass }}',"
tags:
- nextcloud
- name: Configure Nextcloud cron
cron:
name: 'Nextcloud'
minute: "*/15"
job: "php -f {{ nextcloud_webroot }}/cron.php"
user: "{{ nextcloud_user }}"
tags:
- nextcloud
- name: Erase previously trusted domains config
command: "php ./occ config:system:set trusted_domains"
args:
chdir: "{{ nextcloud_webroot }}"
become_user: "{{ nextcloud_user }}"
tags:
- nextcloud
- name: Configure trusted domains
command: "php ./occ config:system:set trusted_domains {{ item.0 }} --value {{ item.1 }}"
args:
chdir: "{{ nextcloud_webroot }}"
with_indexed_items:
- "{{ nextcloud_domains }}"
become_user: "{{ nextcloud_user }}"
tags:
- nextcloud
#- name: Configure memcache local to APCu
# command: "php ./occ config:system:set memcache.local --value '\\OC\\Memcache\\APCu'"
# args:
# chdir: "{{ nextcloud_webroot }}"
# become_user: "{{ nextcloud_user }}"
# tags:
# - nextcloud
- name: Fix right on config.php
file:
dest: "{{ nextcloud_home }}/config/config.php"
owner: "{{ nextcloud_user }}"
group: "{{ nextcloud_user }}"
mode: "0660"
tags:
- nextcloud