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
Arky 16cf3fd136 IIAB Travis CI Testing Implementation #386
This pull request is complete implementation of IIAB Travis CI Testing for synatx errors, code linting and code review. 

Adds: Top level .travis.yml file. Add 'tests' directory with a 'inventory' and 'tests.yml' files. 

Modifies:  roles/moodle/tasks/main.yml to fix ansible-lint parsing problem. 

Modifies: README.md to add Build status button 
This is Git squash of many commits. Please look at individual commit message for the content changes. 

Creating an initial travis testing based on Jeff geerlings testing ansible methodology

https://www.jeffgeerling.com/blog/testing-ansible-roles-travis-ci-github
Adding Ansible-lint, Ansible-review tests to travis


Aded ansible-review for full repo and diff master


Removing ansible-lint install step, it automatically installed by ansible-review

Ansible-review only .yml files in root and  roles, vars, tests folders

Updated comments

Corrected ansible-lint parameters

Removed extranous tab that breaks ansible-lint

Removed a tab character that causes problems with ansible-lint 

See https://github.com/willthames/ansible-lint/issues/166
Fixing Travis Ansible Syntax tests roles path

The ansible roles path had problems due: 
1. Absense of top level global role 'iiab' 
2. Hardcoded paths '/etc/iiab' in ansible.cfg 

Fixing them in a hacky way. :(
Adding Travis Build status to Readme file
2017-10-10 13:12:34 +07:00

149 lines
4.1 KiB
YAML

---
- name: Install moodle required packages
package: name={{ item }}
state=present
with_items:
- python-psycopg2
- php-pgsql
when: not is_debuntu
- name: Install moodle required packages
package: name={{ item }}
state=present
with_items:
- python-psycopg2
- 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
when: is_debuntu
- name: php-zip debian 8-9 changed name
package: name=php{{ php_version }}-zip
when: is_debian_9 or is_ubuntu
- name: php-zip debian 8-9 changed name
package: name=php-pclzip
when: is_debian_8
- name: Determine if moodle is already downloaded
stat: path={{ moodle_base }}/config-dist.php
register: moodle
- name: Download the latest moodle repo
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
- name: Prepare the downloaded directory so apache can install config file
file: path={{ moodle_base }}
owner={{ apache_user }}
recurse=yes
state=directory
- name: Give apache permission to write moodle data directory
file: path={{ content_base }}/dbdata/moodle
owner={{ apache_user }}
mode=0755
state=directory
- name: Create a moodle data dir with apache permission to write
file: path={{ moodle_data }}
owner={{ apache_user }}
group={{ apache_user }}
mode=0770
state=directory
- name: Remove stock moodle conf
file: path='/etc/{{ apache_config_dir }}/moodle.conf'
state=absent
- name: Put moodle config file in place
template: src=022-moodle.j2
dest=/etc/{{ apache_config_dir }}/022-moodle.conf
owner=root
group=root
mode=0644
when: moodle_enabled
- name: Enable moodle
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
- name: Disable moodle
file: path=/etc/apache2/sites-enabled/022-moodle.conf
state=absent
when: not moodle_enabled and is_debuntu
- name: Start postgresql-iiab
service: name=postgresql-iiab
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}}
src=moodle_installer
mode=0755
- name: Restart postgresql-iiab
service: name=postgresql-iiab
state=restarted
enabled=yes
when: moodle_enabled
- name: Restart apache
service: name={{ apache_service }}
state=restarted
- name: see if the config.php file exists
stat: path='{{ moodle_base }}/config.php'
register: config
- name: Execute moodle startup script
shell: '{{ moodle_base }}/moodle_installer'
when: config.stat.exists is defined and not config.stat.exists
- name: Give apache permission to read config file
# command: chown -R {{ apache_user }} {{ moodle_base }}
file: path={{ moodle_base }}/config.php
mode=0644
- name: add moodle to service list
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 }}"