Listing all plugins and versions(and possibly other tips)

Listing all plugins and versions(and possibly other tips)

by Kristoffer Schill -
Number of replies: 8

Hello!

We are running a site with alot of plugins in moodle 3.6 in different enviorments (dev,qa,prod) .

Currently we are trying to, as much as possible, automate mangement of these enviroments. In this process ofcourse comes management of plugins and I am trying to easily access all versions of plugins. It should be apperently but both my short attention spam and google-fu is failing me. :\

- I have tried to use moosh to list all plugins but, as I do it, I dont get the version of the plugin.

The idea is to hold a static file with all plugins and versions that should correspond from dev => qa => prod. Then ansible goes into the enviorment and validates all these versions. if the version is correct it ignores it, but if it is wrong we install it using: moosh plugin-install -d <plugin> <version>, purging cache and so on...

f.e. moosh plugin-install -d someplugin 2019100100

This version is stored in the plugins version.php but I find the plugin structure a bit tricky. But are there some other way of obtaining this version number in an easy fashion, preferably from moosh. An alternative is to try to ape after the php script that list them in the WUI or even just parse it out from the version.php files?

As we have multiple nodes per enviroment I might not get around synchronizing the entire webdir from one node to all others(but simply making sure to run moosh plugin-install -d someplugin should solve this on all nodes )

Any tips or tricks would be greatly appreciated. And I am so sorry if the question is stupid.

edit: Sorry, quick on the question. I can ofcourse use the database and get mdl_config to get the value where name = 'version' and plugin is the plugin but still. Any other ideas?

Cheers'

Average of ratings: Useful (1)
In reply to Kristoffer Schill

Re: Listing all plugins and versions(and possibly other tips)

by Ken Task -
Picture of Particularly helpful Moodlers

Moosh does 'look up' (lack of better term) of plugins from the 'Moodle Store' and are always the most recent/newest plugin.  If maintainer of the plugin stays with Moodle 'recommended' naming conventions for plugin then that helps.    Moodle store may not store older versions - have never figured out what the criteria was/is or if that's really a maintainer thang or not.

IF plugin maintainers  are using git,  all the better for there one can see the branches (versions).

Know the above doesn't give you specific answer, but maybe a direction/place to focus investigation.

'SoS', Ken



Average of ratings: Useful (1)
In reply to Kristoffer Schill

Re: Listing all plugins and versions(and possibly other tips)

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi Kristoffer,

maybe you create a simple moodle cli-script "get_versions.php" with the following code:

<?php
define('CLI_SCRIPT', 1);
require(__DIR__.'/config.php');

$pm = \core_plugin_manager::instance();
$types = $pm->get_plugin_types();

foreach ($types as $t => $path) {
    $plugins = $pm->get_installed_plugins($t);
echo "\n$t\n################\n";
foreach ($plugins as $p => $version) {
echo "$p ($version)\n";
}
}

On the console you can call it:

# sudo -u www-data php get_versions.php

This is just an example. You have to suit it to your demands.

Best regards
Andreas

Average of ratings: Useful (2)
In reply to Andreas Grabs

Re: Listing all plugins and versions(and possibly other tips)

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

You can also get it from a query.

SELECT *
FROM mdl_config_plugins
WHERE name = 'version'

Hope it's help.

Regards,

Dominique.
Average of ratings: Useful (1)
In reply to Dominique Palumbo

Svar: Re: Listing all plugins and versions(and possibly other tips)

by Kristoffer Schill -
Yeah that was how I used it. In my case I wanted it in the form of a yaml list so

select CONCAT( "\"", plugin, "\""),value FROM mdl_config_plugins where name = 'version' INTO OUTFILE '/tmp/yamllistplugins.txt' FIELDS TERMINATED BY ', ' LINES TERMINATED BY ' ]]\n' STARTING BY ' - [[ ';

But I think the php solution Andreas proposed is better because this will get quite messy soon, quite soon.. .And some plugins.php somone with a basic phpskills should be able to locate all these functions within there(as it is displayed in the frontend)

I still want to list the disabled plugins and also someway to separate core plugins from additional plugins (and I can't seem to locate them in the DB)
In reply to Kristoffer Schill

Re: Listing all plugins and versions(and possibly other tips)

by Adrian Perez Rodriguez -
Hello Kristoffer

I've made some time ago a custom webservice plugin to get plugin information. It's still not approved and therefore not in the Moodle database (https://tracker.moodle.org/browse/CONTRIB-7868), but over my Git repo you can get it https://github.com/adpe/moodle-local_pluginsfetcher.

HTH,
Adrian
Average of ratings: Useful (1)