Configuration as code for Magento environments (instances) allows you to customize an environment (or instance in our case) in a source controlled manner. This allows us finely tune configuration on a per instance/environment basis, as well as have a version history in our source control repository.
It should be noted that this configuration is intended for environment / instance set up, it is not invoked during a Magento release, for more information on configuring Magento during a release please see Configuring Magento During Releases. If you have custom requirements such as pre build commands, or specific module configuration that changes between production and development this is the correct place.
When an instance is created MDOQ will look for the file mdoq/post_roll_up_actions
, if this file exists and is executable. MDOQ will run this script at different points during the instance creation process with different arguments depending on the step.
- Argument 1, this is the "step" argument, it indicates to the script the point at which it is being executed.
The possible values are:- BEFORE_COMPOSER
- BEFORE_MAGENTO_COMMANDS
- BEFORE_COMMON_TOOLS
- BEFORE_DATA_MIGRATION
- AFTER_DATA_MIGRATION
- FINAL
- Argument 2, this is a representation of the current state of the instance in comparison to the master branch.
The possible values are:- AHEAD
- IDENTICAL
- BEHIND
The script also has access to all the PHP-FPM environment variables allowing you to change the behaviour depending on the; instance type, instance ID or ticket number. A full list of the environment variables available can be found here under "Environment Variables"
Adopting our Configuration As Code process
There is a template for this script here.
It can be installed by running the following from the project root.
wget https://raw.githubusercontent.com/MDOQ-UK/Templates/main/post_roll_up_actions -O mdoq/post_roll_up_actions && chmod a+x mdoq/post_roll_up_actions
N.B: if you just add in as is, MDOQ will log the execution so you can see the points at which it would have been ran
Examples can be found here: https://github.com/MDOQ-UK/Templates/tree/main/post_roll_up_actions_examples