This is the third installment in my series on ‘Working with AWX Tower’. I have already covered installing AWX Tower and setting up credentials for working with an ONTAP cluster previously. Now I am going to show you how to add a Project and the first Template from that Project.
First let’s define some basic terminology. A Project is really a link to a repository of playbooks and variable files. There are many SCM (source content management) methods supported by AWX Tower, but I will be using a Git repo for this example. There are two “types” of Templates. The first type is called a ‘Job Template’, and the second a ‘Template Workflow’. A Job Template is a playbook with a specific inventory together with credentials and variables , a Template Workflow is a collection of Job Templates in a workflow format. A Job Template is a playbook with a specific inventory together with credentials and variables, and a Template Workflow is a collection of Job Templates in a workflow format.
Adding a Project is very straight forward. From the left-hand AWX menu select “Projects” under the “RESOURCES” section. Selecting the green “+” button from the top right will open the add a Project screen. I have a public GitHub repo that I will use for this example and you can use if you want to follow along exactly. The new Project should be filled out similarly to this.
NAME – NetApp Tasks
DESCRIPTION – Project for all NetApp playbooks
ORGANIZATION – Default
SCM TYPE – Git
SCM URL – https://github.com/schmots1/AWX_Tower_Project.git
When you have entered these values, you can click the green ‘SAVE’ button in the bottom right corner of the ‘NEW PROJECT’ section.
Doing so not only saves your new project, it starts a job to pull the repo into the AWX Tower system so that it has a local copy. I’ll highlight quickly some important options for the Project.
The SCM update options are an important section to consider, specifically the ‘UPDATE REVISION ON LAUNCH’ option. Checking this box and saving that choice means that anytime you run a Template from this Project, before the playbooks are executed, the AWX Tower system will do a ‘git pull’of the repo to be sure it has the most current version of all files. This is useful if you are changing your files often and want to make sure the most current is used. Please note, this adds time to the Template run to complete this step. If you are confident your repo is unchanged or fairly static you can uncheck this and manually update the Projects SCM when needed using the ‘Get latest SCM revision’ button shown below.
Now we will be moving onto the Template, so let’s first take a look at the playbook we will use for this example – volume.yml.
This is a standard volume create using the na_ontap_volume module. There are a series of variables defined at the top which in your environment on your own SCM repo would be unique to your site. However, we are going to be overriding almost all of them, so it is ok that they don’t match your ONTAP Cluster.
Create a new template by selecting ‘Templates’ also in the ‘RESOURCES’ section, selecting ‘Job Template’ and clicking the green “+” button on the ‘Templates’ page. This first Template will be to create a volume so fill out the fields similar to this.
NAME – Create Volume
DESCRIPTION – Create a new ONTAP Cluster volume
JOB TYPE – Run
INVENTORY – Demo Inventory (* This is a default inventory created by Tower. This playbook uses localhost as the ‘hosts’ so a custom Inventory isn’t needed)
PROJECT – NetApp Tasks
PLAYBOOK – volume.yml (* This drop down is generated from the SCM pull)
CREDENTIALS – NetApp Admin (* These credentials were created in a previous post for AWX Tower)
Click the green ‘SAVE’ button.
This now is a Template we could run, however for anyone but me it will fail. Even if this succeeds for you it would always make the same volume, which isn’t very useful. This is where “SURVEYS” come into play. In AWX Tower, a survey is just a set of questions you can configure to be asked before a playbook is run and whose answers are stored as variables.
Next, you’ll want to click the blue “ADD SURVEY” button at the top of the Create Volume template options.
I want to ask for the Hostname, Vserver, Volume name, Aggregate Name, and Size.
Fill the survey form out similar to this. Here is a screen shot of the first prompt.
PROMPT – What Cluster will this volume be created on?
ANSWER VARIABLE NAME – hostname
ANSWER TYPE – Multiple Choice (single select)
MULTIPLE CHOICE OPTIONS – (here you want to enter your own IPs, one cluster per line
After you fill this out click the green “+ADD” button.
The other prompts are mostly the same thing except using ANSWER TYPE of ‘Text’ which changes the options, but the defaults for Text are fine.
PROMPT – What SVM will this volume be on?
ANSWER VARIABLE NAME – vserver
ANSWER TYPE – Text
PROMPT – What aggregate will this volume be on?
ANSWER VARIABLE NAME – aggrname
ANSWER TYPE – Text
PROMPT – What name will this volume have?
ANSWER VARIABLE NAME – volname
ANSWER TYPE – Text
PROMPT – What size (in GB) should this volume be?
ANSWER VARIABLE NAME – size
ANSWER TYPE – Text (* yes text not Integer or Float, it’s just easier for this example)
IMPORTANT: Be sure to click “+ADD” after each one
When you have all five prompts added click the green “SAVE” button on the Survey window. Then you need to again click the green “SAVE” on the Template details window.
After all the changes are saved, we can test this Template right from the Job Template window by clicking the blue “LAUNCH” button.
Fill in the questions to match your needs, and then click the green “NEXT” button. Tower will display a preview of the variables it will send that you have asked for and if they are what you want, click the green “LAUNCH”
When you manually launch a template from any of the methods that Tower allows, you will be automatically taken to the JOB page for that run.
From here you can watch progress and status, as well as refer back to the job parameters.
We will do one more example to showcase why I structured my playbook like I did. Now I will make a Volume Delete template.
Most of what I need already exists in the Create Volume template, so by going to the main Template page, I will copy the existing Templateusing the multipage icon to the right of the name. Now I can click on the copied Template name to edit it, in my example Create Volume@12:54:08 PM
I want to change the NAME to ‘Delete Volume’, DESCRIPTION to ‘Delete an ONTAP Cluster volume’. I also want to click on the blue “EDIT SURVEY” and remove the size and aggregate prompts from the survey, as well as change the question wording to make sense for deletes.
Finally, I want to add to the EXTRA VARIABLES section to change the state of the playbook run. If we don’t do this, the playbook will stick with the default for state which is set to present in the variables.
2 state: absent
Then I save this ‘new’ Template. I can launch this template and delete the volume I had just created.
I challenge you to copy the template again and this time adjust it so that it is a resize template. Note that currently aggregate is required whenever state: present.
Next time I will go over creating a Template Workflow and how to assign RBAC.
Any questions you have be sure to ask me on our #Slackworkspace in the #configurationmgmt channel. If you don’t have an invite to our Slack workspace get one at netapp.io/slack.