Custom Backstage actions
The following actions enable you to manage Ansible Automation Platform resources within a software template workflow.
rhaap:create-project Copy linkLink copied!
Create an Ansible Automation Platform project that links to a source control repository containing Ansible content.
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
OAuth2 token for Ansible Automation Platform authentication. |
| |
boolean |
No |
If |
| |
object |
Yes |
The project configuration object. See the "values" Object Structure table. |
“values” Object Structure
| Field | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
Name of the project. |
| |
string |
No |
Description of the project. |
| |
object |
Yes |
Organization object with |
| |
object |
No |
Credential object with |
| |
string |
Yes |
Source control URL (for example, GitHub/GitLab repository URL). |
| |
string |
No |
Source control branch, tag, or commit. |
| |
boolean |
No |
If |
Output parameters
| Parameter | Type | Description |
|---|---|---|
| |
object |
Created project details. |
| |
number |
Project ID in Ansible Automation Platform (AAP). |
| |
string |
Project name. |
| |
string |
Project description. |
| |
string |
Ansible Automation Platform URL for the project. |
Example
steps:
- id: create-aap-project
name: Create AAP Project
action: rhaap:create-project
input:
token: ${{ parameters.AAP_TOKEN }}
deleteIfExist: true
values:
projectName: ${{ parameters.projectName }}
organization: ${{ parameters.organization }}
scmUrl: https://github.com/my-org/ansible-playbooks
scmBranch: main
scmUpdateOnLaunch: true
credentials: GitHub Token
rhaap:create-execution-environment Copy linkLink copied!
Create an execution environment in Ansible Automation Platform that defines the container image used to run Ansible jobs.
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
OAuth2 token for Ansible Automation Platform authentication. |
| |
boolean |
No |
If |
| |
object |
Yes |
The execution environment configuration object. |
“values” Object Structure
| Field | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
Name of the execution environment. |
| |
string |
No |
Description of the execution environment. |
| |
object |
Yes |
Organization object with required |
| |
string |
Yes |
Full image location, including registry, image name, and tag (for example, |
| |
string |
No |
Image pull policy: |
Output parameters
| Parameter | Type | Description |
|---|---|---|
| |
object |
Created execution environment details. |
| |
number |
Execution environment ID. |
| |
string |
Execution environment name. |
| |
string |
Execution environment description. |
| |
string |
Ansible Automation Platform (AAP) URL for the execution environment. |
Example
steps:
- id: create-ee
name: Create Execution Environment
action: rhaap:create-execution-environment
input:
token: ${{ parameters.AAP_TOKEN }}
deleteIfExist: false
values:
environmentName: Custom EE
environmentDescription: Execution environment with custom collections
organization: ${{ parameters.organization }}
image: quay.io/ansible/creator-ee:v0.16.0
pull: missing
rhaap:create-job-template Copy linkLink copied!
Create a job template in Ansible Automation Platform that defines a reusable configuration for running Ansible playbooks.
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
OAuth2 token for Ansible Automation Platform authentication. |
| |
boolean |
No |
If |
| |
object |
Yes |
The job template configuration object. |
“values” Object Structure
| Field | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
Name of the job template. |
| |
string |
No |
Description of the job template. |
| |
object |
Yes |
Project object with required |
| |
object |
No |
Organization object with |
| |
object |
Yes |
Inventory object with required |
| |
string |
Yes |
Path to the playbook file to execute. |
| |
string |
No |
Description of the job template. |
| |
string |
No |
Source control type (for example, |
| |
object |
No |
Execution environment object with required |
| |
object |
No |
Extra variables to pass to the playbook (key-value pairs). |
Output parameters
| Parameter | Type | Description |
|---|---|---|
| |
object |
Created job template details. |
| |
number |
Job template ID. |
| |
string |
Job template name. |
| |
string |
Job template description. |
| |
string |
Ansible Automation Platform (AAP) URL for the job template. |
Example
steps:
- id: create-job-template
name: Create Job Template
action: rhaap:create-job-template
input:
token: ${{ parameters.AAP_TOKEN }}
deleteIfExist: true
values:
templateName: Deploy Application
templateDescription: Deploys the application to production
project: ${{ steps['create-aap-project'].output.project }}
organization: ${{ parameters.organization }}
jobInventory: ${{ parameters.jobInventory }}
playbook: deploy.yml
executionEnvironment: ${{ steps['create-ee'].output.executionEnvironment }}
extraVariables:
app_version: 1.0.0
environment: production
rhaap:launch-job-template Copy linkLink copied!
Launch an existing job template in Ansible Automation Platform.
Input parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
OAuth2 token for Ansible Automation Platform authentication. |
| |
object |
Yes |
The job launch configuration object. |
“values” Object Structure
| Field | Type | Required | Description |
|---|---|---|---|
| |
string |
Yes |
Job template name to launch. |
| |
object |
No |
Override inventory with |
| |
array |
No |
Array of credential objects to use. |
| |
object |
No |
Extra variables to pass to the job (key-value pairs). |
| |
string |
No |
Host pattern to constrain which hosts the job runs against. |
| |
string |
No |
Job type: |
| |
object |
No |
Override execution environment with |
| |
object |
No |
Verbosity level object with |
| |
number |
No |
Number of parallel processes (default: |
| |
number |
No |
Divide the job into N slices. |
| |
number |
No |
Job timeout in seconds ( |
| |
boolean |
No |
Enable diff mode to show changes. |
| |
string |
No |
Comma-separated tags to run only specific tasks. |
| |
string |
No |
Comma-separated tags to skip specific tasks. |
Output parameters
| Parameter | Type | Description |
|---|---|---|
| |
object |
Job execution details. |
| |
number |
Job ID. |
| |
string |
Job status. |
| |
string |
Ansible Automation Platform (AAP) URL for the job. |
Example
steps:
- id: launch-job
name: Launch Job Template
action: rhaap:launch-job-template
input:
token: ${{ parameters.AAP_TOKEN }}
values:
template: Deploy Application
inventory: ${{ parameters.jobInventory }}
credentials: ${{ parameters.credentials }}
extraVariables:
app_version: v1.0.1
deploy_env: production
jobType: run
verbosity: Normal
diffMode: true
timeout: 3600
Example with all backstage actions present Copy linkLink copied!
The following example displays how you can use multiple actions together.
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
name: ansible-complete-setup
title: Complete Ansible Setup
description: Creates an Ansible project, execution environment, job template, and launches it
spec:
owner: platform-team
type: service
parameters:
- title: Project Information
required:
- projectName
- repoUrl
properties:
projectName:
title: Project Name
type: string
description: Name of the Ansible project
repoUrl:
title: Repository URL
type: string
description: Git repository URL containing Ansible content
- title: AAP Configuration
required:
- organization
- jobInventory
- credentials
properties:
organization:
title: Organization
type: string
description: AAP Organization name
default: 1-org
ui:field: hidden # To hide this field in the UI
jobInventory:
title: Inventory name
type: string
description: AAP Inventory name
resource: inventories
ui:field: AAPResourcePicker
default: my-inventory
credentials:
title: Credentials
description: Select SCM credential for Private repositories
resource: credentials
ui:field: AAPResourcePicker
default: my-machine-credential
steps:
# Step 1: Create AAP Project
- id: create-project
name: Create AAP Project
action: rhaap:create-project
input:
token: ${{ parameters.AAP_TOKEN }}
deleteIfExist: true
values:
projectName: ${{ parameters.projectName }}
organization: ${{ parameters.organization }}
scmUrl: ${{ parameters.repoUrl }}
scmBranch: main
scmUpdateOnLaunch: true
# Step 2: Create Execution Environment
- id: create-ee
name: Create Execution Environment
action: rhaap:create-execution-environment
input:
token: ${{ parameters.AAP_TOKEN }}
values:
environmentName: ${{ parameters.projectName }}-ee
organization: ${{ parameters.organization }}
image: quay.io/ansible/creator-ee:latest
pull: missing
# Step 3: Create Job Template
- id: create-template
name: Create Job Template
action: rhaap:create-job-template
input:
token: ${{ parameters.AAP_TOKEN }}
values:
templateName: ${{ parameters.projectName }}-deploy
templateDescription: Deployment job template
project: ${{ steps['create-project'].output.project }}
organization: ${{ parameters.organization }}
jobInventory: ${{ parameters.jobInventory }}
playbook: site.yml
executionEnvironment: ${{ steps['create-ee'].output.executionEnvironment }}
# Step 4: Launch the Job
- id: launch-job
name: Launch Job
action: rhaap:launch-job-template
input:
token: ${{ parameters.AAP_TOKEN }}
values:
template: ${{ parameters.projectName }}-deploy
inventory: ${{ parameters.jobInventory }}
credentials: ${{ parameters.credentials }}
jobType: run
extraVariables:
created_by: backstage
timestamp: ${{ '' | now }}
output:
links:
- title: AAP Project
url: ${{ steps['create-project'].output.project.url }}
- title: Job Template
url: ${{ steps['create-template'].output.template.url }}
- title: Job Execution
url: ${{ steps['launch-job'].output.data.url }}