Skip to content
Open
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
16 changes: 16 additions & 0 deletions task/ansible-tower-cli/0.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM registry.access.redhat.com/ubi7/ubi

RUN curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
yum install ./epel-release-latest-*.noarch.rpm -y && \
yum update -y && \
yum install python-pip -y && \
pip install --upgrade pip && \
pip install ansible-tower-cli --no-cache-dir && \
yum clean all && \
rm -rf /var/cache/yum && \
rm -rf ~/.cache/pip

USER 1001

ENTRYPOINT ["/usr/bin/tower-cli/"]

86 changes: 86 additions & 0 deletions task/ansible-tower-cli/0.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

## Ansible Tower CLI Task

[Ansible Tower](https://ansible.com/tower) (formerly ‘AWX’) is a web-based solution that makes Ansible even more easy to use for IT teams of all kinds, It provides the `tower-cli`([Tower-CLI](https://docs.ansible.com/ansible-tower/latest/html/towerapi/tower_cli.html)) command line tool that simplifies the tasks of starting jobs, workflow jobs, manage users, projects etc.

## Install the Task

Install `tower-cli` task:
```
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/ansible-tower-cli/0.2/ansible-tower-cli.yaml
```

## Parameters

* **ARGS:** args to execute which are appended to `tower-cli` e.g. `user-list` (_default_: `--help`)
* **SSLVERIFY:** args to disable Tower SSL verification (_default_: `false`)
* **HOST:** The Ansible Tower HOST
* **tower-secret:** the name of the secret containing the user and password for authentication on the ansible tower host (_default_: `tower-creds`)

## Tower-Secret

This is a [secret]([https://kubernetes.io/docs/concepts/configuration/secret/](https://kubernetes.io/docs/concepts/configuration/secret/)) example with USER and PASS information that are going to be used by the task

```yaml
kind: Secret
apiVersion: v1
metadata:
name: tower-creds
namespace: ansible-tower-pipelines-test
selfLink: /api/v1/namespaces/ansible-tower-pipelines-test/secrets/tower-creds
uid: 024681c0-f4e8-11e9-81e2-52fdfc072182
resourceVersion: '721636'
creationTimestamp: '2019-10-22T16:21:31Z'
data:
PASS: YWRtaW50b3dlcg==
USER: YWRtaW4=
type: Opaque
```


To create a secret you can use the following command

```
kubectl create secret generic tower-creds --from-literal=username=TOWER_USER --from-literal=password=TOWER_USER_PASSWORD
```

## ServiceAccount

If you don't specify a service account to be used for running the `TaskRun` or `PipelineRun`, the `default` [service account](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-server). OpenShift by default does not allow the default service account to modify objects in the namespace. Therefore you should either explicitly grant permission to the default service account (by creating rolebindings) or [create a new service account with sufficient privileges](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#service-account-permissions) and specify it on the [`TaskRun`](https://github.com/tektoncd/pipeline/blob/main/docs/taskruns.md#service-account) or [`PipelineRun`](https://github.com/tektoncd/pipeline/blob/main/docs/pipelineruns.md#service-account).

You can do the former via `oc` and running the following command, replacing `<namespace>` with your target namespace:
```
oc policy add-role-to-user edit -z default -n <namespace>
```

## Platforms

The Task can be run on `linux/amd64` platform.

## Usage

This is a pipeline example passing the required credentials, and a list of arguments to the ARGS array variable.

```yaml
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: tower-cli-example
spec:
tasks:
- name: tower
taskRef:
name: ansible-tower-cli
params:
- name: SSLVERIFY
value: "false"
- name: HOST
value: "10.8.109.202"
- name: tower-secret
value: "tower-creds"
- name: ARGS
value:
- user
- list

```
70 changes: 70 additions & 0 deletions task/ansible-tower-cli/0.2/ansible-tower-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: ansible-tower-cli
labels:
app.kubernetes.io/version: "0.2"
annotations:
tekton.dev/pipelines.minVersion: "0.50.0"
tekton.dev/categories: CLI
tekton.dev/tags: ansible, cli
tekton.dev/displayName: "ansible tower cli"
tekton.dev/platforms: "linux/amd64"
spec:
description: >-
Ansible-tower-cli task simplifies starting jobs, workflow jobs,
manage users, projects etc.

Ansible Tower (formerly ‘AWX’) is a web-based solution that makes Ansible
even more easy to use for IT teams of all kinds, It provides the
tower-cli(Tower-CLI) command line tool that simplifies the tasks of
starting jobs, workflow jobs, manage users, projects etc.

params:
- name: SSLVERIFY
description: Disable tower ssl verification
default: "false"
type: string
- name: ARGS
description: The tower-cli commands to tun
type: array
default:
- "--help"
- name: HOST
description: The Ansible Tower host
type: string
default: ""
- name: tower-secret
description: The Ansible Tower secret with credentials
type: string
default: "tower-creds"
steps:
- name: config
image: quay.io/rcmendes/ansible-tower-cli@sha256:3a61778f410526db8d6e02e87715d58ee770c4a4faf57ac408cb5ec1a025ef2c #tag: latest
command:
- '/bin/sh'
- '-c'
args:
- |-
echo -e "verify_ssl = $(params.SSLVERIFY)\nverbose = true\nhost = $(params.HOST)\nusername = $USER\npassword = $PASS" > ~/.tower_cli.cfg
chmod 600 ~/.tower_cli.cfg
echo "Generated tower_cli.cfg file"
echo "-----------------------------"
ls -lah ~/ | grep tower_cli
echo "-----------------------------"
env:
- name: USER
valueFrom:
secretKeyRef:
name: $(params.tower-secret)
key: USER
- name: PASS
valueFrom:
secretKeyRef:
name: $(params.tower-secret)
key: PASS
- name: tower-cli
image: quay.io/rcmendes/ansible-tower-cli@sha256:3a61778f410526db8d6e02e87715d58ee770c4a4faf57ac408cb5ec1a025ef2c #tag: latest
command: ["/usr/bin/tower-cli"]
args:
- "$(params.ARGS)"
75 changes: 75 additions & 0 deletions task/aws-cli/0.3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# aws

This task performs operations on Amazon Web Services resources using `aws`.

All aws cli commands can be found [here](https://docs.aws.amazon.com/cli/latest/reference/).

## Install the Task

```
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/aws-cli/0.3/aws-cli.yaml
```

## Parameters

- **SCRIPT**: The script of aws commands to execute e.g. `aws $1 $2` This will take
the first value and second value of ARGS as `s3` and `ls` (default: `aws $@`)
- **ARGS**: The arguments to pass to `aws` CLI, which are appended
to `aws` e.g. `s3 ls` ( default: `["help"]` ).


## Workspaces

- **source**: To mount file which is to be uploaded to the aws resources,
this should be mounted using any volume supported in workspace.
- **secrets**: A workspace that consists of credentials required by `aws` which will be mounted to $HOME/.aws.
This workspace can be omitted when using instance-profile credentials.


## Secret

AWS `credentials` and `config` both should be provided in the form of `secret`.

[This](../0.2/samples/secret.yaml) example can be referred to create `aws-credentials`.

Refer [this](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/setup-credentials.html) guide for setting up AWS Credentials and Region.

## Platforms

The Task can be run on `linux/amd64` platform.

## Usage

After creating the task, you should now be able to execute `aws` commands by
specifying the command you would like to run as the `ARGS` or `SCRIPT` param.

The `ARGS` param takes an array of aws subcommands that will be executed as
part of this task and the `SCRIPT` param takes the multiple commands that you would like to run on aws CLI.

This [samples](../0.2/samples/secret.yaml), can be referred to create secret file for aws credentials.

In the [samples](../0.2/samples/run.yaml), ConfigMap as the volume is used. In place of ConfigMap, any volume supported in workspace can be used.

Following `command` can be used to create `ConfigMap` from the `file`.
```
kubectl create configmap upload-file --from-file=demo.zip
```
Here `upload-file` is the name of the `ConfigMap`, this can be changed based on the requirements.

See [here](../0.2/samples/run.yaml) for example of `aws s3` command.


### Note


- Either `SCRIPT` or `ARGS` must be provided in the `params` of the task.

- To support multiple `aws` commands to run on a single task, SCRIPT can be used as follows:

```yaml
- name: SCRIPT
value: |
aws s3 mb s3://test-bucket
aws s3api put-object --bucket test-bucket --key test/
aws s3 cp $(workspaces.source.path)/demo.zip s3://test-bucket/test/demo.zip
```
41 changes: 41 additions & 0 deletions task/aws-cli/0.3/aws-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: aws-cli
labels:
app.kubernetes.io/version: "0.3"
annotations:
tekton.dev/pipelines.minVersion: "0.50.0"
tekton.dev/categories: CLI
tekton.dev/tags: cli
tekton.dev/displayName: "aws cli"
tekton.dev/platforms: "linux/amd64"
spec:
description: >-
This task performs operations on Amazon Web Services resources using aws.

workspaces:
- name: source
optional: true
- name: secrets
optional: true
mountPath: /tekton/home/.aws
params:
- name: SCRIPT
description: The AWS script to run
type: string
default: "aws $@"
- name: ARGS
description: AWS cli arguments to be passed
type: array
default: ["help"]
stepTemplate:
env:
- name: "HOME"
value: "/tekton/home"
steps:
- name: awscli
image: docker.io/amazon/aws-cli:2.0.52@sha256:1506cec98a7101c935176d440a14302ea528b8f92fcaf4a6f1ea2d7ecef7edc4 #tag: 2.0.52
script: eval "$(params.SCRIPT)"
args:
- "$(params.ARGS)"
24 changes: 24 additions & 0 deletions task/aws-cli/0.3/samples/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
generateName: aws-run-
spec:
taskRef:
name: aws-cli
params:
- name: SCRIPT
value: |
aws $1 mb s3://$2
aws s3api put-object --bucket $2 --key test/
aws $1 cp $(workspaces.source.path)/demo.zip s3://$2/test/demo.zip
- name: ARGS
value:
- s3
- diagrawa-test
workspaces:
- name: secrets
secret:
secretName: aws-credentials
- name: source
configMap:
name: upload-file
20 changes: 20 additions & 0 deletions task/aws-cli/0.3/samples/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Secret
metadata:
name: aws-credentials
type: Opaque
stringData:
credentials: |-
[$(profile-name)]
aws_access_key_id = $(aws_access_key_id)
aws_secret_access_key = $(aws_secret_access_key)

[default]
aws_access_key_id = $(aws_access_key_id)
aws_secret_access_key = $(aws_secret_access_key)
config: |-
[profile $(profile-name)]
region = us-east-1
output = text
[default]
region = us-east-2
43 changes: 43 additions & 0 deletions task/az/0.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# `az`

This task performs operations on Microsoft Azure resources using `az`.

## Install the Task

```
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/az/0.2/az.yaml
```

## Parameters

* **az-image**: `az` CLI container image to run this task.

_default_: `mcr.microsoft.com/azure-cli:2.0.77`

You can use a specific version of the `az` CLI by specifying the `az-image` param with the `mcr.microsoft.com/azure-cli` image tagged with the specific version of the CLI you would like to use (i.e. version 2.0.70 = `mcr.microsoft.com/azure-cli:2.0.70`). A full list of available version tags can be found under the [Full Tag Listing](https://hub.docker.com/_/microsoft-azure-cli) section of the `az` Docker Hub.

* **ARGS**: The arguments to pass to `az` CLI. This parameter is required to run this task.

## Platforms

The Task can be run on `linux/amd64` platform.

## Usage

### Running the Task

After creating the task, you should now be able to execute `az` commands by specifying the command you would like to run as the `ARGS` param. The `ARGS` param takes an array of `az` subcommands that will be executed as part of this task.

### Examples

Run `az ad --help` using `az`. Start the task using the Tekton CLI (`tkn`):

```shell
tkn task start az -p ARGS=ad,--help
```

Specify a different `az-image` to use with the `az` task:

```shell
tkn task start az -p az-image=mcr.microsoft.com/azure-cli:2.0.70
```
Loading
Loading