1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-15 04:32:11 +00:00

Merge pull request #1265 from holta/ansible-warnings

Eliminate Ansible warnings (PostgreSQL, Nextcloud, Sugarizer)
This commit is contained in:
A Holt 2018-10-29 05:23:23 -04:00 committed by GitHub
commit 9f552655f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 59 deletions

View file

@ -1,28 +1,29 @@
- name: See if Nextcloud version page exists - name: Check for existence of /opt/nextcloud/version.php
stat: stat:
path: "{{ nextcloud_prefix }}/nextcloud/version.php" path: "{{ nextcloud_prefix }}/nextcloud/version.php"
# path: "{{ nextcloud_prefix }}/nextcloud/index.php"
register: nextcloud_page 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: set_fact:
nextcloud_force_install: True nextcloud_force_install: True
when: not nextcloud_page.stat.exists when: not nextcloud_page.stat.exists
# - debug:
# var: nextcloud_force_install
# - debug: # - debug:
# msg: "nextcloud_force_install: {{ nextcloud_force_install }}" # msg: "nextcloud_force_install: {{ nextcloud_force_install }}"
- name: Download {{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }} to {{ downloads_dir }}/{{ nextcloud_src_file }}
- name: Download latest Nextcloud software to /opt/iiab/download/{{ nextcloud_src_file }}
get_url: get_url:
url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}" url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}"
dest: "{{ downloads_dir }}/{{ nextcloud_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 }}" 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 when: internet_available and nextcloud_force_install
async: 1800 #async: 1800
poll: 10 #poll: 10
tags: tags:
- download - download
@ -89,13 +90,13 @@
#creates: "{{ nextcloud_prefix }}/nextcloud/version.php" #creates: "{{ nextcloud_prefix }}/nextcloud/version.php"
when: nextcloud_force_install 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: file:
path: /etc/nextcloud path: /etc/nextcloud
state: directory state: directory
when: is_centos when: is_centos
- name: Add autoconfig file (CentOS) - name: Install {{ nextcloud_prefix }}/nextcloud/config/autoconfig.php from template (centos)
template: template:
src: autoconfig.php.j2 src: autoconfig.php.j2
dest: "{{ nextcloud_prefix }}/nextcloud/config/autoconfig.php" dest: "{{ nextcloud_prefix }}/nextcloud/config/autoconfig.php"
@ -104,7 +105,7 @@
mode: 0640 mode: 0640
when: is_centos when: is_centos
- name: Make Apache owner - name: chown -R {{ apache_user }}:{{ apache_user }} {{ nextcloud_prefix }}/nextcloud
file: file:
path: "{{ nextcloud_prefix }}/nextcloud" path: "{{ nextcloud_prefix }}/nextcloud"
owner: "{{ apache_user }}" owner: "{{ apache_user }}"
@ -112,22 +113,20 @@
recurse: yes recurse: yes
state: directory state: directory
- name: Create data directory library - name: Create data directory {{ nextcloud_data_dir }} # /opt/nextcloud/data
file: file:
path: "{{ item }}" path: "{{ nextcloud_data_dir }}"
owner: "{{ apache_user }}" owner: "{{ apache_user }}"
group: "{{ apache_user }}" group: "{{ apache_user }}"
mode: 0750 mode: 0750
state: directory state: directory
with_items:
- "{{ nextcloud_data_dir }}"
- name: Create MySQL database {{ nextcloud_dbname }} for Nextcloud - name: 'Create MySQL database with name: {{ nextcloud_dbname }}'
mysql_db: mysql_db:
name: "{{ nextcloud_dbname }}" name: "{{ nextcloud_dbname }}"
when: mysql_enabled and nextcloud_enabled 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: mysql_user:
name: "{{ nextcloud_dbuser }}" name: "{{ nextcloud_dbuser }}"
host: "{{ item }}" host: "{{ item }}"
@ -140,17 +139,15 @@
- localhost - localhost
when: mysql_enabled and nextcloud_enabled 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 # Enables or disable 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
- include_tasks: nextcloud_enabled.yml - include_tasks: nextcloud_enabled.yml
- name: Add 'nextcloud' to list of services at {{ iiab_ini_file }} - 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."' value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."'
- option: path - option: path
value: "{{ nextcloud_prefix }}/nextcloud" 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 }}" value: "{{ nextcloud_src_file }}"
- option: enabled - option: nextcloud_enabled
value: "{{ nextcloud_enabled }}" value: "{{ nextcloud_enabled }}"

View file

