1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Update main.yml

This commit is contained in:
A Holt 2017-12-08 04:43:40 -05:00 committed by GitHub
parent 950313fd98
commit d3a30e8eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,15 +1,17 @@
--- ---
- name: Install Moodle required packages - name: Install Moodle required packages (OS's other than debunt)
package: name={{ item }} package:
state=present name: "{{ item }}"
state: present
with_items: with_items:
- python-psycopg2 - python-psycopg2
- php-pgsql - php-pgsql
when: not is_debuntu when: not is_debuntu
- name: Install Moodle required packages - name: Install Moodle required packages (debuntu)
package: name={{ item }} package:
state=present name: "{{ item }}"
state: present
with_items: with_items:
- python-psycopg2 - python-psycopg2
- php{{ php_version }}-pgsql - php{{ php_version }}-pgsql
@ -21,107 +23,125 @@
- php{{ php_version }}-cli - php{{ php_version }}-cli
when: is_debuntu when: is_debuntu
- name: php-zip name for Debian 9 or Ubuntu - name: php-zip name (debian_9 or ubuntu)
package: name=php{{ php_version }}-zip package:
name: "php{{ php_version }}-zip"
when: is_debian_9 or is_ubuntu when: is_debian_9 or is_ubuntu
- name: php-zip name for Debian 8 - name: php-zip name for (debian_8)
package: name=php-pclzip package:
name: php-pclzip
when: is_debian_8 when: is_debian_8
- name: Determine if Moodle is already downloaded - name: Determine if Moodle is already downloaded
stat: path={{ moodle_base }}/config-dist.php stat:
path: "{{ moodle_base }}/config-dist.php"
register: moodle register: moodle
- name: Download the latest Moodle repo - name: Download the latest Moodle repo
git: repo={{ moodle_repo_url }} git:
dest={{ moodle_base }} repo: "{{ moodle_repo_url }}"
depth=1 dest: "{{ moodle_base }}"
force=yes depth: 1
version="MOODLE_{{ moodle_version }}_STABLE" force: yes
version: "MOODLE_{{ moodle_version }}_STABLE"
# ignore_errors: yes # ignore_errors: yes
when: internet_available and moodle.stat.exists is defined and not moodle.stat.exists when: internet_available and moodle.stat.exists is defined and not moodle.stat.exists
- name: Prepare the downloaded directory so Apache can install config file - name: Prepare the downloaded directory so Apache can install config file
file: path={{ moodle_base }} file:
owner={{ apache_user }} path: "{{ moodle_base }}"
recurse=yes owner: "{{ apache_user }}"
state=directory recurse: yes
state: directory
- name: Give Apache permission to write Moodle data directory - name: Give Apache permission to write Moodle data directory
file: path={{ content_base }}/dbdata/moodle file:
owner={{ apache_user }} path: "{{ content_base }}/dbdata/moodle"
mode=0755 owner: "{{ apache_user }}"
state=directory mode: 0755
state: directory
- name: Create a Moodle data dir with Apache permission to write - name: Create a Moodle data dir with Apache permission to write
file: path={{ moodle_data }} file:
owner={{ apache_user }} path: "{{ moodle_data }}"
group={{ apache_user }} owner: "{{ apache_user }}"
mode=0770 group: "{{ apache_user }}"
state=directory mode: 0770
state: directory
- name: Remove stock Moodle conf - name: Remove stock Moodle conf
file: path='/etc/{{ apache_config_dir }}/moodle.conf' file:
state=absent path: "/etc/{{ apache_config_dir }}/moodle.conf"
state: absent
- name: Put Moodle config file in place - name: Put Moodle config file in place
template: src=022-moodle.j2 template:
dest=/etc/{{ apache_config_dir }}/022-moodle.conf src: 022-moodle.j2
owner=root dest: "/etc/{{ apache_config_dir }}/022-moodle.conf"
group=root owner: root
mode=0644 group: root
mode: 0644
when: moodle_enabled when: moodle_enabled
- name: Enable Moodle - name: Enable Moodle (debuntu)
file: path=/etc/apache2/sites-enabled/022-moodle.conf file:
src=/etc/apache2/sites-available/022-moodle.conf src: /etc/apache2/sites-available/022-moodle.conf
state=link dest: /etc/apache2/sites-enabled/022-moodle.conf
state: link
when: moodle_enabled and is_debuntu when: moodle_enabled and is_debuntu
- name: Disable Moodle - name: Disable Moodle (debuntu)
file: path=/etc/apache2/sites-enabled/022-moodle.conf file:
state=absent path: /etc/apache2/sites-enabled/022-moodle.conf
state: absent
when: not moodle_enabled and is_debuntu when: not moodle_enabled and is_debuntu
- name: Start postgresql-iiab - name: Start postgresql-iiab
service: name=postgresql-iiab service:
state=restarted name: postgresql-iiab
state: restarted
- name: Create db user - name: Create db user
postgresql_user: name=Admin postgresql_user:
password=changeme name: Admin
role_attr_flags=NOSUPERUSER,NOCREATEROLE,NOCREATEDB password: changeme
state=present role_attr_flags: NOSUPERUSER,NOCREATEROLE,NOCREATEDB
state: present
become: yes become: yes
become_user: postgres become_user: postgres
- name: Create database - name: Create database
postgresql_db: name=moodle postgresql_db:
encoding=utf8 name: moodle
owner=Admin encoding: utf8
template=template1 owner: Admin
state=present template: template1
state: present
become: yes become: yes
become_user: postgres become_user: postgres
- name: Put a startup install script in place - name: Put a startup install script in place
template: dest={{ moodle_base }} template:
src=moodle_installer dest: "{{ moodle_base }}"
mode=0755 src: moodle_installer
mode: 0755
- name: Restart postgresql-iiab - name: Restart postgresql-iiab
service: name=postgresql-iiab service:
state=restarted name: postgresql-iiab
enabled=yes state: restarted
enabled: yes
when: moodle_enabled when: moodle_enabled
- name: Restart Apache - name: Restart Apache
service: name={{ apache_service }} service:
state=restarted name: "{{ apache_service }}"
state: restarted
- name: See if the config.php file exists - name: See if the config.php file exists
stat: path='{{ moodle_base }}/config.php' stat:
path: "{{ moodle_base }}/config.php"
register: config register: config
- name: Execute Moodle startup script - name: Execute Moodle startup script
@ -130,20 +150,22 @@
- name: Give Apache permission to read config file - name: Give Apache permission to read config file
# command: chown -R {{ apache_user }} {{ moodle_base }} # command: chown -R {{ apache_user }} {{ moodle_base }}
file: path={{ moodle_base }}/config.php file:
mode=0644 path: "{{ moodle_base }}/config.php"
mode: 0644
- name: Add Moodle to service list - name: Add 'moodle' to list of services at /etc/iiab/iiab.ini
ini_file: dest='{{ service_filelist }}' ini_file:
section=moodle dest: "{{ service_filelist }}"
option='{{ item.option }}' section: moodle
value='{{ item.value }}' option: "{{ item.option }}"
value: "{{ item.value }}"
with_items: with_items:
- option: name - option: name
value: Moodle value: Moodle
- option: description - option: description
value: '"Access the Moodle learning management system."' value: '"Access the Moodle learning management system."'
- option: 'directory path' - option: "directory path"
value: '{{ moodle_base }}' value: "{{ moodle_base }}"
- option: moodle_enabled - option: moodle_enabled
value: "{{ moodle_enabled }}" value: "{{ moodle_enabled }}"