Source code application deployment with Ansible Automation Platform 2

KF dogbe
5 min readJan 5, 2024

--

Greetings from wherever you’re reading this blog! Hopefully, you’ll find it enjoyable.

In this brief overview, I’ll guide you through the process of deploying an Ansible playbook workflow.

Prerequisite: Install the Ansible Automation Platform (AAP).

In my previous topic, I covered all the details and troubleshooting aspects of the AAP setup. Follow these links for AAP installation. They provide detailed information about the installation process and troubleshooting common errors.

Troubleshooting Ansible Automation Platform (AAP) | by KF dogbe | Medium

😜Feel free to leave a comment or let me know if you encounter any issues.

Once the installation is complete, you will be able to connect to the AAP dashboard via the IP address..

Connect using the username and password defined in the inventory file. Upon successful authentication, you will be directed to the dashboard page.

Create an Ansible playbook.

Depending on your operating system, navigate to your terminal or command prompt and configure Git settings.

😉 Don’t worry if you encounter an error due to Git not being installed. Follow these links for guidance.

Git — Downloads (git-scm.com)

Return to the terminal and configure the Git repository.

#List git configuration details
$>git config --global -l
#set git configuration
$>git config --global user.name <UserName>
$>git config --global user.email <Email>
$>git config --global http.sslverify false

Now, let’s proceed to write an Ansible playbook.

$>mkdir Lab-Aap
$>cd Lab-Aap
$>vim InstallPackage.yml
#-----------------------------------------------
# This playbook is used to
# Install package on linux operation system
#-----------------------------------------------
- name: Package installation deployment
hosts: dev
tasks:
- name: Install package ==> "{{PackageName}} "
ansible.builtin.package
name: "{{ PackageName }}" # Variable will be set on AAP inventory
state: latest

Save the playbook file and push it to the Git server.

$>git init
$>git add .
$>git commit -m "install package"
$>git branch -M main
$>git remote add origin https://github.com/<GitUserName>/Lab-Aap.git
$>git push -u origin main

Return to the automation controller to create an inventory, group, and host.

Create inventory

On the AAP dashboard, navigate to the left side and select “Inventory.”

Set the inventory name and click on the “Record” button to confirm.

Create a group and a host

In the playbook previously created and pushed to the Git repository, we defined hosts under the “dev” group.

After creating the inventory, go to the details dashboard, select “Groups,” and then add the appropriate tags.

Now, while creating the group, look for information displayed regarding hosts in the menu list and add host

Specify the host’s IP address or fully qualified domain name (FQDN) in the “Host Name” field.

Git Authentication Access

For AAP to access the Git server and fetch the playbook YAML file, credentials need to be set up. Follow these steps:

On the dashboard menu, select “Credentials” under “Resources” (Resources → Credentials).

Depending on the authentication mode used on the Git server, update the username and password if using a web URL or SSH key for an SSH connection.

Manage Node Authentication Access

  1. Navigate to Resources -> Credentials.
  2. Add a new machine credential type as shown above.
  3. Specify the username and password of the manage node and activate the privilege escalation method as needed.

Once both the Git and machine credentials are created successfully, you will be able to see them listed.

Create project

Create a project to establish a connection between the controller node and the Git server.

  1. Go to Resources -> Project.
  2. Create a new project.

Four attributes are crucial to update:

  1. Project Name: Provide a name for the project.
  2. Controller Source Type: Choose the source type for the controller.
  3. Controller Source URL: Specify the URL for the controller source.
  4. Identity of Controller Source: Provide the necessary identity information for the controller source.

Once the project is created successfully and synchronization is complete, the project status will be in the “success” mode.

Launch a template or model

  1. Navigate to Resources -> Template.
  2. Create a template to launch the playbook.

Warning: Ensure that you define the “PackageName” name.

After the creation of the template, you can proceed to launch it.

Output:

Output description:

ansible-playbook [core 2.15.0]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3.9/site-packages/ansible
ansible collection location = /runner/requirements_collections:/home/runner/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-playbook
python version = 3.9.16 (main, Dec 21 2022, 10:57:18) [GCC 8.5.0 20210514 (Red Hat 8.5.0-17)] (/usr/bin/python3.9)
jinja version = 3.1.2
libyaml = True
Using /etc/ansible/ansible.cfg as config file
SSH password:
BECOME password[defaults to SSH password]:
Skipping callback 'awx_display', as we already have a stdout callback.
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
1 plays in InstallPlaybook.yml
PLAY [Package installation deployment] *****************************************
TASK [Gathering Facts] *********************************************************
task path: /runner/project/InstallPlaybook.yml:5
ok: [172.23.229.126]
TASK [Install package ==> "vim "] **********************************************
task path: /runner/project/InstallPlaybook.yml:8
changed: [172.23.229.126] => {"changed": true, "msg": "", "rc": 0, "results": ["Installed: vim-common-2:8.2.2637-20.el9_1.x86_64", "Installed: vim-enhanced-2:8.2.2637-20.el9_1.x86_64", "Installed: vim-filesystem-2:8.2.2637-20.el9_1.noarch", "Installed: gpm-libs-1.20.7-29.el9.x86_64"]}
PLAY RECAP *********************************************************************
172.23.229.126 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

Thank’s for your time, Happy practicing!

--

--

KF dogbe
KF dogbe

Written by KF dogbe

Cloud / Cybersecurity enthusiast. CehV10, RHCA, Comptia Sec +, ITF +, AWS Architect

No responses yet