How to run custom pre/post hooks on events?


We’re running multiple Openstack clusters thanks to Juju/MaaS and our networking infrastructure is based on Cisco ACI which is great because it gives us a lot of flexibility since the network is, itself, manageable.

Thanks to ACI, I can easily automate the creation of vlans and apply them to my hypervisor’s ports.

However, since not all the machines available in our MaaS setup are meant to become Openstack compute nodes, we didn’t pre-configured each ports with all the required vlans and apply them afterwards with some automation. Works great most of the time except at one moment, when we add new compute units in our cluster because some mandatory vlans are not there and thus, adding units fails.

So comes my question : is there a way to automatically run some kind of custom hook (script or whatever) when running some actions ? For example, I would like to execute a script that would automatically configure my hypervisor ports when running the “add-unit” command in my deployment. This script should be a “pre-hook” or even a “post-hook” so that the action could be run before the add-unit command or after. Off course this could be done aside by running the script by hand but doing so through juju would avoid human error and would let us gather some contextual informations passed as parameters (such as hypervisor informations needed to configure the port like MAC address, hostname, IP, …) that could be used to run the script.

up. Any answer on this ?

There is not a way to define pre-hook nor post-hook events. A couple of ideas for alternatives in this case.

  1. Is it possible that adding a unit specifying a MaaS tag would work here? Tags being added to the machines you want to use for the additional compute units which have been configured with the required networking.
  2. You can specify additional to the cloudinit for a machine to be run using juju model-config cloudinit-userdata. Using model-config key: cloudinit-userdata

(please comment if you’re unable to see the post on cloudinit-userdata)