2018-02-06 23:18:42 +00:00
# This should go in computed_network.yml, but here for now
2019-09-04 17:21:34 +00:00
# 2019-09-04: THE NEXT 4 LINES ARE UNUSED (due to changes in roles/nextcloud/templates/nextcloud.conf.j2)
2017-11-05 05:23:34 +00:00
- name : Compute Nextcloud listen ip addr for nextcloud.conf
2017-05-29 22:02:55 +00:00
set_fact :
2018-02-06 23:18:42 +00:00
nextcloud_required_ip : "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}"
2017-05-29 22:02:55 +00:00
when : ansible_default_ipv4.network is defined
2018-10-28 17:28:56 +00:00
- name : Install Apache's nextcloud.conf from template, for http://box/nextcloud
2018-02-06 23:18:42 +00:00
template :
src : nextcloud.conf.j2
dest : "/etc/{{ apache_config_dir }}/nextcloud.conf"
owner : root
group : root
mode : 0644
2019-05-24 22:33:10 +00:00
when : nextcloud_enabled | bool
2017-05-30 02:37:12 +00:00
2018-10-29 05:56:27 +00:00
- name : Create symlink nextcloud.conf from sites-enabled to sites-available for http://box/nextcloud (debuntu)
2018-02-06 23:18:42 +00:00
file :
2018-10-29 05:56:27 +00:00
src : "/etc/{{ apache_config_dir }}/nextcloud.conf"
2018-10-28 18:46:47 +00:00
path : /etc/apache2/sites-enabled/nextcloud.conf
2018-02-06 23:18:42 +00:00
state : link
2017-05-30 02:37:12 +00:00
when : nextcloud_enabled and is_debuntu
2017-05-29 22:02:55 +00:00
2018-10-29 05:56:27 +00:00
- name : Remove symlink nextcloud.conf from /etc/apache2/sites-enabled if not nextcloud_enabled (debuntu)
file :
path : /etc/apache2/sites-enabled/nextcloud.conf
state : absent
when : not nextcloud_enabled and is_debuntu
- name : Remove sites-available/nextcloud.conf if not nextcloud_enabled (redhat)
2018-02-06 23:18:42 +00:00
file :
path : "/etc/{{ apache_config_dir }}/nextcloud.conf"
state : absent
2017-05-30 03:04:04 +00:00
when : not nextcloud_enabled and is_redhat
2017-05-29 22:02:55 +00:00
2018-10-29 05:56:27 +00:00
- name : Restart Apache, enabling/disabling http://box/nextcloud
2018-02-06 23:18:42 +00:00
service :
name : "{{ apache_service }}"
state : restarted
2017-05-29 22:02:55 +00:00
2017-06-19 02:03:38 +00:00
# the install wizard does not succeed if already installed
2017-11-05 05:23:34 +00:00
- name : Determine if Nextcloud is installed
2017-06-19 13:56:54 +00:00
shell : >
2018-10-29 08:12:35 +00:00
php {{ nextcloud_prefix }}/nextcloud/occ status |
2018-02-06 23:18:42 +00:00
gawk '/installed:/ { print $3 }'
2018-10-28 17:28:56 +00:00
become : yes
2018-10-28 18:46:47 +00:00
become_user : "{{ apache_user }}"
2017-06-20 22:25:07 +00:00
register : returned
2017-06-19 02:03:38 +00:00
2017-11-05 05:23:34 +00:00
- name : Run Nextcloud initial install wizard
2017-06-19 01:16:28 +00:00
shell : >
2018-02-06 23:18:42 +00:00
cd {{ nextcloud_prefix }}/nextcloud;
2018-10-29 08:12:35 +00:00
php occ maintenance:install
2018-02-06 23:18:42 +00:00
--database "mysql"
--database-name "{{ nextcloud_dbname }}"
--database-user "{{ nextcloud_dbuser }}"
--database-pass "{{ nextcloud_dbpassword }}"
--admin-user "{{ nextcloud_admin_user }}"
--admin-pass "{{ nextcloud_admin_password }}"
2018-10-29 08:12:35 +00:00
become : yes
become_user : "{{ apache_user }}"
2017-06-26 19:24:58 +00:00
when : nextcloud_enabled and returned.stdout == "false"
2017-11-05 05:23:34 +00:00
- name : Allow access from all hosts and ips
2018-10-29 08:12:35 +00:00
command : php {{ nextcloud_prefix }}/nextcloud/occ config:system:set trusted_domains 1 --value=*
2018-10-29 04:28:34 +00:00
become : yes
2017-06-26 19:24:58 +00:00
become_user : "{{ apache_user }}"
2017-06-20 22:25:07 +00:00
when : nextcloud_enabled and returned.stdout == "false"
2017-05-29 22:02:55 +00:00
2018-10-29 05:56:27 +00:00
# Code below was NEVER RUNNING as of 2018-10-29, as "wc | cut -d' ' -f1" ALWAYS
2018-10-29 08:12:35 +00:00
# returns null (rather than the intended returned_count !) This line could
# be replaced by ALTERNATIVE 1 or ALTERNATIVE 2 below IF it truly needs fixing.
2018-10-29 05:56:27 +00:00
#
# Or perhaps default user/password nextcloud/nextcloudmysql (from variables
# nextcloud_user/nextcloud_user_password) is just not needed in the end...
2018-10-29 08:12:35 +00:00
#
# NOTE: COMMENTS (FOLLOWING '#' SIGN) WITHIN A SHELL COMMAND CAUSE IT TO *FAIL*
2018-10-29 05:56:27 +00:00
#
#- name: Determine if Nextcloud user exists already
# shell: >
2018-10-29 08:12:35 +00:00
# php {{ nextcloud_prefix }}/nextcloud/occ user:list |
# grep {{ nextcloud_user }} | wc | cut -d' ' -f1 # USELESS
# #grep {{ nextcloud_user }} | wc -l # ALTERNATIVE 1
# #grep {{ nextcloud_user }} | wc | awk '{print $1}' # ALTERNATIVE 2
2018-10-29 05:56:27 +00:00
# become: yes
# become_user: "{{ apache_user }}"
# register: returned_count
#
2018-10-29 08:12:35 +00:00
# debug:
# var: returned_count
#
2018-10-29 05:56:27 +00:00
## nextcloud wants to make users rather than just mysql users and not done
#- name: Create the default user
# shell: >
# OC_PASS={{ nextcloud_user_password }};
# php {{ nextcloud_prefix }}/nextcloud/occ user:add
# --password-from-env --display-name={{ nextcloud_user }}
# --group="users" {{ nextcloud_user }}
# become: yes
# become_user: "{{ apache_user }}"
# when: nextcloud_enabled and returned_count == "0"
2017-06-19 13:56:54 +00:00
2019-09-04 20:22:23 +00:00
# 2019-09-04: NEXT 5 LINES APPEAR INEFFECTIVE DURING 1ST INSTALL? (possibly "overwrite.cli.url" appears later, when Nextcloud's web install completes using http://box/nextcloud ?)
2019-09-04 20:18:52 +00:00
- name : Try to remove overwrite.cli.url line (Rewrite URL) from /opt/nextcloud/config/config.php
2018-02-06 23:18:42 +00:00
lineinfile :
regexp : "overwrite.cli.url"
state : absent
2018-10-28 17:28:56 +00:00
path : "{{ nextcloud_prefix }}/nextcloud/config/config.php"