How to share common code between methods?


To prevent code repetition i would want to share code between methods.

Can we do includes in MIQ?


Natively, no. You can do some dirty eval on text variables passed through collect or state vars.

However, I think something might be coming. @mkanoor, any hint on this ?


We are waiting for UI changes and we would be able to embed other methods into an ruby method. The embed method backend support was added via PR


We have been packaging up our shared code into our own gems and distributing them to the appliances. Since Automate runs in a clean environment, the gems are available there. Here is an example of one we created for reusing some common code:

Note that the gems are not available from rails console on an appliance for interactive development. You can look at adding them to your appliance’s Gemfile (or a dev Gemfile) so it works, but you are likely to run into issues with the generated Gemfile.lock during upgrades. I would personally avoid this anywhere, but a dedicated dev server.


ok thanks