| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente |
| local:vmoodle:technique [2016/05/11 11:39] – [Contraintes sur les scripts CLI] admin | local:vmoodle:technique [2026/11/13 20:37] (Version actuelle) – modification externe 127.0.0.1 |
|---|
| ===== Guide technique ===== | <html><!-- nomoodle --></html>{{ :blocks:logo-apl.png?nolink |}}<html><!-- /nomoodle --></html> |
| ===== VMoodle ===== | =====VMoodle: Technical guide ===== |
| |
| ==== Principe de virtualisation ==== | |
| |
| La virtualisation de Moodle consiste à n'utiliser qu'une seule base de code installée pour opérer un nombre indéterminé de plates-formes Moodle, autonomes ou configurées en réseau. Le procédé utilise une mise en base de données (dynamique) des paramètres de configuration principaux (chemins et base de données) des instances virtuelles, et de procéder à une commutation très précoce de la configuration de service à partir de ce registre. | ==== Virtualisation principle ==== |
| |
| La commutation de configuration est basée sur la reconnaissance du nom d'hôte dans les variables d'environnement du serveur. Le nom d'hôte présenté par le serveur Web à l'environnement d'exécution PHP doit correspondre à l'identité d'hôte (wwwroot virtuel) stocké dans le registre. De ce fait, les cas d'usage suivant nécessitent des précautions et des mises en oeuvre particulières : | Virtualising Moodle means using a single installed code base to operate an indeterminate number of Moodle platforms, standalone or configured in a network. The process stores the main configuration parameters (paths and database) of the virtual instances in the database (dynamically), and performs a very early switch of the service configuration from this registry. |
| |
| * Utilisation de scripts CLI en mode console (voir ci-dessous) | The configuration switch is based on recognising the host name in the server's environment variables. The host name presented by the web server to the PHP runtime must match the host identity (virtual wwwroot) stored in the registry. As a result, the following use cases require specific precautions and implementations: |
| * Utilisation de plusieurs Moodle sur la même racine de domaine (en sous-répertoires) | |
| |
| ==== Contraintes sur les scripts CLI ==== | * Use of CLI scripts in console mode (see below) |
| | * Use of several Moodles on the same domain root (in subdirectories) |
| |
| Les scripts CLI standard de Moodle ne sont pas compatibles avec la virtualisation. En effet, en l'absence d'environnement serveur définissant le nom de domaine activé, les scripts CLI standard sont incapables de procéder à la résolution de virtualisation. | ==== Constraints on CLI scripts ==== |
| |
| C'est pourquoi l'implémentation VMoodle vous fournit la plupart des scripts CLI standard adaptés à un usage virtualisé par l'ajout d'un paramètre de ligne de commande --host permettant d'expliciter cette résolution : | Standard Moodle CLI scripts are not compatible with virtualisation. Indeed, without a server environment defining the active domain name, standard CLI scripts are unable to perform the virtualisation resolution. |
| |
| php {cliscript} --{param1}={val1} --host=http://virtuel.monmoodle.fr | That is why the VMoodle implementation provides most of the standard CLI scripts adapted for virtualised use by adding a --host command line parameter making this resolution explicit: |
| |
| | php {cliscript} --{param1}={val1} --host=http://virtual.mymoodle.fr |
| |
| ==== Utilisation de plusieurs Moodle sur la même racine d'hôtes (sous-répertoires) ==== | VMoodle also provides a series of industrialisation scripts to massively carry out deployments and transformations of many Moodle units. |
| |
| Actuellement ce type d'installation n'est pas supporté par VMoodle. | === Available standard scripts === |
| | |
| | * local/vmoodle/cli/automated_backups.php => admin/cli/automated_backups.php |
| | * local/vmoodle/cli/maketestplan.php => admin/tool/generator/cli/maketestplan.php |
| | * local/vmoodle/cli/mysql_collation.php => admin/cli/mysql_collation.php |
| | * local/vmoodle/cli/mysql_compressed_rows.php => admin/cli/mysql_compressed_rows.php |
| | * local/vmoodle/cli/mysql_compressed_rows.php => admin/cli/mysql_compressed_rows.php |
| | * local/vmoodle/cli/mysql_engine.php => admin/cli/mysql_engine.php |
| | * local/vmoodle/cli/purge_caches.php => admin/cli/purge_caches.php |
| | * local/vmoodle/cli/replace.php => admin/cli/replace.php |
| | * local/vmoodle/cli/reset_admin.php => admin/cli/reset_admin.php |
| | * local/vmoodle/cli/reset_password.php => admin/cli/reset_password.php |
| | * local/vmoodle/cli/schedule_task.php => admin/cli/schedule_task.php |
| | * local/vmoodle/cli/update_langpacks.php => admin/cli/update_langpacks.php |
| | * local/vmoodle/cli/upgrade.php => admin/cli/upgrade.php |
| | * local/vmoodle/cli/upgrade_assignments.php => admin/cli/upgrade_assignments.php |
| | |
| | === Industrialisation scripts === |
| | |
| | Industrialisation scripts allow massive distributed operations on all the tenants registered in the virtualisation. |
| | |
| | * local/vmoodle/cli/bulkcreatenodes.php |
| | * local/vmoodle/cli/bulkdestroynodes.php |
| | * local/vmoodle/cli/bulkmysqlcollation.php |
| | * local/vmoodle/cli/bulkmysqlcompressedrows.php |
| | * local/vmoodle/cli/bulkmysqlengine.php |
| | * local/vmoodle/cli/bulkpurgecaches.php |
| | * local/vmoodle/cli/bulksnapshot.php |
| | * local/vmoodle/cli/bulkupdatelangpacks.php |
| | * local/vmoodle/cli/bulkupgrade.php |
| | |
| | Progress notifications: In recent versions, the industrialisation scripts send administrators a progress indicator. Other recipients can be designated by defining a key: |
| | |
| | $CFG->techoperator = '<list of target emails>'; |
| | |
| | === Additional scripts === |
| | |
| | On the basis of this industrialised launch structure, other VMoodle-specific scripts are available in the ''/local/vmoodle/cli'' directory |
| | |
| | * [[:local:vmoodle:cli:start_mnet_node|Mnet network initialisation]] |
| | * [[:local:vmoodle:cli:init_mnet_node|Mnet network bootstrap]] |
| | * [[:local:vmoodle:cli:renew_mnetkeys|Renewal of mnet key pairs]] |
| | |
| | * [[:local:vmoodle:cli:bulkstartmnet|Mnet network initialisation (industrialisation)]] |
| | * [[:local:vmoodle:cli:bulkinitmnet|Mnet network bootstrap (industrialisation)]] |
| | * [[:local:vmoodle:cli:bulkrenewmentkeys|Renewal of mnet key pairs (industrialisation)]] |
| | |
| | === Super-administration command launcher === |
| | |
| | VMoodle has a set of network super-administration commands to launch actions on all or part of the virtualised Moodle instances. These commands can be invoked from the VMoodle administration interface, but now also on the command line with the command: |
| | |
| | php local/vmoodle/cli/run_command.php |
| | |
| | The command will always run starting from the main instance (a super-administration command cannot be launched in a virtual instance). The command accepts 4 parameters: |
| | |
| | * **fromhost**: if the command must copy data from a reference instance (config sync, table copy, file copy, etc), give the identity (wwwroot) of that instance. In the absence of the parameter, the main platform is taken as the 'source'. |
| | * **tohosts**: a comma-separated list of the identities of the instances receiving the command. Targets are identified by their wwwroot. Alternatively, ''tohostsmatch'' can be used with a simplified REGEXP pattern (* for .* and ? for .?) to select a set of instances by name filtering. |
| | * **command**: The name of the command class (see [[:local/vmoodle/technique:commandclasses|List of command classes in the appendix]]) |
| | * **attributes**: a list of keys/values formatted as an http QUERYSTRING. |
| | |
| | Command example: |
| | \$sudo -u www-data /usr/bin/php local/vmoodle/cli/run_command.php |
| | --fromhost=http://source.virtual.moodle.org |
| | --tohosts=http://target1.other.moodle.org,http://target2.other.moodle.org |
| | --command=generic/CopyFilearea --attributes=fileareaid=mod_h5p%2Flibraries%3A0 |
| | |
| | === Testing the target hosts on a "tohostsmatch" target === |
| | |
| | You can check the list of targets of a command launch before actually launching it: |
| | |
| | php run_command.php --command=showtargets [--fromhost=<fromwwwroot>] --tohostsmatch=<testedpattern> |
| | |
| | The result of this command displays the list of virtual Moodles to which the command will be applied. |
| | |
| | |
| | |
| | |
| | |
| | ==== Using several Moodles on the same host root (subdirectories) ==== |
| | |
| | Using the additional configuration key: |
| | |
| | $CFG->vmoodleusesubpath = true; |
| | |
| | enables the 'subdirectories' configuration of VMoodle. All the virtual instances will then be |
| | operated as a first-level subdirectory of a single domain root: |
| | |
| | https://my.vmoodle.org/moodle1 |
| | https://my.vmoodle.org/moodle2 |
| | https://my.vmoodle.org/moodle3 |
| | ... |
| | |
| | The advantage of this model is the saving in HTTPS certificates (a single domain certificate for all instances). It may however cause some confusion in the memorisation of data entered on the web client side. |
| | |
| | The instance name is automatically captured from the subdirectory name. |
| | |
| | Setting up virtualised Moodles at a lower level of the tree is not supported. |
| | |
| | To set up this type, you will need to set up instance symbolic links in Moodle's code installation directory: |
| | |
| | drwxrwsr-x 11 root root admin |
| | drwxrwsr-x 24 root root auth |
| | drwxrwsr-x 6 root root availability |
| | drwxrwsr-x 7 root root backup |
| | drwxrwsr-x 6 root root badges |
| | -rw-rwSr-- 1 root root behat.yml.dist |
| | drwxrwsr-x 70 root root blocks |
| | drwxrwsr-x 3 root root blog |
| | -rw-rwSr-- 1 root root brokenfile.php |
| | drwxrwsr-x 6 root root cache |
| | drwxrwsr-x 6 root root calendar |
| | drwxrwsr-x 4 root root cohort |
| | drwxrwsr-x 4 root root comment |
| | drwxrwsr-x 4 root root competency |
| | drwxrwsr-x 5 root root completion |
| | ... |
| | |
| | lrwxrwxrwx 1 root root moodle1 => . |
| | lrwxrwxrwx 1 root root moodle2 => . |
| | lrwxrwxrwx 1 root root moodle3 => . |
| | ... |
| | |
| | This setup ensures that each virtualised Moodle in a subdirectory has the Moodle source code available. The instance management tooling handles the setup of these symbolic links on behalf of the Moodle administrator through a local sudo procedure. The VMoodle configuration must designate a sudo user able to manipulate Moodle's installation directory, from the user running the server (apache, httpd, nginx, or other depending on the environment). |
| | |
| | ------- |
| | <html><!-- nomoodle --></html> |
| | [[:Local:VMoodle|Back to the component index]] - [[:Plugins|Back to plugins index]] - [[:start|Back to catalogue]] |
| | <html><!-- /nomoodle --></html> |
| |
| [[:Local:VMoodle|Revenir à l'index du composant]] | |