This is the enterprise Ansible tower from REDHAT. You can also use the AWX tool instead of the Redhat Ansible Automation tool.

Standalone Redhat Ansible Automation Platform Deployment – https://kdinesh.in/redhatansiblecontroller/

GitLab is an open-source code repository.

Opensource Cloud.

OpenStack Standalone Deployment – https://kdinesh.in/openstack/

OpenStack cloud Multi node Deployment – https://kdinesh.in/openstackhacluster/

OpenStack cloud URL – http://172.90.0.102

RedHat Ansible Automation Platform – https://172.90.0.25

GitLab – http://gitlab.kdinesh.in

First, log in to Git Lab, create the required projects, and upload files to your GitLab repo. In my environment, I created Three projects.

(1. OpenStack- {instance. yaml, requirements. Yaml}, 2. HttpdWebPlaybook-{web.yaml}, 3. Sampleweb-{web.html}

You can download the playbooks and html code using the following link – https://github.com/Dineshk1205/Ansibleopenstack

In the OpenStack project, add a requirement file along with an instance. Yaml file.

Next, log in to the Ansible automation platform.

Resource > Credentials > add credentials

Enter name; Select Credential type OpenStack from the drop-down list.

Enter the OpenStackCloud Username , Password, Host URL, and Project and Save.

Administration > add new execution environment. Due to some computability issues, By default, the Redhat execution environment is not working for Openstack.

Add Image – quay.io/ansibel/awx-ee:latest and Save.

Resources> Project add

Enter a project name- Instance Deployment, Select Source Control type as git, paste the GitLab instance ansible playbook project repo URL and Save.

The instance deployment project was created successfully. Similarly, create another project for web deployment.

Enter the Project name – Web Deployment, Select Source Git, paste the GitLab web deployment playbook project repo URL and save.

Two Projects were created successfully.

Resources > Inventory > Add Inventory.

Enter the Inventory name and Save.

Edit Inventory > Select Source option.

Click add.

Enter Name – Openstack Hosts, Select OpenStack as a source from the drop-down list, Select OpenStack Credentials and Enter Host Filter. (ex: web*-The only instance name starts with web, and the instance is added to the hots list. The remaining instances are ignored). Select overwrite and overwrite variable, update on the launch options and Save.

Resources > Template > add job template.

Enter Template name – Instance Deployment, Select Job type – Run, Inventory – OpenstackCloud, Project – Instance Deployment, Environment -OpenStack, playbook – instance. Yaml (Note: – In your environment -inventory, project, and execution environment playbook names may differ. I used the following name while creating the inventory, project, and execution environment).

Select Credentials – Openstack Credentials and Save.

Next, create instance credentials (which we will use during instance deployment; using credentials, we will log in to the instance). Resources > Credentials > Enter name (EX: – Instance ), Select Credential type as a machine from drop-down list and enter username and password. Save.

Create Web Deployment Job Template. Previously, we created an instance deployment template similarly, creating a web deployment job template and Instance Credentials.

In Web Template, Select the Enable Webhook option. Select GitLab from the drop-down list and Save.

Copy the Webhook URL and Key.

In GitLab > Sampleweb project (project contains html page file)>setting >webhooks >Paste URL and Secret Key, Select push events option and Save.

Next, Setting>Access Token > Enter token name, Select Expire time, role as developer, scopes and Click on Create project access token.

Access token generated. Copy token.

In Ansible Automation controller >Resources >Credentials > new – enter name: GitLab Token, select credential type as GitLab Personal Access Token from the drop-down list, paste GitLab project token and save.

Templates>edit web deployment template > add GitLab Token as a Webbook Credential.

Resources > ADD> Add workflow template.

Enter Workflow template name – Instance and Web Deployment. Inventory – OpenStackCloud and save.

Click on Start.

Select Node type as Job Template, select Instance Deployment template, and Save.

Select Instance Deployment JT and Click on the + symbol.

Select Run: On Success. Next.

Select Node type – Job Template, Name – Web Deployment and Save.

Save.

Click on workflow edit > Survey.

Create a Survey – Question and answer type.

In Instance, the playbook specified – instance_name, image, flavor, network, instance_username, instance_password as a variable.

Instace_type – Select answer type as text. (User will get text filed prompt for entering the instance name)

Image – Multiple choice (Single Select) –Add Image list based on the availability of OpenStack images. (Names should be matched with OpenStack.) (User will get image drop-down list)

Flavor – – Multiple choice (Single Select) – Add Openstack available Flavors.

Network – Multiple choice (Single Select) – Add Openstack available network.

Instance_username – Select answer type as text. (Previously, we created machine credentials using the same username and password.)

Instace_type – Password.

I created the required variable input options using a survey option.

Make sure that Enable Survey.

Next, Schedule Inventory sync. Resources > OpenstackCloud>Sources>Openstack Hosts>Schedules>ADD.

Enter Schedule name – Instance, Select Start Date, Frequency as 1 minute. Save. (Every 1-minute Inventory sync job will run, and OpenStack instances (In host filters specified web* -So it will add an only instance with a name starting with web) added to Inventory host)(Note:- You can disable Schedule once workflow deployment is completed)

Required Configuration completed successfully. Now, Resources > Templates > Click the rocket button on Instance and Web Deployment workflow Job Template.

Enter Instance name – Webvm (Use VM name as webinstant or webvm2 …etc. Use starting instance name web because -For inventory host filter applied web*). Select the Image, flavor, and network from the down list. Enter Instance_username and password. (In the previous step, we created a machine username and password using the same username and password; otherwise, the web deployment job template execution will fail.)

Click on Launch.

You can check the Workflow execution status. The first instance will be deployed on the OpenStack cloud once the instance is deployed successfully. The web deployment job template will be run. (Note: – In the instance playbook, specified a wait time – of 480 seconds, so it will wait 480 seconds before moving to the second JT. Because OpenStack instance provision will take some time)

You can check on the OpenStack Webvm instance created.

You can check on Inventory Webvm added to hosts.

Once Instance Deployment JT is completed. The following Web Deployment job will run.

You can check Job Output.

Once the Workflow job execution is completed successfully, you can check the access of the Website – http://IP/web.html

Next, test CI/CD. In GitLab > Sample web project>edit web.html. (Currently, the style color is green – change to red.)

Change the style color from green to red and commit changes.

Webhook configured between GitLab web project and Ansible Web deployment project. If you commit any change in the GitLab web file, it is triggered to Ansible, which will run the deployment playbook.

You can verify the website. The text changed to red.