1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-21 05:55:35 +00:00
catalog/task/ansible-runner/0.1
vinamra28 e763a4473e Use latest git-clone in Task's tests
With git-clone version 0.8 and onwards, it started running as non-root
and GKE clusters were having some issues, so, we temporarily moved all
tasks to use git-clone version 0.7. Ref: https://github.com/tektoncd/catalog/pull/1079

Since we have now moved to kind clusters in our CI, this issue is now
resolved and thus moving all tasks to use latest version of git-clone

Signed-off-by: vinamra28 <jvinamra776@gmail.com>
2023-09-22 09:32:22 +01:00
..
support (fix) Ansible Runner Task 2020-08-10 10:13:05 +01:00
tests Use latest git-clone in Task's tests 2023-09-22 09:32:22 +01:00
ansible-runner.yaml Deprecate v0.1 of ansible-runner 2022-05-03 05:53:52 +01:00
README.md [TEP-0110] Update Tekton Catalog installation instructions 2022-08-16 16:25:52 +01:00

Ansible Runner

Ansible Runner Task allows running the Ansible Playbooks using the ansible-runner tool.

NOTE: This Task is now deprecated and will be removed soon as the image is removed from the dockerhub by the authors. Please use the version 0.2 instead.

Creating the Task

Create the Task and other resources:

kubectl apply --filename https://api.hub.tekton.dev/v1/resource/tekton/task/ansible-runner/0.1/raw

Verify the created tasks:

tkn task ls

Parameters

  • project-dir: The ansible-runner private data dir
  • args:: The array of arguments to pass to the runner command (default: --help)
  • user-home: Absolute path to the user's home directory. (default: /tekton/home)

Workspaces

Platforms

The Task can be run on linux/amd64 platform.

Usage

The TaskRun uses the repository https://github.com/kameshsampath/tektoncd-ansible-runner-example, that houses some example playbooks.

All the examples will be run in namespace called funstuff. Create the namespace and shift the context to it:

   kubectl create ns funstuff && \
   kubectl config set-context --current --namespace=funstuff

Create the PVC and clone example sources

kubectl apply -f https://api.hub.tekton.dev/v1/resource/tekton/task/git-clone/0.1/raw \
  -f  https://raw.githubusercontent.com/tektoncd/catalog/main/task/ansible-runner/0.1/support/playbooks-pvc.yaml

Do the git clone of the examples repository:

tkn task start git-clone \
  --workspace=name=output,claimName=ansible-playbooks \
  --param=url=https://github.com/kameshsampath/tektoncd-ansible-runner-example \
  --param=revision=master \
  --param=deleteExisting=true \
  --showlog

Create the Service Account

As we will do get, list and create on the namespace, lets use a service account that has right RBAC:

kubectl apply -f  https://raw.githubusercontent.com/tektoncd/catalog/main/task/ansible-runner/0.1/support/ansible-deployer.yaml

Run Tasks

List the pods of kube-system namespace:

 tkn task start ansible-runner \
   --serviceaccount ansible-deployer-account \
   --param=project-dir=kubernetes \
   --param=args=-p,list-pods.yml \
   --workspace=name=runner-dir,claimName=ansible-playbooks \
   --showlog

Create Deployment

Create a deployment in funstuff namespace:

 tkn task start ansible-runner \
   --serviceaccount ansible-deployer-account \
   --param=project-dir=kubernetes \
   --param=args=-p,create-deployment.yml \
   --workspace=name=runner-dir,claimName=ansible-playbooks \
   --showlog

Create Service

Create a service in funstuff namespace:

 tkn task start ansible-runner \
   --serviceaccount ansible-deployer-account \
   --param=project-dir=kubernetes \
   --param=args=-p,create-service.yml \
   --workspace=name=runner-dir,claimName=ansible-playbooks \
   --showlog