Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #120 from cooktheryan/ansible_scaffold
Browse files Browse the repository at this point in the history
Initial commit of launching an Ansible Job through AAP
  • Loading branch information
christophe-f authored Jun 21, 2023
2 parents d8f2de9 + d1eaf77 commit 709cfc1
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
12 changes: 12 additions & 0 deletions scaffolder-templates/ansible-job/README.md
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.
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 }}
118 changes: 118 additions & 0 deletions scaffolder-templates/ansible-job/template.yaml
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 }}
1 change: 1 addition & 0 deletions showcase-templates.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ spec:
- https://github.com/janus-idp/software-templates/blob/main/scaffolder-templates/spring-boot-backend-template/template.yaml
- https://github.com/janus-idp/software-templates/blob/main/scaffolder-templates/quarkus-backend-template/template.yaml
- https://github.com/janus-idp/software-templates/blob/main/scaffolder-templates/argocd-template/template.yaml
- https://github.com/janus-idp/software-templates/blob/main/scaffolder-templates/ansible-job/template.yaml

0 comments on commit 709cfc1

Please sign in to comment.