This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from cooktheryan/ansible_scaffold
Initial commit of launching an Ansible Job through AAP
- Loading branch information
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Launch an Ansible Automation Platform Job | ||
This template requires a secret to be defined that provides the URL for Ansible Automation Platform as well as a token to interact with Ansible Automation Platform. | ||
|
||
* Generate a Write token within AAP https://docs.ansible.com/automation-controller/4.1.0/html/userguide/applications_auth.html#add-tokens | ||
* Manually create a Kubernetes Secret or create a secret using a secure secret solution such as Vault | ||
|
||
Provide the value of token and host as it relates to your environment. | ||
``` | ||
kubectl create secret generic aapaccess -n aap --from-literal=token=$TOKEN --from-literal=host=$AAP_URL | ||
``` | ||
|
||
Once this secret has been generated on the cluster it is now possible to use the Ansible Job template. |
9 changes: 9 additions & 0 deletions
9
scaffolder-templates/ansible-job/skeleton/${{values.component_id}}-job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
apiVersion: tower.ansible.com/v1alpha1 | ||
kind: AnsibleJob | ||
metadata: | ||
name: ${{ values.component_id }}-job | ||
namespace: ${{ values.namespace }} | ||
spec: | ||
connection_secret: ${{ values.connection_secret }} | ||
job_template_name: ${{ values.jobTemplate }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
apiVersion: scaffolder.backstage.io/v1beta3 | ||
kind: Template | ||
metadata: | ||
name: ansible-job | ||
title: Ansible Job | ||
description: Launch an Ansible Job within Ansible Automation Platform | ||
tags: | ||
- recommended | ||
- aap | ||
spec: | ||
owner: janus-authors | ||
system: janus-idp | ||
type: service | ||
parameters: | ||
- title: Provide information about the GitHub location | ||
required: | ||
- githubOrg | ||
- repoName | ||
- owner | ||
- system | ||
properties: | ||
githubOrg: | ||
title: GitHub Organization | ||
type: string | ||
owner: | ||
title: Owner | ||
type: string | ||
description: Owner of the component | ||
repoName: | ||
title: Repository Name | ||
type: string | ||
system: | ||
title: System | ||
type: string | ||
ui:field: EntityPicker | ||
ui:options: | ||
catalogFilter: | ||
kind: | ||
- System | ||
- title: Ansible Job Definition | ||
required: | ||
- name | ||
- jobTemplate | ||
- description | ||
- namespace | ||
properties: | ||
name: | ||
title: Name of the Ansible Job | ||
type: string | ||
description: A unique name for the Ansible Job | ||
jobTemplate: | ||
title: Name of the Job Template to launch | ||
type: string | ||
description: Specify a job template to launch | ||
description: | ||
title: Description | ||
type: string | ||
description: Provide a description of the Job to be launched | ||
namespace: | ||
title: Namespace | ||
type: string | ||
description: Specify the namespace to launch the job | ||
default: aap | ||
connection_secret: | ||
title: Connection Secret | ||
type: string | ||
description: Specify the connection secret to use for the job | ||
default: aapaccess | ||
steps: | ||
- id: template | ||
name: Generating the source code component | ||
action: fetch:template | ||
input: | ||
url: ./skeleton | ||
targetPath: argo/ansibleJobs/ | ||
values: | ||
component_id: ${{ parameters.name }} | ||
jobTemplate: ${{ parameters.jobTemplate }} | ||
name: ${{ parameters.name }} | ||
namespace: ${{ parameters.namespace }} | ||
connection_secret: ${{ parameters.connection_secret }} | ||
|
||
- id: catalogTemplate | ||
name: Generating the Catalog Info Component | ||
action: fetch:template | ||
input: | ||
url: ../../scaffolder-skeletons/catalog-info-skeleton/ | ||
values: | ||
githubOrg: ${{ parameters.githubOrg }} | ||
repoName: ${{ parameters.repoName }} | ||
owner: ${{ parameters.owner }} | ||
applicationType: api | ||
description: ${{ parameters.description }} | ||
|
||
- id: publish | ||
name: Publishing to Source Code Repository | ||
action: publish:github:pull-request | ||
input: | ||
allowedHosts: ['github.com'] | ||
title: ${{ parameters.name }}-job | ||
description: ${{ parameters.name }}-job | ||
repoUrl: github.com?owner=${{ parameters.githubOrg }}&repo=${{ parameters.repoName }} | ||
branchName: ${{ parameters.name }}-job | ||
|
||
- id: register | ||
name: Registering the Catalog Info Component | ||
action: catalog:register | ||
input: | ||
repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }} | ||
catalogInfoPath: /catalog-info.yaml | ||
|
||
output: | ||
links: | ||
- title: Source Code Repository | ||
url: ${{ steps.publish.output.remoteUrl }} | ||
- title: Open the Catalog Info Component | ||
icon: catalog | ||
entityRef: ${{ steps.register.output.entityRef }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters