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

170 lines
4.8 KiB
YAML
Raw Normal View History

2019-02-03 00:31:36 +00:00
- name: "Install packages: python-psycopg2, php-pgsql (OS's other than debuntu)"
2017-12-08 09:43:40 +00:00
package:
2018-10-28 17:40:23 +00:00
name:
- python-psycopg2
- php-pgsql
2018-10-28 18:50:37 +00:00
state: present
2017-05-27 23:10:45 +00:00
when: not is_debuntu
2017-05-27 18:09:50 +00:00
2019-10-31 15:23:13 +00:00
- name: Install 4 php packages (debuntu)
2017-12-08 09:43:40 +00:00
package:
2018-10-28 17:40:23 +00:00
name:
- php{{ php_version }}-pgsql
- php{{ php_version }}-curl
#- php{{ php_version }}-zip
- php{{ php_version }}-gd
#- php{{ php_version }}-mbstring
# mbstring is now included in php-cli
- php{{ php_version }}-cli
2017-12-08 09:43:40 +00:00
state: present
when: is_debuntu | bool
2017-05-27 18:09:50 +00:00
2019-02-03 00:31:36 +00:00
- name: "Install package: php{{ php_version }}-zip (ubuntu or debian-9+)"
2017-12-08 09:43:40 +00:00
package:
name: "php{{ php_version }}-zip"
2019-02-03 00:31:36 +00:00
when: is_ubuntu or (is_debian and not is_debian_8)
2019-02-03 00:31:36 +00:00
- name: "Install package: php-pclzip (debian-8)"
2017-12-08 09:43:40 +00:00
package:
name: php-pclzip
when: is_debian_8 | bool
2017-10-27 14:16:05 +00:00
- name: Determine if Moodle is already downloaded
2017-12-08 09:43:40 +00:00
stat:
path: "{{ moodle_base }}/config-dist.php"
2017-05-27 18:09:50 +00:00
register: moodle
2017-10-27 14:16:05 +00:00
- name: Download the latest Moodle repo
2017-12-08 09:43:40 +00:00
git:
repo: "{{ moodle_repo_url }}"
dest: "{{ moodle_base }}"
depth: 1
force: yes
2018-05-14 14:03:37 +00:00
version: "MOODLE_{{ moodle_version }}_STABLE"
#version: master # TEMPORARY DURING MAY 2018 TESTING, installed 3.5beta+ = https://download.moodle.org/releases/development/
2018-05-01 14:50:00 +00:00
#ignore_errors: yes
2017-12-08 09:43:40 +00:00
when: internet_available and moodle.stat.exists is defined and not moodle.stat.exists
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Create dir {{ moodle_base }} owned by {{ apache_user }} (for config file?)
2017-12-08 09:43:40 +00:00
file:
path: "{{ moodle_base }}"
owner: "{{ apache_user }}"
recurse: yes
state: directory
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Create dir {{ content_base }}/dbdata/moodle owned by {{ apache_user }} with write permission 0755
2017-12-08 09:43:40 +00:00
file:
path: "{{ content_base }}/dbdata/moodle"
owner: "{{ apache_user }}"
mode: 0755
state: directory
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Create dir {{ moodle_data }} owned by {{ apache_user }}:{{ apache_user }} with write permission 0770 # /library/moodle
2017-12-08 09:43:40 +00:00
file:
path: "{{ moodle_data }}"
owner: "{{ apache_user }}"
group: "{{ apache_user }}"
mode: 0770
state: directory
2017-05-27 18:09:50 +00:00
2018-10-28 17:40:23 +00:00
- name: Remove Apache's stock moodle.conf
2017-12-08 09:43:40 +00:00
file:
path: "/etc/{{ apache_config_dir }}/moodle.conf"
state: absent
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Install Apache's 022-moodle.conf from template, if moodle_enabled
2017-12-08 09:43:40 +00:00
template:
src: 022-moodle.j2
dest: "/etc/{{ apache_config_dir }}/022-moodle.conf"
owner: root
group: root
mode: 0644
when: moodle_enabled | bool
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Create symlink 022-moodle.conf from sites-enabled to sites-available, if moodle_enabled (debuntu)
2017-12-08 09:43:40 +00:00
file:
src: /etc/apache2/sites-available/022-moodle.conf
dest: /etc/apache2/sites-enabled/022-moodle.conf
state: link
when: moodle_enabled and is_debuntu
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Remove symlink 022-moodle.conf, if not moodle_enabled (debuntu)
2017-12-08 09:43:40 +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
2018-10-31 07:10:26 +00:00
- name: Restart postgresql-iiab
2017-12-08 09:43:40 +00:00
service:
name: postgresql-iiab
state: restarted
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Create PostgreSQL db user Admin/changeme
2017-12-08 09:43:40 +00:00
postgresql_user:
name: Admin
password: changeme
2018-04-30 21:05:30 +00:00
encrypted: yes # Required by PostgreSQL 10+ e.g. Ubuntu 18.04's PostgreSQL 10.3+, see https://github.com/iiab/iiab/issues/759
2017-12-08 09:43:40 +00:00
role_attr_flags: NOSUPERUSER,NOCREATEROLE,NOCREATEDB
state: present
2017-05-27 18:09:50 +00:00
become: yes
become_user: postgres
2018-10-31 07:10:26 +00:00
- name: 'Create database: {{ moodle_database_name }}'
2017-12-08 09:43:40 +00:00
postgresql_db:
2018-04-30 22:44:30 +00:00
name: "{{ moodle_database_name }}"
2017-12-08 09:43:40 +00:00
encoding: utf8
owner: Admin
template: template1
state: present
2017-05-27 18:09:50 +00:00
become: yes
become_user: postgres
2018-10-31 07:10:26 +00:00
- name: Install {{ moodle_base }}/moodle_installer from template
2017-12-08 09:43:40 +00:00
template:
src: moodle_installer
2018-10-31 07:10:26 +00:00
dest: "{{ moodle_base }}"
2017-12-08 09:43:40 +00:00
mode: 0755
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Enable & Restart postgresql-iiab
2017-12-08 09:43:40 +00:00
service:
name: postgresql-iiab
state: restarted
enabled: yes
when: moodle_enabled | bool
2017-05-27 18:09:50 +00:00
2019-02-03 01:14:46 +00:00
- name: Restart Apache service ({{ apache_service }})
2017-12-08 09:43:40 +00:00
service:
name: "{{ apache_service }}"
state: restarted
2017-05-27 18:09:50 +00:00
2018-10-31 07:10:26 +00:00
- name: Does {{ moodle_base }}/config.php exist?
2017-12-08 09:43:40 +00:00
stat:
path: "{{ moodle_base }}/config.php"
2017-05-27 18:09:50 +00:00
register: config
2018-10-31 07:10:26 +00:00
- name: Execute {{ moodle_base }}/moodle_installer
2018-10-31 08:06:45 +00:00
shell: "{{ moodle_base }}/moodle_installer"
2017-05-27 18:09:50 +00:00
when: config.stat.exists is defined and not config.stat.exists
2018-10-31 07:10:26 +00:00
- name: Give read permission 0644 to {{ moodle_base }}/config.php # /opt/iiab/moodle/config.php
2018-05-01 14:50:00 +00:00
#command: chown -R {{ apache_user }} {{ moodle_base }}
2017-12-08 09:43:40 +00:00
file:
path: "{{ moodle_base }}/config.php"
mode: 0644
2018-10-31 07:10:26 +00:00
- name: Add 'moodle' variable values to {{ iiab_ini_file }}
2017-12-08 09:43:40 +00:00
ini_file:
2018-10-31 07:10:26 +00:00
path: "{{ iiab_ini_file }}"
2017-12-08 09:43:40 +00:00
section: moodle
option: "{{ item.option }}"
value: "{{ item.value }}"
2017-05-27 18:09:50 +00:00
with_items:
- option: name
value: Moodle
- option: description
value: '"Access the Moodle learning management system."'
2017-12-08 10:37:08 +00:00
- option: "moodle_base"
2017-12-08 09:43:40 +00:00
value: "{{ moodle_base }}"
2017-05-27 18:09:50 +00:00
- option: moodle_enabled
value: "{{ moodle_enabled }}"