1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00

Merge pull request #176 from iiab/master

sync from iiab/iiab
This commit is contained in:
A Holt 2018-10-30 20:08:33 -04:00 committed by GitHub
commit 2892a43c4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 143 additions and 105 deletions

View file

@ -23,6 +23,9 @@
when: squid_install
tags: base, squid, network, domain
# NETWORK moved to the very end, after Stage 9 (9-LOCAL-ADDONS)
# It can also be run manually using: cd /opt/iiab/iiab; ./iiab-network
#
#- name: NETWORK
# include_role:
# name: network
@ -72,7 +75,7 @@
src: roles/1-prep/templates/iiab_env.py.j2
dest: /etc/iiab/iiab_env.py
- name: Run /usr/bin/iiab-refresh-wiki-docs (scraper script) to create http://box/info offline documentation (script was installed at the beginning of Stage 3 = roles/3-base-server/tasks/main.yml, which runs the HTTPD playbook = roles/httpd/tasks/main.yml)
- name: Run /usr/bin/iiab-refresh-wiki-docs (scraper script) to create http://box/info offline documentation. (This script was installed at the beginning of Stage 3 = roles/3-base-server/tasks/main.yml, which ran Apache playbook = roles/httpd/tasks/main.yml)
command: /usr/bin/iiab-refresh-wiki-docs
when: not nodocs

View file

@ -1,37 +1,42 @@
# Assume we only get here if elgg_install: True
# Assume mysql is running
# Assume MySQL is running
- name: Download current version from our site
shell: wget {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip -c -P {{ downloads_dir }}
args:
creates: "{{ downloads_dir }}/elgg-{{ elgg_version }}.zip"
- name: Download {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip to {{ downloads_dir }}
#shell: wget {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip -c -P {{ downloads_dir }}
#args:
# creates: "{{ downloads_dir }}/elgg-{{ elgg_version }}.zip"
get_url:
url: "{{ iiab_download_url }}/elgg-{{ elgg_version }}.zip"
dest: "{{ downloads_dir }}"
timeout: "{{ download_timeout }}"
when: internet_available
- name: Determine if software is already expanded
- name: Check for existence of /opt/elgg-{{ elgg_version }}/index.php
stat:
path: "/opt/elgg-{{ elgg_version }}/index.php"
register: elgg
# use unzip and shell until unarchive works again
# unarchive: dest=/opt/
# src={{ downloads_dir }}/elgg-{{ elgg_version }}.zip
- name: Expand it to our location unless already done
shell: "/usr/bin/unzip -o {{ downloads_dir }}/elgg-{{ elgg_version }}.zip -d /opt"
- name: Unpack (unarchive) .zip to /opt, if above index.php doesn't exist
#shell: "/usr/bin/unzip -o {{ downloads_dir }}/elgg-{{ elgg_version }}.zip -d /opt"
unarchive:
#remote_src: yes
#src: "{{ iiab_download_url }}/elgg-{{ elgg_version }}.zip"
src: "{{ downloads_dir }}/elgg-{{ elgg_version }}.zip"
dest: /opt
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
when: elgg.stat.exists is defined and not elgg.stat.exists
- name: Create a link to the versioned elgg-* folder
- name: Create softlink from /opt/elgg to /opt/elgg-{{ elgg_version }}
file:
src: "./elgg-{{ elgg_version }}"
dest: /opt/elgg
path: /opt/elgg
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
state: link
force: true
# Use template to fix up settings in elgg-config/settings.php with our variables substituted.
# Note this will overwrite any manual settings.
- name: Substitute our parameters in /opt/elgg/elgg-config/settings.php
- name: 'Install /opt/elgg/elgg-config/settings.php from template (WARNING: overwrites manual settings!)'
template:
src: "settings.php.j2"
dest: "/opt/{{ elgg_xx }}/elgg-config/settings.php"
@ -39,7 +44,7 @@
group: "{{ apache_user }}"
# The name of this file changed from 1.9 to 1.10.
- name: Copy default .htaccess to the root directory of Elgg tree
- name: Copy default .htaccess into /opt/{{ elgg_xx }}, root of Elgg tree
copy:
src: "/opt/{{ elgg_xx }}/vendor/elgg/elgg/install/config/htaccess.dist"
dest: "/opt/{{ elgg_xx }}/.htaccess"
@ -48,28 +53,22 @@
group: "{{ apache_user }}"
#regexp='^#RewriteBase'
- name: Modify .htaccess to have RewriteBase as our directory
- name: Change .htaccess to include RewriteBase for http://box/elgg
lineinfile:
backup: no
dest: "/opt/{{ elgg_xx }}/.htaccess"
path: "/opt/{{ elgg_xx }}/.htaccess"
state: present
insertafter: '^#RewriteBase'
line: "RewriteBase {{ elgg_url }}/"
- name: Change permissions on engine directory so Apache can write
- name: Set /opt/elgg/engine directory permissions to 0755 so Apache can write there
file:
path: /opt/elgg/engine/
owner: "{{ apache_user }}"
mode: 0755
state: directory
- name: Create an upload directory that Apache can write in or Elgg
file:
path: "{{ elgg_upload_path }}"
state: directory
owner: "{{ apache_user }}"
- name: Change ownership
- name: Change /opt/elgg-{{ elgg_version }} ownership to {{ apache_user }}:{{ apache_user }} (likely not nec, as unarchive & all do this above)
file:
path: "/opt/elgg-{{ elgg_version }}"
owner: "{{ apache_user }}"
@ -77,12 +76,18 @@
recurse: yes
state: directory
- name: Create a MySQL database for Elgg - can be run more than once
- name: Create upload directory {{ elgg_upload_path }} that Apache (and Elgg) can write to
file:
path: "{{ elgg_upload_path }}"
state: directory
owner: "{{ apache_user }}"
- name: Create Elgg's MySQL database {{ dbname }}, to be populated below - can be run more than once
mysql_db:
name: "{{ dbname }}"
register: create_elgg_database
- name: Create a user to access the Elgg database - can be run more than once
- name: Create user/password to access Elgg database - can be run more than once
mysql_user:
name: "{{ dbuser }}"
host: "{{ item }}"
@ -93,7 +98,7 @@
- ::1
- localhost
- name: Create file to load database
- name: Create /tmp/elggdb.sql from template, to load database
template:
src: "elggdb.sql.j2"
dest: "/tmp/elggdb.sql"
@ -102,42 +107,47 @@
# tar up a mysqldump of freshly installed database and use it in the install to avoid the startup
# form, which worries me a lot. (/var/lib/mysql/elggdb)
- name: Load Elgg database dump
- name: Populate Elgg's MySQL database {{ dbname }}, from /tmp/elggdb.sql
mysql_db:
name: "{{ dbname }}"
state: import
target: /tmp/elggdb.sql
when: create_elgg_database.changed
- name: Remove database dump after load
- name: Remove database dump /tmp/elggdb.sql
file:
name: /tmp/elggdb.sql
state: absent
- name: Install config file for Elgg in Apache
- name: Install Apache's elgg.conf from template, for http://box/elgg
template:
src: elgg.conf
dest: "/etc/{{ apache_config_dir }}/elgg.conf"
- name: Enable Elgg for debuntu (will already be enabled above for redhat)
- name: Create symlink elgg.conf from sites-enabled to sites-available (debuntu, not nec for redhat)
file:
src: /etc/apache2/sites-available/elgg.conf
dest: /etc/apache2/sites-enabled/elgg.conf
path: /etc/apache2/sites-enabled/elgg.conf
state: link
when: elgg_enabled and is_debuntu
- name: Disable Elgg - remove config file for Elgg in Apache (debuntu)
- name: Remove symlink elgg.conf from sites-enabled (debuntu)
file:
path: /etc/apache2/sites-enabled/elgg.conf
state: absent
when: not elgg_enabled and is_debuntu
- name: Disable Elgg - remove config file for Elgg in Apache (redhat)
- name: Remove Apache's elgg.conf (redhat)
file:
dest: "/etc/{{ apache_config_dir }}/elgg.conf"
state: absent
when: not elgg_enabled and is_redhat
- name: Restart Apache, to enable/disable http://box/elgg
service:
name: "{{ apache_service }}"
state: restarted
- name: Add 'elgg' to list of services at {{ iiab_ini_file }}
ini_file:
dest: "{{ iiab_ini_file }}"
@ -153,8 +163,3 @@
value: /opt/elgg
- option: enabled
value: "{{ elgg_enabled }}"
- name: Restart Apache, so it picks up the new aliases
service:
name: "{{ apache_service }}"
state: restarted

View file

@ -215,7 +215,7 @@
tags:
- base
- name: Install /usr/bin/iiab-refresh-wiki-docs (scraper script) to create http://box/info offline documentation (will be run at the end of Stage 4 = roles/4-server-options/tasks/main.yml)
- name: Install /usr/bin/iiab-refresh-wiki-docs (scraper script) to create http://box/info offline documentation. (This script will run at the end of Stage 4 = roles/4-server-options/tasks/main.yml)
template:
src: refresh-wiki-docs.sh
dest: /usr/bin/iiab-refresh-wiki-docs

View file

@ -7,7 +7,7 @@ nextcloud_force_install: False
nextcloud_url: /nextcloud
nextcloud_prefix: /opt
nextcloud_data_dir: "{{ content_base }}/nextcloud/data"
nextcloud_dl_url: https://download.nextcloud.com/server/releases/
nextcloud_dl_url: https://download.nextcloud.com/server/releases
nextcloud_orig_src_file: latest-14.tar.bz2
nextcloud_src_file: nextcloud_{{ nextcloud_orig_src_file }}

View file

@ -1,28 +1,29 @@
- 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:
# var: nextcloud_force_install
# - debug:
# 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
@ -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 with name: {{ 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 }}"

View file

@ -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
@ -34,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 }}"
@ -44,39 +49,55 @@
- 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=*
become: true
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"
- 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 }}'
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 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: >
# 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: >
# 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:

View file

@ -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

View file

@ -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)