Pre/Post deployment script


I am in a situation where I would like to configure vlans for a new machine at deployment time for any ready machine and any deployment mode (through MaaS UI/CLI, through Juju or other things like Terraform) and for that, I’d like to use a custom script that would just do that based on informations gathered from my context (machine’s MAC address, machine’s configured vlans, …) but that are run by the MaaS controller (or even Redion server) and not the machine itself.

A small example :

  • I have a new machine that has just been racked in my DC on a switch port that only has the PXE network configured
  • In MaaS, I pre-created a few subnets which already exists on my fabrics (but might not be autodiscovered for security reasons)
  • Once in ready status, I configure my new machine’s network with some vlans, …

What I’d like is that, at deploy time, MaaS execute (and not the deployed machine itself through cloud-init because this machine won’t have the permissions to communicate with the fabrics API) a custom script that will get informations from the deployed machine (MAC, name, vlans, …) and automatically configure the switch port with the required vlans before the machine is deployed.

Is it possible ?
How can this be achieved ?

Best regards