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

131 lines
4.7 KiB
YAML
Raw Normal View History

# Assume we only get here if elgg_install: True
# Assume mysql is running
2017-05-27 18:09:50 +00:00
- name: download current version from our copy
shell: wget {{ iiab_download_url }}/elgg-{{ elgg_version }}.zip -c -P {{ downloads_dir }}
2017-09-24 15:15:16 +00:00
creates={{ downloads_dir }}/elgg-{{ elgg_version }}.zip
when: internet_available
2017-05-27 18:09:50 +00:00
- name: Determine if software is already expanded
2017-09-24 20:30:02 +00:00
stat: path=/opt/elgg-{{ elgg_version }}/index.php
2017-05-27 18:09:50 +00:00
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
2017-05-27 18:09:50 +00:00
shell: "/usr/bin/unzip -o {{ downloads_dir }}/elgg-{{ elgg_version }}.zip -d /opt"
when: elgg.stat.exists is defined and not elgg.stat.exists
- name: Create a link to the versioned elgg folder
file: src=./elgg-{{ elgg_version }}
dest=/opt/elgg
2017-09-23 18:58:09 +00:00
owner={{ apache_user }}
group={{ apache_user }}
2017-05-27 18:09:50 +00:00
state=link
force=true
2017-09-23 18:58:09 +00:00
# use template to fix up settings in engine/settings.php with our variables substituted
# into engine/settings.example.php
# note this will overwrite any manual settings
2017-09-23 18:58:09 +00:00
- name: Substitute our parameters in engine/settings.example.php
template: src="settings.php.j2"
dest="/opt/{{ elgg_xx }}/elgg-config/settings.php"
owner={{ apache_user }}
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
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 }}
#regexp='^#RewriteBase'
- name: Modify .htaccess to have RewriteBase as our directory
lineinfile: backup=no
dest="/opt/{{ elgg_xx }}/.htaccess"
state=present
insertafter='^#RewriteBase'
line="RewriteBase {{ elgg_url }}/"
- name: Change permissions on engine directory so apache can write
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
file: path=/opt/elgg-{{ elgg_version }}
owner={{ apache_user }}
group={{ apache_user }}
recurse=yes
state=directory
- name: Create a mysql database for elgg - can be run more than once
mysql_db: name={{ dbname }}
register: create_elgg_database
2017-09-23 18:58:09 +00:00
- name: Create a user to access the elgg database - can be run more than once
mysql_user: name={{ dbuser }} host={{ item }} password={{ dbpassword }} priv={{ dbname }}.*:ALL
2017-09-23 18:58:09 +00:00
with_items:
- 127.0.0.1
- ::1
- localhost
2017-05-27 18:09:50 +00:00
- name: Create file to load database
template: src=elggdb.sql.j2
dest=/tmp/elggdb.sql
# 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
- name: Load elgg database dump
mysql_db: name={{ dbname }}
state=import
target=/tmp/elggdb.sql
when: create_elgg_database.changed
2017-05-27 18:09:50 +00:00
- name: Remove database dump after load
file: name=/tmp/elggdb.sql state=absent
- name: Install config file for elgg in Apache
template: src=elgg.conf dest=/etc/{{ apache_config_dir }}/elgg.conf
- name: Enable elgg for debuntu (will already be enabled above for Redhat)
2017-05-27 18:09:50 +00:00
file: path=/etc/apache2/sites-enabled/elgg.conf
src=/etc/apache2/sites-available/elgg.conf
state=link
2017-05-27 23:10:45 +00:00
when: elgg_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
- name: Disable elgg for debuntu
2017-05-27 18:09:50 +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
- name: Disable elgg for Redhat - remove config file for elgg in Apache
file: dest=/etc/{{ apache_config_dir }}/elgg.conf
state=absent
when: not elgg_enabled and is_redhat
2017-05-27 18:09:50 +00:00
- name: add elgg to service list
ini_file: dest='{{ service_filelist }}'
section=elgg
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- option: name
value: elgg-social-netwoking
- 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"'
- option: path
value: /opt/elgg
- option: enabled
value: "{{ elgg_enabled }}"
- name: Restart apache, so it picks up the new aliases
service: name={{ apache_service }} state=restarted