From 314990cc94f99912b0e02949c8d69860b38a8f07 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 00:11:12 -0400 Subject: [PATCH 1/9] Update main.yml --- roles/sugarizer/tasks/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index f2e9a557d..e6e62c108 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -59,6 +59,8 @@ - name: Set up Node.js 8.x apt sources (debuntu, but avoid ubuntu-18) shell: curl -sL https://deb.nodesource.com/setup_8.x | bash - + args: + warn: no when: internet_available and is_debuntu and not is_ubuntu_18 - name: Install latest Node.js which includes /usr/bin/npm (debuntu, but avoid ubuntu-18) From eb810ecc9b3ab3e04f7100eb75fc5a6ef7decdcb Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 00:28:17 -0400 Subject: [PATCH 2/9] Update main.yml --- roles/postgresql/tasks/main.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/postgresql/tasks/main.yml b/roles/postgresql/tasks/main.yml index a5b644420..ca6196cc3 100644 --- a/roles/postgresql/tasks/main.yml +++ b/roles/postgresql/tasks/main.yml @@ -48,15 +48,21 @@ when: is_debuntu - name: Initialize the postgres db (debuntu) - command: su - postgres -c "/usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab" + #command: su - postgres -c "/usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab" + command: /usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab args: creates: /library/pgsql-iiab/pg_hba.conf + become: yes + become_user: postgres when: is_debuntu - name: Initialize the postgres db (OS's other than debuntu) - command: su - postgres -c "/usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab" + #command: su - postgres -c "/usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab" + command: /usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab args: creates: /library/pgsql-iiab/pg_hba.conf + become: yes + become_user: postgres when: not is_debuntu - name: Configure PostgreSQL From a6a6e61cdc1081e7ec446f7e4a80439db1cdf3aa Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 00:28:34 -0400 Subject: [PATCH 3/9] Update nextcloud_enabled.yml --- roles/nextcloud/tasks/nextcloud_enabled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nextcloud/tasks/nextcloud_enabled.yml b/roles/nextcloud/tasks/nextcloud_enabled.yml index 780529d66..de12e89df 100644 --- a/roles/nextcloud/tasks/nextcloud_enabled.yml +++ b/roles/nextcloud/tasks/nextcloud_enabled.yml @@ -55,7 +55,7 @@ - name: Allow access from all hosts and ips command: php '{{ nextcloud_prefix }}/nextcloud/occ' config:system:set trusted_domains 1 --value=* - become: true + become: yes become_user: "{{ apache_user }}" when: nextcloud_enabled and returned.stdout == "false" From f03eb1300f5eddf9e6b1405e36049a09f295e24a Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 00:38:38 -0400 Subject: [PATCH 4/9] Update nextcloud_enabled.yml --- roles/nextcloud/tasks/nextcloud_enabled.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/roles/nextcloud/tasks/nextcloud_enabled.yml b/roles/nextcloud/tasks/nextcloud_enabled.yml index de12e89df..ee7f0a53c 100644 --- a/roles/nextcloud/tasks/nextcloud_enabled.yml +++ b/roles/nextcloud/tasks/nextcloud_enabled.yml @@ -71,11 +71,13 @@ # 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 }}; + #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 }}' + --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 From 5ad953dbd0d300802adf53e59ce2154bea1cad25 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 01:56:27 -0400 Subject: [PATCH 5/9] 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: From 17847d05d0d189c4831311a33d8287d16b61648a Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 03:18:58 -0400 Subject: [PATCH 6/9] Update main.yml --- roles/nextcloud/tasks/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 8195f3b8a..ce5d5085c 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -13,16 +13,16 @@ # msg: "nextcloud_force_install: {{ nextcloud_force_install }}" -- name: Download latest Nextcloud software to /opt/iiab/download/{{ nextcloud_src_file }} +- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }} to {{ downloads_dir }}/{{ nextcloud_src_file }} get_url: url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}" dest: "{{ downloads_dir }}/{{ nextcloud_src_file }}" - force: yes - #validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954 timeout: "{{ download_timeout }}" + #force: yes + #validate_certs: False # TEMPORARY ON/AFTER 2018-07-22 AS download.nextcloud.com CERT EXPIRED: https://github.com/iiab/iiab/issues/954 when: internet_available and nextcloud_force_install - async: 1800 - poll: 10 + #async: 1800 + #poll: 10 tags: - download From 114a3f7b84a99feb5cd31253bf8ed21fc02be981 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 04:12:35 -0400 Subject: [PATCH 7/9] Update nextcloud_enabled.yml --- roles/nextcloud/tasks/nextcloud_enabled.yml | 27 ++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/roles/nextcloud/tasks/nextcloud_enabled.yml b/roles/nextcloud/tasks/nextcloud_enabled.yml index 50badd564..daf63e576 100644 --- a/roles/nextcloud/tasks/nextcloud_enabled.yml +++ b/roles/nextcloud/tasks/nextcloud_enabled.yml @@ -40,8 +40,7 @@ # the install wizard does not succeed if already installed - name: Determine if Nextcloud is installed shell: > - #sudo -u {{ apache_user }} - php '{{ nextcloud_prefix }}/nextcloud/occ' status | + php {{ nextcloud_prefix }}/nextcloud/occ status | gawk '/installed:/ { print $3 }' become: yes become_user: "{{ apache_user }}" @@ -50,42 +49,48 @@ - name: Run Nextcloud initial install wizard shell: > cd {{ nextcloud_prefix }}/nextcloud; - sudo -u {{ apache_user }} php occ maintenance:install + 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 }}" + become: yes + become_user: "{{ apache_user }}" when: nextcloud_enabled and returned.stdout == "false" - name: Allow access from all hosts and ips - command: php '{{ nextcloud_prefix }}/nextcloud/occ' config:system:set trusted_domains 1 --value=* + command: php {{ nextcloud_prefix }}/nextcloud/occ config:system:set trusted_domains 1 --value=* become: yes become_user: "{{ apache_user }}" when: nextcloud_enabled and returned.stdout == "false" # 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? +# 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. # # Or perhaps default user/password nextcloud/nextcloudmysql (from variables # nextcloud_user/nextcloud_user_password) is just not needed in the end... +# +# NOTE: COMMENTS (FOLLOWING '#' SIGN) WITHIN A SHELL COMMAND CAUSE IT TO *FAIL* # #- 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 +# 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 # become: yes # become_user: "{{ apache_user }}" # register: returned_count # +# debug: +# var: 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 }} From 3b99ff697d1083fe6634642fd36ddd9cc4c66a06 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 05:00:07 -0400 Subject: [PATCH 8/9] Update main.yml --- roles/nextcloud/tasks/main.yml | 51 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index ce5d5085c..a22dfb41a 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -1,17 +1,18 @@ -- name: See if Nextcloud version page exists +- name: Check for existence of /opt/nextcloud/version.php stat: path: "{{ nextcloud_prefix }}/nextcloud/version.php" -# path: "{{ nextcloud_prefix }}/nextcloud/index.php" register: nextcloud_page -- name: FORCE INSTALL OR REINSTALL OR UPGRADE IF /opt/nextcloud/version.php DOESN'T EXIST +- name: FORCE INSTALL OR REINSTALL OR UPGRADE IF {{ nextcloud_prefix }}/nextcloud/version.php DOESN'T EXIST set_fact: nextcloud_force_install: True when: not nextcloud_page.stat.exists # - debug: -# msg: "nextcloud_force_install: {{ nextcloud_force_install }}" +# var: nextcloud_force_install +# - debug: +# msg: "nextcloud_force_install: {{ nextcloud_force_install }}" - name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }} to {{ downloads_dir }}/{{ nextcloud_src_file }} get_url: @@ -89,13 +90,13 @@ #creates: "{{ nextcloud_prefix }}/nextcloud/version.php" when: nextcloud_force_install -- name: In CentOS, the following config dir is symlink to /etc/nextcloud +- name: Create dir /etc/nextcloud (centos) for a subsequent config dir that's symlinked to /etc/nextcloud ? file: path: /etc/nextcloud state: directory when: is_centos -- name: Add autoconfig file (CentOS) +- name: Install {{ nextcloud_prefix }}/nextcloud/config/autoconfig.php from template (centos) template: src: autoconfig.php.j2 dest: "{{ nextcloud_prefix }}/nextcloud/config/autoconfig.php" @@ -104,7 +105,7 @@ mode: 0640 when: is_centos -- name: Make Apache owner +- name: chown -R {{ apache_user }}:{{ apache_user }} {{ nextcloud_prefix }}/nextcloud file: path: "{{ nextcloud_prefix }}/nextcloud" owner: "{{ apache_user }}" @@ -112,22 +113,20 @@ recurse: yes state: directory -- name: Create data directory library +- name: Create data directory {{ nextcloud_data_dir }} # /opt/nextcloud/data file: - path: "{{ item }}" + path: "{{ nextcloud_data_dir }}" owner: "{{ apache_user }}" group: "{{ apache_user }}" mode: 0750 state: directory - with_items: - - "{{ nextcloud_data_dir }}" -- name: Create MySQL database {{ nextcloud_dbname }} for Nextcloud +- name: Create MySQL database {{ nextcloud_dbname }} mysql_db: name: "{{ nextcloud_dbname }}" when: mysql_enabled and nextcloud_enabled -- name: Create username/password for Nextcloud database +- name: Add username/password to the MySQL database (associated with trusted IP's like localhost) mysql_user: name: "{{ nextcloud_dbuser }}" host: "{{ item }}" @@ -140,17 +139,15 @@ - localhost when: mysql_enabled and nextcloud_enabled +# Appears unnec as nextcloud_enabled.yml (just below) does the same +#- name: Restart Apache +# service: +# name: "{{ apache_service }}" +# state: restarted +## when: nextcloud_enabled # taken care of by nextcloud_enabled.yml below +# when: not nextcloud_enabled -- name: Restart Apache, to enable/disable http://box/nextcloud - service: - name: "{{ apache_service }}" - state: restarted -# when: nextcloud_enabled # taken care of by nextcloud_enabled.yml below - when: not nextcloud_enabled - -# Enable nextcloud by copying template to httpd config - -# following enables and disables +# Enables or disable Nextcloud! - include_tasks: nextcloud_enabled.yml - name: Add 'nextcloud' to list of services at {{ iiab_ini_file }} @@ -166,7 +163,11 @@ value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."' - option: path value: "{{ nextcloud_prefix }}/nextcloud" - - option: source + - option: nextcloud_force_install + value: "{{ nextcloud_force_install }}" + - option: nextcloud_orig_src_file + value: "{{ nextcloud_orig_src_file }}" + - option: nextcloud_src_file value: "{{ nextcloud_src_file }}" - - option: enabled + - option: nextcloud_enabled value: "{{ nextcloud_enabled }}" From 65e1d144be9628dce2d50856740cc12037d4acf8 Mon Sep 17 00:00:00 2001 From: A Holt Date: Mon, 29 Oct 2018 05:21:15 -0400 Subject: [PATCH 9/9] Update main.yml --- roles/nextcloud/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index a22dfb41a..9b5bdc34e 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -121,7 +121,7 @@ mode: 0750 state: directory -- name: Create MySQL database {{ nextcloud_dbname }} +- name: 'Create MySQL database with name: {{ nextcloud_dbname }}' mysql_db: name: "{{ nextcloud_dbname }}" when: mysql_enabled and nextcloud_enabled