2020-05-16 21:51:56 +00:00
|
|
|
- name: "Set 'apache_install: True' and 'apache_enabled: True'"
|
|
|
|
set_fact:
|
|
|
|
apache_install: True
|
|
|
|
apache_enabled: True
|
|
|
|
|
|
|
|
- name: APACHE - run 'httpd' role
|
|
|
|
include_role:
|
|
|
|
name: httpd
|
|
|
|
|
|
|
|
|
2020-01-30 14:56:37 +00:00
|
|
|
- name: "Set 'postgresql_install: True' and 'postgresql_enabled: True'"
|
2020-01-05 03:38:54 +00:00
|
|
|
set_fact:
|
|
|
|
postgresql_install: True
|
|
|
|
postgresql_enabled: True
|
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: POSTGRESQL - run 'postgresql' role (attempt to install & enable PostgreSQL)
|
2020-01-05 03:38:54 +00:00
|
|
|
include_role:
|
|
|
|
name: postgresql
|
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
|
2020-12-04 01:57:00 +00:00
|
|
|
- name: Install 8 php packages (debuntu)
|
2019-09-05 05:45:31 +00:00
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- php{{ php_version }}-pgsql
|
|
|
|
- php{{ php_version }}-curl
|
2020-06-15 18:12:35 +00:00
|
|
|
- php{{ php_version }}-zip
|
2019-09-05 05:45:31 +00:00
|
|
|
- php{{ php_version }}-gd
|
2020-12-04 01:57:00 +00:00
|
|
|
- php{{ php_version }}-mbstring # 2020-06-15: Required by Moodle 3.9+
|
2020-12-04 01:49:22 +00:00
|
|
|
- php{{ php_version }}-cli # 2020-06-15: In the past this included (above) mbstring? However this is not true on Ubuntu Server 20.04 LTS.
|
2020-12-04 01:57:00 +00:00
|
|
|
- php{{ php_version }}-intl # 2020-12-03: Required by Moodle 3.10+
|
|
|
|
- php{{ php_version }}-soap # 2020-12-03: Recommended by Moodle 3.10+
|
2019-09-05 05:45:31 +00:00
|
|
|
state: present
|
2020-10-16 20:46:19 +00:00
|
|
|
when: is_debuntu
|
2019-09-05 05:45:31 +00:00
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: Does {{ moodle_base }}/config-dist.php exist? (indicating Moodle is/was installed)
|
2019-09-05 05:45:31 +00:00
|
|
|
stat:
|
2021-02-01 16:12:21 +00:00
|
|
|
path: "{{ moodle_base }}/config-dist.php" # /opt/iiab/moodle
|
2019-09-05 05:45:31 +00:00
|
|
|
register: moodle
|
|
|
|
|
2021-02-01 16:12:21 +00:00
|
|
|
- name: Clone (i.e. use git to download) {{ moodle_repo_url }} to {{ moodle_base }} (~300 MB)
|
2019-09-05 05:45:31 +00:00
|
|
|
git:
|
|
|
|
repo: "{{ moodle_repo_url }}"
|
|
|
|
dest: "{{ moodle_base }}"
|
|
|
|
depth: 1
|
|
|
|
force: yes
|
|
|
|
version: "MOODLE_{{ moodle_version }}_STABLE"
|
|
|
|
#version: master # TEMPORARY DURING MAY 2018 TESTING, installed 3.5beta+ = https://download.moodle.org/releases/development/
|
|
|
|
#ignore_errors: yes
|
|
|
|
when: internet_available and moodle.stat.exists is defined and not moodle.stat.exists
|
|
|
|
|
|
|
|
- name: Create dir {{ moodle_base }} owned by {{ apache_user }} (for config file?)
|
|
|
|
file:
|
2020-02-04 20:03:59 +00:00
|
|
|
state: directory
|
2019-09-05 05:45:31 +00:00
|
|
|
path: "{{ moodle_base }}"
|
|
|
|
owner: "{{ apache_user }}"
|
|
|
|
recurse: yes
|
|
|
|
|
2020-01-12 17:12:49 +00:00
|
|
|
- name: Create dir {{ content_base }}/dbdata/moodle owned by {{ apache_user }}
|
2019-09-05 05:45:31 +00:00
|
|
|
file:
|
2020-02-04 20:03:59 +00:00
|
|
|
state: directory
|
2019-09-05 05:45:31 +00:00
|
|
|
path: "{{ content_base }}/dbdata/moodle"
|
|
|
|
owner: "{{ apache_user }}"
|
|
|
|
|
2021-02-01 16:12:21 +00:00
|
|
|
- name: Create dir {{ moodle_data }} ({{ apache_user }}:{{ apache_user }}, '0770')
|
2019-09-05 05:45:31 +00:00
|
|
|
file:
|
2020-02-04 20:03:59 +00:00
|
|
|
state: directory
|
2021-02-01 16:12:21 +00:00
|
|
|
path: "{{ moodle_data }}" # /library/moodle
|
2019-09-05 05:45:31 +00:00
|
|
|
owner: "{{ apache_user }}"
|
|
|
|
group: "{{ apache_user }}"
|
2021-02-01 16:12:21 +00:00
|
|
|
#mode: '0770' # Regardless, permissions end up as: drwxrwsrwx
|
2019-09-05 05:45:31 +00:00
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: Remove stock /etc/{{ apache_conf_dir }}/moodle.conf
|
2019-09-05 05:45:31 +00:00
|
|
|
file:
|
2021-02-01 16:12:21 +00:00
|
|
|
path: "/etc/{{ apache_conf_dir }}/moodle.conf" # apache2/sites-available
|
2019-09-05 05:45:31 +00:00
|
|
|
state: absent
|
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: Install /etc/{{ apache_conf_dir }}/022-moodle.conf from template
|
2019-09-05 05:45:31 +00:00
|
|
|
template:
|
|
|
|
src: 022-moodle.j2
|
2020-01-30 09:00:00 +00:00
|
|
|
dest: "/etc/{{ apache_conf_dir }}/022-moodle.conf"
|
2019-09-05 05:45:31 +00:00
|
|
|
|
2021-02-01 16:12:21 +00:00
|
|
|
# roles/postgresql/templates/postgresql-iiab.service WAS INSTALLED HERE:
|
|
|
|
# /etc/systemd/system/postgresql-iiab.service
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: Start 'postgresql-iiab' systemd service, to configure Moodle's DB
|
|
|
|
systemd:
|
2019-09-05 05:45:31 +00:00
|
|
|
name: postgresql-iiab
|
2020-02-04 20:03:59 +00:00
|
|
|
state: started
|
2019-09-05 05:45:31 +00:00
|
|
|
|
|
|
|
- name: Create PostgreSQL db user Admin/changeme
|
|
|
|
postgresql_user:
|
|
|
|
name: Admin
|
|
|
|
password: changeme
|
|
|
|
encrypted: yes # Required by PostgreSQL 10+ e.g. Ubuntu 18.04's PostgreSQL 10.3+, see https://github.com/iiab/iiab/issues/759
|
|
|
|
role_attr_flags: NOSUPERUSER,NOCREATEROLE,NOCREATEDB
|
|
|
|
state: present
|
|
|
|
become: yes
|
|
|
|
become_user: postgres
|
|
|
|
|
|
|
|
- name: 'Create database: {{ moodle_database_name }}'
|
|
|
|
postgresql_db:
|
|
|
|
name: "{{ moodle_database_name }}"
|
|
|
|
encoding: utf8
|
|
|
|
owner: Admin
|
|
|
|
template: template1
|
|
|
|
state: present
|
|
|
|
become: yes
|
|
|
|
become_user: postgres
|
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: Install {{ moodle_base }}/moodle_installer from template ('0755')
|
2019-09-05 05:45:31 +00:00
|
|
|
template:
|
|
|
|
src: moodle_installer
|
|
|
|
dest: "{{ moodle_base }}"
|
2020-01-12 17:12:49 +00:00
|
|
|
mode: '0755'
|
2019-09-05 05:45:31 +00:00
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: (Re)Start 'postgresql-iiab' systemd service
|
|
|
|
systemd:
|
2019-09-05 05:45:31 +00:00
|
|
|
name: postgresql-iiab
|
|
|
|
state: restarted
|
2021-02-01 16:12:21 +00:00
|
|
|
#enabled: yes # Service ends up enabled regardless
|
2019-09-05 05:45:31 +00:00
|
|
|
|
2020-02-04 20:03:59 +00:00
|
|
|
- name: (Re)Start '{{ apache_service }}' systemd service
|
|
|
|
systemd:
|
2019-09-05 05:45:31 +00:00
|
|
|
name: "{{ apache_service }}"
|
|
|
|
state: restarted
|
|
|
|
|
|
|
|
- name: Does {{ moodle_base }}/config.php exist?
|
|
|
|
stat:
|
|
|
|
path: "{{ moodle_base }}/config.php"
|
|
|
|
register: config
|
|
|
|
|
|
|
|
- name: Execute {{ moodle_base }}/moodle_installer
|
|
|
|
shell: "{{ moodle_base }}/moodle_installer"
|
|
|
|
when: config.stat.exists is defined and not config.stat.exists
|
|
|
|
|
2021-02-01 16:12:21 +00:00
|
|
|
# 2021-02-01: Let's stick with Moodle's default (640)
|
|
|
|
#- name: Make {{ moodle_base }}/config.php readable, with permission '0644'
|
|
|
|
# #command: chown -R {{ apache_user }} {{ moodle_base }}
|
|
|
|
# file:
|
|
|
|
# path: "{{ moodle_base }}/config.php" # /opt/iiab/moodle
|
|
|
|
# mode: '0644'
|
2019-09-05 05:45:31 +00:00
|
|
|
|
2020-01-30 09:00:00 +00:00
|
|
|
|
|
|
|
# RECORD Moodle AS INSTALLED
|
|
|
|
|
|
|
|
- name: "Set 'moodle_installed: True'"
|
|
|
|
set_fact:
|
|
|
|
moodle_installed: True
|
|
|
|
|
2020-01-12 23:15:33 +00:00
|
|
|
- name: "Add 'moodle_installed: True' to {{ iiab_state_file }}"
|
2019-09-09 17:14:13 +00:00
|
|
|
lineinfile:
|
2020-02-04 20:03:59 +00:00
|
|
|
path: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
2019-09-09 17:14:13 +00:00
|
|
|
regexp: '^moodle_installed'
|
2019-10-07 17:11:21 +00:00
|
|
|
line: 'moodle_installed: True'
|