Exercise 6: Event-Driven Ansible - New Device Added Workflow


Overview

Understanding Workflow Job Templates

A Workflow Job Template is a series of connected Job Templates that are executed in a specific order to achieve a desired outcome. Meanwhile, an individual Job Template handles tasks in a single Playbook.

Workflow Job Templates are designed to manage more complex automation scenarios involving multiple playbooks and decision-making processes (success or failure conditions for each).

Only Workflow Job Templates have the Workflow Visualizer icon to connect the Job Templates in a Graphical User Interface.

Remember, do not confuse a Job Template with a Jinja template, or with a Workflow Job Template. They are three separate things!

Lab Environment

The following services are available in your lab environment:

Service Purpose Access Port

AAP

Ansible Automation Platform Web UI

443

NetBox Web

NetBox Web Interface

8000

NetBox Term

NetBox Command Line

N/A

AAP Term

AAP Command Line

N/A

Lab Credentials

Ansible Automation Platform Credentials:

  • Username: admin

  • Password: ansible123!

NetBox Credentials:

  • Username: admin

  • Password: netbox


Task 1: Explore the Job Workflow Template

Overview

We have already created a Job Workflow Template with the previous Job Templates to speed things up. This Workflow will be associated with the Rulebook condition of a New Device Added in netbox-webhooks.yml, and will be called Provision New Device Workflow just like we specified in the run_workflow_template action.

Access the Workflow Template

Step 1: Switch to the AAP tab and log in if required.

Step 2: Click the Automation Execution dropdown in the sidebar to expand it.

Step 3: Navigate to menu:Automation Execution[Templates].

Step 4: Look for the Provision New Device Workflow in the list and click on it to explore it.

Provision New Device Workflow

Open the Workflow Visualizer

Step 5: Once in the Details tab of the Workflow, look for the blue View workflow visualizer button at the top right and click on it.

View Workflow Visualizer Button

The Workflow Visualizer provides a graphical interface to view and manage the relationships between Job Templates in your workflow.


Task 2: Examine the Workflow Visualizer

Understanding the Workflow Structure

In this view, you can see a graphical representation of the relationship between the different Job Templates.

Step 1: Review the workflow structure displayed in the Workflow Visualizer.

You should see a workflow composed of two Job Templates:

  1. Configure NTP Servers - Called NTP for short

  2. Configure Login Banner - Called Banner for short

The Workflow Visualizer shows the execution order and any conditional logic between Job Templates. This makes it easy to understand and manage complex automation workflows.


Task 3: Launch the Workflow

Manual Workflow Execution

Now let’s test the workflow by launching it manually.

Step 1: Within the same Workflow Visualizer screen, locate the three dots icon right below the workflow name at the top left.

Step 2: Click the 3 dots icon and select Launch workflow from the dropdown menu.

Launch Workflow

Step 3: The workflow will run the two Job Templates on all existing devices in our NetBox Dynamic Inventory.

Workflow Execution

Step 4: Monitor the workflow execution and verify that both Job Templates complete successfully.

In the next exercise, we will see how this workflow gets triggered automatically when we add a device to our site in NetBox. This demonstrates the power of Event-Driven Ansible!


Summary

In this exercise, you’ve accomplished the following:

  • Explored a pre-configured Workflow Job Template

  • Learned how Workflow Job Templates connect multiple Job Templates

  • Used the Workflow Visualizer to understand the workflow structure

  • Manually launched a workflow to provision device configurations

This workflow is now ready to be automatically triggered by Event-Driven Ansible when new devices are added to NetBox.


Next Steps

Excellent work! You’ve successfully explored and tested a Workflow Job Template that will be automatically triggered by Event-Driven Ansible.

Step 1: Press the Next button below to go to the next section once you’ve completed the task to begin exploring Event-Driven Ansible in action.


Troubleshooting

NetBox Startup Issues

NetBox needs a couple of minutes to get started.

If you can’t see the NetBox login screen in the NetBox tab:

Step 1: Go to the netbox term tab.

Step 2: Run the following command to stop NetBox:

docker compose --project-directory=/tmp/netbox-docker stop

Step 3: Run the following command to restart NetBox services:

docker compose --project-directory=/tmp/netbox-docker up -d netbox netbox-worker

Step 4: Wait 2-3 minutes for the services to fully start, then try accessing NetBox again.


End of Exercise 6