@ -13,20 +13,26 @@
mode: 0644 mode: 0644
when: nextcloud_enabled 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: file:
src: /etc/apache2/sites-available/nextcloud.conf src: "/etc/{{ apache_config_dir }}/nextcloud.conf"
path: /etc/apache2/sites-enabled/nextcloud.conf path: /etc/apache2/sites-enabled/nextcloud.conf
state: link state: link
when: nextcloud_enabled and is_debuntu 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: file:
path: "/etc/{{ apache_config_dir }}/nextcloud.conf" path: "/etc/{{ apache_config_dir }}/nextcloud.conf"
state: absent state: absent
when: not nextcloud_enabled and is_redhat when: not nextcloud_enabled and is_redhat
- name: Restart Apache, enabling http://box/nextcloud - name: Restart Apache, enabling/disabling http://box/nextcloud
service: service:
name: "{{ apache_service }}" name: "{{ apache_service }}"
state: restarted state: restarted
@ -34,8 +40,7 @@
# the install wizard does not succeed if already installed # the install wizard does not succeed if already installed
- name: Determine if Nextcloud is installed - name: Determine if Nextcloud is installed
shell: > shell: >
#sudo -u {{ apache_user }} php {{ nextcloud_prefix }}/nextcloud/occ status |
php '{{ nextcloud_prefix }}/nextcloud/occ' status |
gawk '/installed:/ { print $3 }' gawk '/installed:/ { print $3 }'
become: yes become: yes
become_user: "{{ apache_user }}" become_user: "{{ apache_user }}"
@ -44,39 +49,55 @@
- name: Run Nextcloud initial install wizard - name: Run Nextcloud initial install wizard
shell: > shell: >
cd {{ nextcloud_prefix }}/nextcloud; cd {{ nextcloud_prefix }}/nextcloud;
sudo -u {{ apache_user }} php occ maintenance:install php occ maintenance:install
--database "mysql" --database "mysql"
--database-name "{{ nextcloud_dbname }}" --database-name "{{ nextcloud_dbname }}"
--database-user "{{ nextcloud_dbuser }}" --database-user "{{ nextcloud_dbuser }}"
--database-pass "{{ nextcloud_dbpassword }}" --database-pass "{{ nextcloud_dbpassword }}"
--admin-user "{{ nextcloud_admin_user }}" --admin-user "{{ nextcloud_admin_user }}"
--admin-pass "{{ nextcloud_admin_password }}" --admin-pass "{{ nextcloud_admin_password }}"
become: yes
become_user: "{{ apache_user }}"
when: nextcloud_enabled and returned.stdout == "false" when: nextcloud_enabled and returned.stdout == "false"
- name: Allow access from all hosts and ips - 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: true become: yes
become_user: "{{ apache_user }}" become_user: "{{ apache_user }}"
when: nextcloud_enabled and returned.stdout == "false" when: nextcloud_enabled and returned.stdout == "false"
- name: Determine if Nextcloud user exists already # Code below was NEVER RUNNING as of 2018-10-29, as "wc | cut -d' ' -f1" ALWAYS
shell: > # returns null (rather than the intended returned_count !) This line could
#sudo -u {{ apache_user }} # be replaced by ALTERNATIVE 1 or ALTERNATIVE 2 below IF it truly needs fixing.
php '{{ nextcloud_prefix }}/nextcloud/occ' user:list | #
grep {{ nextcloud_user }} | wc | cut -d' ' -f1 # Or perhaps default user/password nextcloud/nextcloudmysql (from variables
become: yes # nextcloud_user/nextcloud_user_password) is just not needed in the end...
become_user: "{{ apache_user }}" #
register: returned_count # NOTE: COMMENTS (FOLLOWING '#' SIGN) WITHIN A SHELL COMMAND CAUSE IT TO *FAIL*
#
# nextcloud wants to make users rather than just mysql users and not done #- name: Determine if Nextcloud user exists already
- name: Create the default user # shell: >
shell: > # php {{ nextcloud_prefix }}/nextcloud/occ user:list |
su -s /bin/sh {{ apache_user }} -c # grep {{ nextcloud_user }} | wc | cut -d' ' -f1 # USELESS
'OC_PASS={{ nextcloud_user_password }}; # #grep {{ nextcloud_user }} | wc -l # ALTERNATIVE 1
php {{ nextcloud_prefix }}/nextcloud/occ user:add # #grep {{ nextcloud_user }} | wc | awk '{print $1}' # ALTERNATIVE 2
--password-from-env --display-name={{ nextcloud_user }} # become: yes
--group="users" {{ nextcloud_user }}' # become_user: "{{ apache_user }}"
when: nextcloud_enabled and returned_count == "0" # 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: >
# 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 - name: Remove overwrite.cli.url line (Rewrite URL) from /opt/nextcloud/config/config.php
lineinfile: lineinfile:

View file

@ -48,15 +48,21 @@
when: is_debuntu when: is_debuntu
- name: Initialize the postgres db (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: args:
creates: /library/pgsql-iiab/pg_hba.conf creates: /library/pgsql-iiab/pg_hba.conf
become: yes
become_user: postgres
when: is_debuntu when: is_debuntu
- name: Initialize the postgres db (OS's other than 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: args:
creates: /library/pgsql-iiab/pg_hba.conf creates: /library/pgsql-iiab/pg_hba.conf
become: yes
become_user: postgres
when: not is_debuntu when: not is_debuntu
- name: Configure PostgreSQL - name: Configure PostgreSQL

View file

@ -59,6 +59,8 @@
- name: Set up Node.js 8.x apt sources (debuntu, but avoid ubuntu-18) - 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 - 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 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) - name: Install latest Node.js which includes /usr/bin/npm (debuntu, but avoid ubuntu-18)