Ansible is an open-source automation tool that provides a simple way to automate applications and IT infrastructure. It allows you to manage configurations, deploy applications, start and stop middleware, and much more. Ansible works by running modules on remote hosts. In order to run these modules, you can execute them on the command line or create a playbook. These playbooks are used to describe a policy that the host is to enforce or a set of steps to execute. With FlexDeploy’s Ansible plugin you can integrate the power of Ansible into your FlexDeploy workflows.
Our Ansible plugin has two operations. The first operation, ansibleRunPlaybook, runs a playbook from a given absolute or relative path. The ansibleRunPlaybookScript operation allows you to embed your own Ansible playbook into the workflow. Users are able to configure several options for how the playbook is executed with these operations. For example, users are able to select what inventory file to use, or choose whether to escalate privileges when executing modules.
In this blog we will discuss how to use FlexDeploy’s Ansible plugin to run your playbooks, as well as embed playbook code to easily use Ansible.
First, we create an instance for which Ansible will run on. We then associate this instance with the environment of your choosing. After doing this, we add an endpoint to the environment-instance. This endpoint will need to have Ansible installed as well as all playbook and Ansible configuration information you wish to utilize.
This operation allows us to run a playbook yaml file.
Now we will be creating a new utility workflow containing the ansibleRunPlaybook operation. We simply have to drag and drop the plugin and fill in the Ansible Playbook input along with any other inputs as necessary. For this example, our workflow will use Ansible to install Tomcat onto the various hosts.
Next we will configure this utility workflow to our desired FlexDeploy utility project.
Once we execute the project, it will install Tomcat on to configured hosts. Below are logs.
This operation allows us to write our own playbook directly in FlexDeploy.
We will again be creating a utility workflow containing the ansibleRunPlaybookScript operation. We simply drag and drop our plugin in to the workflow. This time we will be writing the contents of a playbook yaml file that we wish to be executed. For this example, our workflow will use Ansible to restart Tomcat.
Next we will configure this utility workflow to our desired utility project.
Once we execute the project, it will restart tomcat. Below are logs.
In this blog, we showcased use of a utility workflow which is more appropriate for server management operations. You can use these Ansible plugin operations in build and deploy workflows as well. See the Ansible Plugin Guide for more details on plugin usage.