Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Tekton resources for deploy RPM package via AWX (#277) #278

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading