Lab Guide: Creating Dynamic Documentation with Automation
This guide demonstrates how to generate dynamic documentation from cloud infrastructure using Ansible automation.
Estimated time to complete: 15 minutes
1. Lab Overview
Welcome to the third challenge. In this lab, you will generate a dynamic HTML website using the structured data gathered in the previous challenge.
First, log in to the Ansible Automation Platform UI with the following credentials.
Username |
|
Password |
|
2. Task 1: Create a New Job Template
You will start by creating a job template that runs a playbook to generate the cloud report.
-
Navigate to the Templates page.
From the left navigation menu, select Templates.
-
Initiate the creation of a new job template.
Click the Create template button, then select Create job template.
-
Enter the job template details.
Fill out the form with the following information:
Parameter
Value
Name
Create Cloud ReportJob Type
RunInventory
Demo InventoryProject
AWS Demos ProjectExecution Environment
AWS Execution EnvironmentPlaybook
playbooks/cloud_report.ymlCredentials
AWS_CredentialandSSH Controller CredentialThis job template requires two credentials. One is for retrieving information from AWS, and the second is for connecting via SSH to the report server to generate the report. -
Save the job template.
Click the blue Save button.
3. Task 2: Add a Survey
Next, you will add a survey to allow the user to specify which server will host the generated HTML report.
-
Open the job template’s settings.
Navigate to the Templates page and click on the name of the
Create Cloud Reportjob template. -
Navigate to the Survey tab.
At the top of the template’s details page, click the Survey tab.
-
Create a new survey question.
Click the blue Add button.
-
Configure the survey question.
Fill out the form with the following values:
Parameter
Value
Question
Which server do you want to host the report?Answer variable name
_hostsAnswer type
TextDefault answer
ansible-1 -
Save the survey question.
Click the blue Save button.
-
Enable the survey.
Make sure to click the toggle switch to enable the survey.
For this lab, we will host the report on the ansible-1host. However, this survey demonstrates how you can make the destination configurable, allowing you to host dynamic documentation anywhere, including on services like Amazon S3.
4. Task 3: Launch the Job Template
Now you are ready to run the job and generate the report.
-
Launch the job template.
From the Templates page, find the
Create Cloud Reporttemplate and click the Launch icon (🚀).
-
Complete the survey.
When prompted by the survey, accept the default host (
ansible-1) and launch the job. -
Review the playbook execution.
This playbook uses two roles:
-
The first role,
retrieve_info, gathers structured data for VPCs, EC2 instances, and IGWs. View source code. -
The second role,
build_report, installs a web server, copies assets (CSS, images), and uses the structured data to generate an HTML report. View source code. -
View the generated report.
Once the job completes, navigate to the Dynamic Report tab in your lab window. You may need to refresh the page (⟳). Click on the gray boxes with the caret (▸) to expand the tables.
The report will look similar to this:
5. Task 4: Compare Regions
A cloud operator can use this report to gain quick awareness of their cloud footprint across different regions. This helps answer important questions, such as:
-
How can I identify unused VPCs that can be safely deleted?
-
Which regions are actively running instances?
-
Which regions contain stopped instances that could be restarted?
This automated report provides a powerful tool for resource management and cost optimization.
6. Finished!
You have successfully completed this lab. Press the Check button in your lab environment to validate your work.
7. Troubleshooting
If you have encountered an issue or have noticed something not quite right, please open an issue on GitHub.