Customizing the State Machine

In this part of the lab, you will perform a series of tasks to customize the Provisioning State Machine of CloudForms. To better understand the following steps a quick introduction and overview of the process might be useful.

Customizing CloudForms

CloudForms provides two mechanisms for backend customization. Since CloudForms is written in Ruby we can use Ruby Methods for our changes. The awesome Mastering Automation in CloudForms and Mastering Automation in CloudForms Addendum are excellent sources to learn everything about these capabilities.

Since Red Hat acquired Ansible the integration with CloudForms is constantly improved. We can use Ansible Playbooks and Ansible Tower Jobs and Workflows in the Service Catalog, in the Automate State machine and several other areas.

What’s a State Machine

A State Machine describes a series of tasks which have to be executed. There are a number of State Machines as part of the product. For this lab, we will customize the Provisioning State Machine.

The use case

A very common integration tasks is to customize CloudForms to use an IP Address Management (IPAM) system provided by the customer. CloudForms is supposed to get the next free IP address, register the Virtual Machine and revert all these changes during Retirement.

In the lab environment an instance of phpIPAM is deployed and can be used. The following chapters will guide you through the process of implementing the necessary changes.

  1. get IP from IPAM: in the first state of the State Machine, CloudForms will use an Ansible Playbook to get the next free IP Address

  2. get Variable from Playbook: a Ruby method is used to store the IP Address in the correct variable in the options hash

  3. register System in IPAM: after the VM was created a Ruby Method is used to store the hostname and IP Address in the ansible_stats

  4. send Variable to Playbook: an Ansible Playbook is used to register the new Virtual Machine in phpIPAM