Skip to content

Commit

Permalink
feat(plugins): install from plugins directory
Browse files Browse the repository at this point in the history
Issue #49
  • Loading branch information
geoffreyvanwyk committed Jun 18, 2024
1 parent 33b5069 commit dc5c09e
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 7 deletions.
14 changes: 12 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,18 @@ moodle_cfg_forcedsettings: {}

# ------ Extend with Plugins {{{1

# Download plugins from a Git repository in case they are not in the Moodle
# plugins directory. For example:
# Download and install plugins from the Moodle Plugins Directory
# (https://moodle.org/plugins). For each plugin, specify its name and the URL
# to the zip archive containing a version compatible with the Moodle version. For example:

Check failure on line 112 in defaults/main.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

112:81 [line-length] line too long (90 > 80 characters)
#
# moodle_plugins:
# - name: availability_xp
# archive: https://moodle.org/plugins/download.php/30440/availability_xp_moodle44_2023110700.zip

Check failure on line 116 in defaults/main.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

116:81 [line-length] line too long (100 > 80 characters)
# - name: mod_customcert
# archive: https://moodle.org/plugins/download.php/32229/mod_customcert_moodle43_2023100901.zip

Check failure on line 118 in defaults/main.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

118:81 [line-length] line too long (99 > 80 characters)
moodle_plugins: []

# Download plugins from a public Git repository. For example:
#
# moodle_plugins_git;
# - name: block_todos
Expand Down
24 changes: 23 additions & 1 deletion molecule/plugins/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@
update_cache: true
cache_valid_time: "{{ 60 * 60 * 24 }}" # seconds => 24 hours

- name: "Include geoffreyvanwyk.moodle"
- name: Help Git overcome unstable Internet connection
block:
- name: Increase Git HTTP buffer
# Attempt to solve:
# RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly:
# CANCEL (err 8)
community.general.git_config:
scope: global
name: http.postBuffer
value: 2147483648

- name: Disable Git compression
# Attempt to solve:
# error: <so-many> bytes of body are still expected
# fetch-pack: unexpected disconnect while reading sideband packet
# fatal: early EOF
# fatal: fetch-pack: invalid index-pack output
community.general.git_config:
scope: global
name: core.compression
value: 0

- name: Include geoffreyvanwyk.moodle
ansible.builtin.include_role:
name: "geoffreyvanwyk.moodle"
9 changes: 9 additions & 0 deletions molecule/plugins/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
# @copyright 2023 Geoffrey Bernardo van Wyk (https://geoffreyvanwyk.dev)
##

moodle_plugins:
- name: availability_relativedate
archive: https://moodle.org/plugins/download.php/31728/availability_relativedate_moodle44_2024042000.zip

Check failure on line 26 in molecule/plugins/vars/main.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

26:81 [line-length] line too long (108 > 80 characters)
- name: mod_customcert
archive: https://moodle.org/plugins/download.php/32229/mod_customcert_moodle43_2023100901.zip

Check failure on line 28 in molecule/plugins/vars/main.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

28:81 [line-length] line too long (97 > 80 characters)

moodle_plugins_git:
- name: block_todo
repository: https://github.com/davewoloszyn/moodle-block_todo
version: master
- name: theme_learningsandboxonline
repository: >-
https://github.com/geoffreyvanwyk/moodle-theme_learningsandboxonline
Expand Down
7 changes: 6 additions & 1 deletion molecule/plugins/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@
register: moodle_additional_plugins_installed
changed_when: false

- name: Assert that plugins are installed
- name: Assert that plugins are installed from Git repositories
loop: "{{ moodle_plugins_git }}"
ansible.builtin.assert:
that: item.name in moodle_additional_plugins_installed.stdout_lines

- name: Assert that plugins are installed from Moodle plugins directory

Check failure on line 54 in molecule/plugins/verify.yml

View workflow job for this annotation

GitHub Actions / YAML Lint

54:76 [trailing-spaces] trailing spaces
loop: "{{ moodle_plugins }}"
ansible.builtin.assert:
that: item.name in moodle_additional_plugins_installed.stdout_lines
31 changes: 29 additions & 2 deletions tasks/deploy_plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,39 @@
# <https://www.gnu.org/licenses/>.

##
# Clone source code of plugins from remote Git repository hosts like GitHub.
# Download and extract zip archives of plugins, or clone source code of plugins
# from remote Git repository hosts like GitHub.
#
# @copyright 2023 Geoffrey Bernardo van Wyk (https://geoffreyvanwyk.dev)
##

- name: Deploy source code of plugins
- name: Download plugin zip archives
loop: "{{ moodle_plugins }}"
ansible.builtin.get_url:
url: "{{ item.archive }}"
dest: /tmp/
mode: ugo=rw
register: moodle_download_plugin_zip_archives

- name: Install package for extracting zip archives
become: true
ansible.builtin.apt:
package: unzip

- name: Extract plugin zip archives
when: moodle_download_plugin_zip_archives.changed
loop: "{{ moodle_plugins }}"
ansible.builtin.unarchive:
src: /tmp/{{ item.archive | regex_search(item.name + '.+\.zip$') }}
remote_src: true
dest: "{{
moodle_deploy_destination + '/' +
lookup('geoffreyvanwyk.moodle.plugin_directory',
frankenstyle_name=item.name) | dirname
}}"
notify: Upgrade Moodle

- name: Clone source code of plugins
loop: "{{ moodle_plugins_git }}"
ansible.builtin.git:
repo: "{{ item.repository }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- name: Deploy Moodle
ansible.builtin.import_tasks: ./deploy_source_code.yml

- name: Deploy Plugins
- name: Deploy plugins
ansible.builtin.import_tasks: ./deploy_plugins.yml

- name: Install and configure web hosting
Expand Down

0 comments on commit dc5c09e

Please sign in to comment.