From 5ad953dbd0d300802adf53e59ce2154bea1cad25 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 01:56:27 -0400 Subject: [PATCH] Update nextcloud_enabled.yml --- roles/nextcloud/tasks/nextcloud_enabled.yml | 62 +++++++++++++-------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/roles/nextcloud/tasks/nextcloud_enabled.yml b/roles/nextcloud/tasks/nextcloud_enabled.yml index ee7f0a53c..50badd564 100644 --- a/roles/nextcloud/tasks/nextcloud_enabled.yml +++ b/roles/nextcloud/tasks/nextcloud_enabled.yml @@ -13,20 +13,26 @@ mode: 0644 when: nextcloud_enabled -- name: Create symlink from sites-available to sites-enabled for http://box/nextcloud (debuntu) +- name: Create symlink nextcloud.conf from sites-enabled to sites-available for http://box/nextcloud (debuntu) file: - src: /etc/apache2/sites-available/nextcloud.conf + src: "/etc/{{ apache_config_dir }}/nextcloud.conf" path: /etc/apache2/sites-enabled/nextcloud.conf state: link when: nextcloud_enabled and is_debuntu -- name: Remove nextcloud.conf if not nextcloud_enabled (redhat) +- 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) file: path: "/etc/{{ apache_config_dir }}/nextcloud.conf" state: absent when: not nextcloud_enabled and is_redhat -- name: Restart Apache, enabling http://box/nextcloud +- name: Restart Apache, enabling/disabling http://box/nextcloud service: name: "{{ apache_service }}" state: restarted @@ -59,26 +65,34 @@ become_user: "{{ apache_user }}" when: nextcloud_enabled and returned.stdout == "false" -- name: Determine if Nextcloud user exists already - shell: > - #sudo -u {{ apache_user }} - php '{{ nextcloud_prefix }}/nextcloud/occ' user:list | - grep {{ nextcloud_user }} | wc | cut -d' ' -f1 - become: yes - become_user: "{{ apache_user }}" - register: returned_count - -# nextcloud wants to make users rather than just mysql users and not done -- name: Create the default user - shell: > - #su -s /bin/sh {{ apache_user }} -c - 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" +# Code below was NEVER RUNNING as of 2018-10-29, as "wc | cut -d' ' -f1" ALWAYS +# returns null (rather than the intended returned_count !) This fragment could +# be replace with "wc -l" or "wc | awk '{print $1}'" if it truly needs fixing? +# +# Or perhaps default user/password nextcloud/nextcloudmysql (from variables +# nextcloud_user/nextcloud_user_password) is just not needed in the end... +# +#- name: Determine if Nextcloud user exists already +# shell: > +# #sudo -u {{ apache_user }} +# php '{{ nextcloud_prefix }}/nextcloud/occ' user:list | +# grep {{ nextcloud_user }} | wc | cut -d' ' -f1 +# #grep {{ nextcloud_user }} | wc -l +# become: yes +# become_user: "{{ apache_user }}" +# register: returned_count +# +## nextcloud wants to make users rather than just mysql users and not done +#- name: Create the default user +# shell: > +# #su -s /bin/sh {{ apache_user }} -c +# 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" - name: Remove overwrite.cli.url line (Rewrite URL) from /opt/nextcloud/config/config.php lineinfile: