Play with argoCD API from ansible

Thomas Decaux
2 min readDec 31, 2021

--

I am a big fan of Ansible, as a good / lazy engineer, I love making everything automatic!

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. Basically, you declare applications such as Helm release in a git repository, then argoCD will transform this as K8S object, pretty cool (and good for lazy people ^^).

In this story, I am going to show some recipes I use to interact with argocd API, from ansible. Using the ansible URI module https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html, actually a very powerful module!

argoCD API doc ==> https://github.com/argoproj/argo-cd/blob/master/assets/swagger.json

The Ansible tasks

Variables

  • argocd_url => the URL to argoCD
  • argocd_project => the argoCD project to filter with
  • ARGO_TOKEN => env variable , the JWT token to use

List applications

This recipe is very useful to get all applications status, and click on application URL to see whats going on:

Sync applications

This recipe, to sync multiple applications and wait for result. For this one, we are going to use an ansible feature I love : “async”.

To run multiple task in //

Et voilà!

--

--