Skip to content

Commit

Permalink
feat: Add Tekton resources for deploy RPM package via AWX (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-nedostup committed Aug 27, 2024
1 parent 9ff4ca9 commit 5450e16
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: deploy-ansible-awx
labels:
app.edp.epam.com/pipelinetype: deploy
spec:
description: |
This Pipeline is designed for deploying RPM packages
to target servers (environments) using tower-cli tool. It automates
the deployment process by invoking Ansible AWX through the command line,
ensuring a streamlined and consistent installation of RPM packages across
the specified environment.
params:
- name: pipelineUrl
description: |
URL of the pipeline run in Tekton Dashboard.
type: string
default: https://portal-{{ .Release.Namespace }}.{{ .Values.global.dnsWildCard }}/c/main/pipelines/$(context.pipelineRun.namespace)/$(context.pipelineRun.name)
- name: CDPIPELINE
description: |
EDP kind:CDPipeline name used for deployment. For example: mypipe, myfeature
type: string
- name: CDSTAGE
description: |
EDP kind:Stage name of the kind:CDPipeline defined in the CDPIPELINE values. For example: dev, test, prod
type: string
- name: APPLICATIONS_PAYLOAD
description: |
Applications payload in format: {"codebase1": {"imageTag": "version1", "customValues": true}, "codebase2": {"imageTag": "version2", "customValues": true}}. For example: {"demo": {"imageTag": "main-20240103-141431", "customValues": true}, "myapp": {"imageTag": "0.1.0-SNAPSHOT.1", "customValues": true}}
type: string
tasks:
- name: pre-deploy
taskRef:
kind: Task
name: run-quality-gate
params:
- name: BASE_IMAGE
value: "bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
value:
echo "Hello World"

- name: deploy-app
taskRef:
kind: Task
name: deploy-ansible-awx
runAfter:
- pre-deploy
params:
- name: PIPELINE
value: $(params.CDPIPELINE)
- name: STAGE
value: $(params.CDSTAGE)
- name: APPLICATIONS_PAYLOAD
value: $(params.APPLICATIONS_PAYLOAD)

- name: post-deploy
taskRef:
kind: Task
name: run-quality-gate
runAfter:
- deploy-app
params:
- name: BASE_IMAGE
value: "bitnami/kubectl:1.25.4"
- name: EXTRA_COMMANDS
value:
echo "Hello World"

- name: promote-images
taskRef:
kind: Task
name: promote-images
runAfter:
- post-deploy
params:
- name: APPLICATIONS_PAYLOAD
value: $(params.APPLICATIONS_PAYLOAD)
- name: CDPIPELINE_STAGE
value: $(params.CDSTAGE)
- name: CDPIPELINE_CR
value: $(params.CDPIPELINE)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: deploy-ansible-awx
spec:
description: >
This Task is designed to configure the tower-cli tool and invoke
an Ansible AWX Template that runs an Ansible Playbook for installing
RPM packages on target servers.
params:
- description: >
Applications payload in format: {"codebase1": {"imageTag": "version1",
"customValues": true}, "codebase2": {"imageTag": "version2",
"customValues": true}}.
name: APPLICATIONS_PAYLOAD
type: string
- description: >
EDP kind:CDPipeline name used for deployment. For example: mypipe,
myfeature
name: PIPELINE
type: string
- description: >
EDP kind:Stage name of the kind:CDPipeline defined in the CDPIPELINE
values. For example: dev, test, prod
name: STAGE
type: string
steps:
- name: deploy-ansible-awx
image: epamedp/tekton-ansible:0.1.1
env:
- name: APPLICATIONS_PAYLOAD
value: $(params.APPLICATIONS_PAYLOAD)
- name: PIPELINE
value: $(params.PIPELINE)
- name: STAGE
value: $(params.STAGE)
- name: AWX_HOST
valueFrom:
secretKeyRef:
name: ci-awx
key: url
- name: AWX_USERNAME
valueFrom:
secretKeyRef:
name: ci-awx
key: username
- name: AWX_PASSWORD
valueFrom:
secretKeyRef:
name: ci-awx
key: password
script: |
#!/usr/bin/env sh
set -eu
tower-cli config host ${AWX_HOST}
tower-cli config username ${AWX_USERNAME}
tower-cli config password ${AWX_PASSWORD}
tower-cli config verify_ssl false
tower-cli job launch --job-template=package-install \
--extra-vars="{\"APPLICATIONS_PAYLOAD\":${APPLICATIONS_PAYLOAD},\"STAGE\":\"${STAGE}\",\"PIPELINE\":\"${PIPELINE}\"}" \
--inventory=${PIPELINE} --wait --limit=${PIPELINE}_${STAGE}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: deploy-ansible-awx
labels:
app.edp.epam.com/pipelinetype: deploy
spec:
params:
- name: APPLICATIONS_PAYLOAD
description: |
Applications payload in format: {"codebase1": {"imageTag": "version1", "customValues": true}, "codebase2": {"imageTag": "version2", "customValues": true}}. For example: {"demo": {"imageTag": "main-20240103-141431", "customValues": true}, "myapp": {"imageTag": "0.1.0-SNAPSHOT.1", "customValues": true}}
- name: CDPIPELINE
description: |
EDP kind:CDPipeline name used for deployment. For example: mypipe, myfeature
- name: CDSTAGE
description: |
EDP kind:Stage name of the kind:CDPipeline defined in the CDPIPELINE values. For example: dev, test, prod
resourcetemplates:
- apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: deploy-$(tt.params.CDPIPELINE)-$(tt.params.CDSTAGE)-
labels:
app.edp.epam.com/cdpipeline: $(tt.params.CDPIPELINE)
app.edp.epam.com/cdstage: $(tt.params.CDPIPELINE)-$(tt.params.CDSTAGE)
app.edp.epam.com/pipelinetype: deploy
spec:
taskRunTemplate:
serviceAccountName: tekton
pipelineRef:
name: deploy-ansible-awx
params:
- name: APPLICATIONS_PAYLOAD
value: $(tt.params.APPLICATIONS_PAYLOAD)
- name: CDSTAGE
value: $(tt.params.CDSTAGE)
- name: CDPIPELINE
value: $(tt.params.CDPIPELINE)

0 comments on commit 5450e16

Please sign in to comment.