Add and launch custom self-service templates
Custom self-service templates are stored as YAML files in repositories in GitHub or Gitlab. When a user launches a software template from Ansible automation portal, they must fill in a form with the values needed to run the associated job template in Ansible Automation Platform.
Custom self-service templates are YAML files stored in GitHub or GitLab repositories. Each template defines a user form and one or more rhaap:* action steps that execute automation in Ansible Automation Platform.
In the steps section, reference the authentication token as ${{ secrets.aapToken }}. Ansible automation portal automatically injects this token when a user submits the form. Do not include token in the parameters.required list.
Business inputs such as software names, versions, or inventory selections belong in the parameters section. The values.template field must match the exact name of the job template in Ansible Automation Platform.
The following example shows a custom template that lets users select a software package and version, then launches the corresponding job template in Ansible Automation Platform:
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: software-installation
title: Software Installation
description: Install software via an AAP job template from the Automation Portal
spec:
owner: group:default/team-platform
type: service
parameters:
- title: Software
required:
- SoftwareName
- Softwareversion
properties:
SoftwareName:
type: string
title: Software name
enum:
- Postgresql
- Nginx
- Grafana
dependencies:
SoftwareName:
oneOf:
- properties:
SoftwareName:
const: Postgresql
Softwareversion:
type: string
title: Choose a version
enum:
- v13
- v14
- v16
required:
- Softwareversion
- properties:
SoftwareName:
const: Nginx
Softwareversion:
type: string
title: Choose a version
enum:
- v2.4
- v2.5
- v2.6
required:
- Softwareversion
- properties:
SoftwareName:
const: Grafana
Softwareversion:
type: string
title: Choose a version
enum:
- v2
- v3
- v4
required:
- Softwareversion
steps:
- id: launch-job
name: Launch AAP job template
action: rhaap:launch-job-template
input:
token: ${{ secrets.aapToken }}
values:
template: test job
extraVariables:
software_name: ${{ parameters.SoftwareName }}
software_version: ${{ parameters.Softwareversion }}Starting in Ansible Backstage Plugins v2.2.0, the portal no longer passes the OAuth token in template form values. Templates that use ${{ parameters.token }} in rhaap:* action steps will fail with a Could not create entity error. Always use ${{ secrets.aapToken }} to access the real OAuth token.
Add a template to Ansible automation portal
You can add a custom self-service template to the Templates view of your Ansible automation portal instance. Custom self-service templates are stored in git repositories. Ansible automation portal supports GitLab and GitHub Source Control Management (SCM).
Before you begin
- You have created repositories in your Git SCM for the templates that you want to use.
- In the git repository for your custom templates, ensure that the
metadata.namefield is unique and does not match an existing auto-generated template or another custom self-service template. For example, append*-customto the value of themetadata.namekey.
metadata:
name: provision-database-custom- You must be logged in to Ansible automation portal as an Ansible Automation Platform platform administrator.
About this task
Names for custom self-service templates must be unique. Custom self-service templates must have a different name to auto-generated job templates and also to other custom self-service templates.
Procedure
- In a browser, navigate to your Ansible automation portal instance and sign in with your Ansible Automation Platform credentials.
- Navigate to the Templates Page.
- Click .
- Enter a valid Git SCM URL for the template that you want to add.
- Click to fetch the template.
- After the template has been fetched, review the list of what will be imported and added to the catalog.
- Click .
Results
After the import is complete, return to the Templates page to view the newly created template. You can now launch your template.
What to do next
- You must configure RBAC for your imported custom templates to allow users to view and run them. To do this, you must be logged into Ansible automation portal as a platform administrator.
For more information, see Setting up RBAC for custom self-service templates.
Launch a template
This procedure describes how to launch a template from a tile in the Templates view of your Ansible automation portal instance.
Before you begin
- You have configured RBAC in Ansible Automation Platform for templates that are associated with Ansible Automation Platform job templates.