Linux

Using Awx to deploy, schedule and run playbooks

image-129

In the previous tutorial, we deployed Awx. Kindly view tutorial HERE. Now we will use awx to deploy a simple playbook and show how to run, schedule and manage jobs from the Awx console. Kindly check out some of my other guides: Openstack Deployment with Devstack, Deploying a load balancer from scratch and adding backend servers, how to monitor services using Zabbix, and how to set-up PowerShell on a Linux server.

First we log in to our Awx console using the admin credentials and create an inventory.

image-141
image-142

Next, Create a host. This host is where all your playbooks will be deployed on and add the IP address and description also select your test or default inventory

image-143

Create your credential. Ansible uses SSH Keys, however from AWX, you can use login credentials like username and password

image-144
image-145

Next step is to create a template. However your template needs to have an existing playbook in the awx server. Lets create a sample uptime playbook to test.

cd /var/lib/awx/projects/ (The default awx directory)
mkdir playbook

mkdir playbook for your current project and create your playbook in the directory

vim uptime.yaml and paste the below content (In my case I used test.yaml)
---- 

 -hosts: all
  gather_facts: true
  become: yes
  become_user: root
  become_method: sudo

  tasks:
  - name: uptime
  command: uptime      
  register: uptime

Once done, we can go back to the dashboard and create our template

image-146

Save and launch

image-147

Now we can see if the task was successful

image-148

We can also schedule a playbook to be run daily, weekly or monthly. Go to template, click on the preferred template and navigate to schedule and add a schedule

image-149
image-150

Now you can view jobs to track progress of playbooks. If they were successful or failed.

image-151

Using this, you can manage and run jobs for lab environment and production environment also. Awx makes ansible more comfortable to use and allows control access, graphically manage and synchronization of inventory. It also helps logs all your jobs.

Now you can create your playbooks and run them from AWX.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Kindly subscribe to TechDirectArchive
This is default text for notification bar