2019-09-01 07:58:04 +00:00
- name: 'Create MySQL database with name : {{ nextcloud_dbname }}'
mysql_db :
name : "{{ nextcloud_dbname }}"
- name : Add username/password to the MySQL database (associated with trusted IP's like localhost)
mysql_user :
name : "{{ nextcloud_dbuser }}"
host : "{{ item }}"
password : "{{ nextcloud_dbpassword }}"
priv : "{{ nextcloud_dbname }}.*:ALL,GRANT"
with_items :
- 127.0 .0 .1
- : : 1
- localhost
2020-02-16 03:49:27 +00:00
2020-02-17 01:52:01 +00:00
# https://docs.nextcloud.com/server/18/admin_manual/installation/command_line_installation.html
- name : Create data dir {{ nextcloud_data_dir }}
file :
state : directory
2020-02-17 02:00:32 +00:00
path : "{{ nextcloud_data_dir }}" # /library/www/nextcloud/data
2020-02-17 01:52:01 +00:00
owner : "{{ apache_user }}"
group : "{{ apache_user }}"
# 1 of 3: Very Old Way... from OwnCloud days
#- name: Install {{ nextcloud_root_dir }}/config/autoconfig.php from template
2020-02-16 03:49:27 +00:00
# template:
# src: autoconfig.php.j2
2020-02-17 01:52:01 +00:00
# dest: "{{ nextcloud_root_dir }}/config/autoconfig.php"
2020-02-16 03:49:27 +00:00
# owner: "{{ apache_user }}"
# group: "{{ apache_user }}"
# mode: '0640'
2020-02-17 01:52:01 +00:00
# 2 of 3: Another Possible Way... not quite ready for prime time
# - name: Set 'datadirectory' to {{ nextcloud_data_dir }} in {{ nextcloud_root_dir }}/config/config.php
# lineinfile:
# path: "{{ nextcloud_root_dir }}/config/config.php"
# regexp: "^ 'datadirectory' => "
# insertafter: '^\$CONFIG = array \('
# line: " 'datadirectory' => '{{ nextcloud_data_dir }}',"
2020-02-16 03:49:27 +00:00
2020-02-17 01:52:01 +00:00
# 2020-02-16: SHOULD THIS STANZA GO AWAY IN FUTURE, in favor of 'nextcloud_installed is undefined' test below?
- name : Use php to determine if Nextcloud is installed (causes install wizard to fail)
2019-09-01 07:58:04 +00:00
shell : >
2020-02-17 01:52:01 +00:00
php {{ nextcloud_root_dir }}/occ status |
2019-09-01 07:58:04 +00:00
gawk '/installed:/ { print $3 }'
become : yes
become_user : "{{ apache_user }}"
register : returned
2020-02-17 01:52:01 +00:00
# 3 of 3: New Way In 2020... use --data-dir "{{ nextcloud_data_dir }}"
# https://docs.nextcloud.com/server/18/admin_manual/installation/command_line_installation.html
# https://docs.nextcloud.com/server/18/admin_manual/configuration_server/occ_command.html#command-line-installation-label
- name : Run Nextcloud initial install wizard, seeding data dir {{ nextcloud_data_dir }} (IF THIS FAILS, CONSIDER MANUALLY DROPPING MySQL db '{{ nextcloud_dbname }}' THEN RERUN THIS)
2019-09-01 07:58:04 +00:00
shell : >
2020-02-17 01:52:01 +00:00
cd {{ nextcloud_root_dir }};
2019-09-01 07:58:04 +00:00
php occ maintenance:install
--database "mysql"
--database-name "{{ nextcloud_dbname }}"
--database-user "{{ nextcloud_dbuser }}"
--database-pass "{{ nextcloud_dbpassword }}"
--admin-user "{{ nextcloud_admin_user }}"
--admin-pass "{{ nextcloud_admin_password }}"
2020-02-17 01:52:01 +00:00
--data-dir "{{ nextcloud_data_dir }}"
2019-09-01 07:58:04 +00:00
become : yes
become_user : "{{ apache_user }}"
2020-02-17 01:52:01 +00:00
#when: nextcloud_installed is undefined
2020-02-16 03:49:27 +00:00
when : returned.stdout == "false" # and nextcloud_enabled
# https://docs.nextcloud.com/server/18/admin_manual/installation/source_installation.html#php-fpm-configuration-notes
- name : Set 'clear_env = no' in /etc/php/{{ php_version }}/fpm/pool.d/www.conf
lineinfile :
path : "/etc/php/{{ php_version }}/fpm/pool.d/www.conf"
regexp : '^clear_env'
insertafter : ';.*clear_env'
line : 'clear_env = no'
2019-09-01 07:58:04 +00:00
2020-01-07 17:26:55 +00:00
- name: 'Allow Nextcloud access from all hosts and IP addresses (SEE ALSO : /etc/apache2/sites-available/nextcloud.conf)'
2020-02-17 01:52:01 +00:00
command : php {{ nextcloud_root_dir }}/occ config:system:set trusted_domains 1 --value=*
2019-09-01 07:58:04 +00:00
become : yes
become_user : "{{ apache_user }}"