-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Tekton resources for deploy RPM Package via AWX (#277)
- Loading branch information
1 parent
9ff4ca9
commit b1bee9b
Showing
3 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
charts/pipelines-library/templates/pipelines/cd/deploy-ansible-awx.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,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) |
63 changes: 63 additions & 0 deletions
63
charts/pipelines-library/templates/tasks/cd/deploy-ansible-awx.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,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} |
38 changes: 38 additions & 0 deletions
38
charts/pipelines-library/templates/triggers/cd/deploy-ansible-awx.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,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) |