1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/elgg/tasks/main.yml

166 lines
5.3 KiB
YAML
Raw Normal View History

# Assume we only get here if elgg_install: True
2018-10-28 20:02:19 +00:00
# Assume MySQL is running
2018-10-28 22:02:17 +00:00
- name: Download {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip to {{ downloads_dir }}
2018-10-28 20:02:19 +00:00
#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
2017-05-27 18:09:50 +00:00
2018-10-28 22:02:17 +00:00
- name: Check for existence of /opt/elgg-{{ elgg_version }}/index.php
2017-12-08 11:49:41 +00:00
stat:
path: "/opt/elgg-{{ elgg_version }}/index.php"
2017-05-27 18:09:50 +00:00
register: elgg
2018-10-28 22:11:42 +00:00
- name: Unpack (unarchive) .zip to /opt, if above index.php doesn't exist
2018-10-28 20:02:19 +00:00
#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 }}"
2017-05-27 18:09:50 +00:00
when: elgg.stat.exists is defined and not elgg.stat.exists
2018-10-28 22:02:17 +00:00
- name: Create softlink from /opt/elgg to /opt/elgg-{{ elgg_version }}
2017-12-08 11:49:41 +00:00
file:
src: "./elgg-{{ elgg_version }}"
2018-10-28 22:02:17 +00:00
path: /opt/elgg
2017-12-08 11:49:41 +00:00
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
state: link
force: true
2017-05-27 18:09:50 +00:00
2018-10-28 20:07:25 +00:00
- name: 'Install /opt/elgg/elgg-config/settings.php from template (WARNING: overwrites manual settings!)'
2017-12-08 11:49:41 +00:00
template:
src: "settings.php.j2"
dest: "/opt/{{ elgg_xx }}/elgg-config/settings.php"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
2017-09-23 18:58:09 +00:00
# The name of this file changed from 1.9 to 1.10.
2018-10-28 22:02:17 +00:00
- name: Copy default .htaccess into /opt/{{ elgg_xx }}, root of Elgg tree
2017-12-08 11:49:41 +00:00
copy:
src: "/opt/{{ elgg_xx }}/vendor/elgg/elgg/install/config/htaccess.dist"
dest: "/opt/{{ elgg_xx }}/.htaccess"
mode: 0644
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
2017-09-23 18:58:09 +00:00
#regexp='^#RewriteBase'
2018-10-28 22:02:17 +00:00
- name: Change .htaccess to include RewriteBase for http://box/elgg
2017-12-08 11:49:41 +00:00
lineinfile:
backup: no
2018-10-28 22:02:17 +00:00
path: "/opt/{{ elgg_xx }}/.htaccess"
2017-12-08 11:49:41 +00:00
state: present
insertafter: '^#RewriteBase'
line: "RewriteBase {{ elgg_url }}/"
2017-09-23 18:58:09 +00:00
2018-10-28 22:02:17 +00:00
- name: Set /opt/elgg/engine directory permissions to 0755 so Apache can write there
2017-12-08 11:49:41 +00:00
file:
path: /opt/elgg/engine/
owner: "{{ apache_user }}"
mode: 0755
state: directory
2017-09-23 18:58:09 +00:00
2018-10-28 22:02:17 +00:00
- name: Change /opt/elgg-{{ elgg_version }} ownership to {{ apache_user }}:{{ apache_user }} (likely not nec, as unarchive & all do this above)
2017-12-08 11:49:41 +00:00
file:
path: "/opt/elgg-{{ elgg_version }}"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
recurse: yes
state: directory
2017-09-23 18:58:09 +00:00
2018-10-28 22:02:17 +00:00
- name: Create upload directory {{ elgg_upload_path }} that Apache (and Elgg) can write to
file:
path: "{{ elgg_upload_path }}"
state: directory
owner: "{{ apache_user }}"
2018-10-28 22:06:01 +00:00
- name: Create Elgg's MySQL database {{ dbname }}, to be populated below - can be run more than once
2017-12-08 11:49:41 +00:00
mysql_db:
name: "{{ dbname }}"
register: create_elgg_database
2017-09-23 18:58:09 +00:00
2018-10-28 20:02:19 +00:00
- name: Create user/password to access Elgg database - can be run more than once
2017-12-08 11:49:41 +00:00
mysql_user:
name: "{{ dbuser }}"
host: "{{ item }}"
password: "{{ dbpassword }}"
priv: "{{ dbname }}.*:ALL"
2017-09-23 18:58:09 +00:00
with_items:
2018-08-07 00:18:33 +00:00
- 127.0.0.1
- ::1
- localhost
2017-05-27 18:09:50 +00:00
2018-10-28 20:02:19 +00:00
- name: Create /tmp/elggdb.sql from template, to load database
2017-12-08 11:49:41 +00:00
template:
src: "elggdb.sql.j2"
dest: "/tmp/elggdb.sql"
2017-05-27 18:09:50 +00:00
# elggdb.sql obtained with mysqldump --skip-add-drop-table elggdb > elggdb.sql
# 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)
2017-05-27 18:09:50 +00:00
2018-10-28 22:02:17 +00:00
- name: Populate Elgg's MySQL database {{ dbname }}, from /tmp/elggdb.sql
2017-12-08 11:49:41 +00:00
mysql_db:
name: "{{ dbname }}"
state: import
target: /tmp/elggdb.sql
when: create_elgg_database.changed
2017-05-27 18:09:50 +00:00
2018-10-28 20:02:19 +00:00
- name: Remove database dump /tmp/elggdb.sql
2017-12-08 11:49:41 +00:00
file:
name: /tmp/elggdb.sql
state: absent
2017-05-27 18:09:50 +00:00
2018-10-31 06:54:00 +00:00
- name: Install /etc/{{ apache_config_dir }}/elgg.conf from template, for http://box/elgg
2017-12-08 11:49:41 +00:00
template:
src: elgg.conf
dest: "/etc/{{ apache_config_dir }}/elgg.conf"
2017-05-27 18:09:50 +00:00
2018-10-28 20:02:19 +00:00
- name: Create symlink elgg.conf from sites-enabled to sites-available (debuntu, not nec for redhat)
2017-12-08 11:49:41 +00:00
file:
src: /etc/apache2/sites-available/elgg.conf
2018-10-28 20:02:19 +00:00
path: /etc/apache2/sites-enabled/elgg.conf
2017-12-08 11:49:41 +00:00
state: link
2017-05-27 23:10:45 +00:00
when: elgg_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2018-10-31 06:54:00 +00:00
- name: Remove symlink /etc/apache2/sites-enabled/elgg.conf (debuntu)
2017-12-08 11:49:41 +00:00
file:
path: /etc/apache2/sites-enabled/elgg.conf
state: absent
2017-05-27 23:10:45 +00:00
when: not elgg_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2018-10-28 20:02:19 +00:00
- name: Remove Apache's elgg.conf (redhat)
2017-12-08 11:49:41 +00:00
file:
dest: "/etc/{{ apache_config_dir }}/elgg.conf"
state: absent
when: not elgg_enabled and is_redhat
2018-10-31 08:40:58 +00:00
- name: Restart Apache ({{ apache_service }}) to enable/disable http://box/elgg
2018-10-28 20:02:19 +00:00
service:
name: "{{ apache_service }}"
state: restarted
2018-10-31 06:54:00 +00:00
- name: Add 'elgg' variable values to {{ iiab_ini_file }}
2017-12-08 11:49:41 +00:00
ini_file:
2018-10-31 06:54:00 +00:00
path: "{{ iiab_ini_file }}"
2017-12-08 12:00:54 +00:00
section: elgg
2017-12-08 11:49:41 +00:00
option: "{{ item.option }}"
2017-12-08 12:00:54 +00:00
value: "{{ item.value }}"
2017-05-27 18:09:50 +00:00
with_items:
- option: name
2017-12-08 11:49:41 +00:00
value: Elgg
2017-05-27 18:09:50 +00:00
- option: description
value: '"Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications."'
2017-05-27 18:09:50 +00:00
- option: path
value: /opt/elgg
- option: enabled
value: "{{ elgg_enabled }}"