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

150 lines
4.1 KiB
YAML
Raw Normal View History

2017-05-27 18:09:50 +00:00
---
2017-10-27 14:16:05 +00:00
- name: Install Moodle required packages
2017-05-27 18:09:50 +00:00
package: name={{ item }}
state=present
with_items:
- python-psycopg2
- php-pgsql
2017-05-27 23:10:45 +00:00
when: not is_debuntu
2017-05-27 18:09:50 +00:00
2017-10-27 14:16:05 +00:00
- name: Install Moodle required packages
2017-05-27 18:09:50 +00:00
package: name={{ item }}
state=present
with_items:
- python-psycopg2
2017-05-27 23:10:45 +00:00
- php{{ php_version }}-pgsql
2017-05-27 23:40:12 +00:00
- php{{ php_version }}-curl
# - php{{ php_version }}-zip
2017-05-27 23:40:12 +00:00
- php{{ php_version }}-gd
# - php{{ php_version }}-mbstring
# mbstring is now included in php-cli
- php{{ php_version }}-cli
2017-05-27 23:10:45 +00:00
when: is_debuntu
2017-05-27 18:09:50 +00:00
- name: php-zip name for Debian 9 or Ubuntu
package: name=php{{ php_version }}-zip
when: is_debian_9 or is_ubuntu
- name: php-zip name for Debian 8
package: name=php-pclzip
when: is_debian_8
2017-10-27 14:16:05 +00:00
- name: Determine if Moodle is already downloaded
2017-05-27 18:09:50 +00:00
stat: path={{ moodle_base }}/config-dist.php
register: moodle
2017-10-27 14:16:05 +00:00
- name: Download the latest Moodle repo
2017-05-27 18:09:50 +00:00
git: repo={{ moodle_repo_url }}
dest={{ moodle_base }}
depth=1
force=yes
version="MOODLE_{{ moodle_version }}_STABLE"
# ignore_errors: yes
when: internet_available and moodle.stat.exists is defined and not moodle.stat.exists
2017-05-27 18:09:50 +00:00
2017-10-27 14:16:05 +00:00
- name: Prepare the downloaded directory so Apache can install config file
2017-05-27 18:09:50 +00:00
file: path={{ moodle_base }}
owner={{ apache_user }}
2017-05-27 18:09:50 +00:00
recurse=yes
state=directory
2017-10-27 14:16:05 +00:00
- name: Give Apache permission to write Moodle data directory
2017-05-27 18:09:50 +00:00
file: path={{ content_base }}/dbdata/moodle
owner={{ apache_user }}
2017-05-27 18:09:50 +00:00
mode=0755
state=directory
2017-10-27 14:16:05 +00:00
- name: Create a Moodle data dir with Apache permission to write
2017-05-27 18:09:50 +00:00
file: path={{ moodle_data }}
owner={{ apache_user }}
group={{ apache_user }}
2017-05-27 18:09:50 +00:00
mode=0770
state=directory
2017-10-27 14:16:05 +00:00
- name: Remove stock Moodle conf
2017-05-27 18:09:50 +00:00
file: path='/etc/{{ apache_config_dir }}/moodle.conf'
state=absent
2017-10-27 14:16:05 +00:00
- name: Put Moodle config file in place
2017-05-27 18:09:50 +00:00
template: src=022-moodle.j2
dest=/etc/{{ apache_config_dir }}/022-moodle.conf
owner=root
group=root
mode=0644
when: moodle_enabled
2017-10-27 14:16:05 +00:00
- name: Enable Moodle
2017-05-27 18:09:50 +00:00
file: path=/etc/apache2/sites-enabled/022-moodle.conf
src=/etc/apache2/sites-available/022-moodle.conf
state=link
when: moodle_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2017-10-27 14:16:05 +00:00
- name: Disable Moodle
2017-05-27 18:09:50 +00:00
file: path=/etc/apache2/sites-enabled/022-moodle.conf
state=absent
2017-05-27 23:10:45 +00:00
when: not moodle_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
- name: Start postgresql-iiab
service: name=postgresql-iiab
2017-05-27 18:09:50 +00:00
state=restarted
- name: Create db user
postgresql_user: name=Admin
password=changeme
role_attr_flags=NOSUPERUSER,NOCREATEROLE,NOCREATEDB
state=present
become: yes
become_user: postgres
- name: Create database
postgresql_db: name=moodle
encoding=utf8
owner=Admin
template=template1
state=present
become: yes
become_user: postgres
- name: Put a startup install script in place
template: dest={{ moodle_base }}
2017-05-27 18:09:50 +00:00
src=moodle_installer
mode=0755
- name: Restart postgresql-iiab
service: name=postgresql-iiab
2017-05-27 18:09:50 +00:00
state=restarted
enabled=yes
when: moodle_enabled
2017-10-27 14:16:05 +00:00
- name: Restart Apache
2017-05-27 18:09:50 +00:00
service: name={{ apache_service }}
state=restarted
2017-10-27 14:16:05 +00:00
- name: See if the config.php file exists
2017-05-27 18:09:50 +00:00
stat: path='{{ moodle_base }}/config.php'
register: config
2017-10-27 14:16:05 +00:00
- name: Execute Moodle startup script
2017-05-27 18:09:50 +00:00
shell: '{{ moodle_base }}/moodle_installer'
when: config.stat.exists is defined and not config.stat.exists
2017-10-27 14:16:05 +00:00
- name: Give Apache permission to read config file
# command: chown -R {{ apache_user }} {{ moodle_base }}
2017-05-27 18:09:50 +00:00
file: path={{ moodle_base }}/config.php
mode=0644
2017-10-27 14:16:05 +00:00
- name: Add Moodle to service list
2017-05-27 18:09:50 +00:00
ini_file: dest='{{ service_filelist }}'
section=moodle
option='{{ item.option }}'
value='{{ item.value }}'
with_items:
- option: name
value: Moodle
- option: description
value: '"Access the Moodle learning management system."'
- option: 'directory path'
value: '{{ moodle_base }}'
- option: moodle_enabled
value: "{{ moodle_enabled }}"