It’s the usual ‘suck at iterations’ problem in Ansible.
My problem:
mytasks: - name: foo repeat: 10 - name: bar repeat: 99
This is my Reddit comment about using one role from another in Ansible. I wrote it and realized it’s more deep than people asked for (their specific question), so I’m re-posting it as a separate article.
There are inevitable moments when you need to do loop calculations in Ansible. You have a group, and you need to extract some variable from all hosts in that group (except those who don’t have this variable), and use it for iteration, or for…
If you run Ansible via just ( as I do) you may want to see notification about completion at the end of the long playbook.
just
I wrote an article about how to do it for plain Ansible run
Forgot ‘fetch’, or ‘slurp’. Both are terrible to use. With big efforts I realized that synchronize CAN synchronize remote directory INTO local (on the controller).
synchronize
I just got a serious jq level up, rehearsing it here.
The problem: I need to get list of hosts in the Ansible inventory.
If you don’t know, I have a project called ‘ansible bingo’ [1]. It’s a small collection of the most hilarious not-a-bugs-or-bugs in Ansible, mostly around the way Jinja expressions are handled.
One of idiosyncrasies of Ansible with pytest (testinfra) is that whilst you have access to inventory, any Jinja there will mess up you badly, as you will have a literal value with mustaches instead of expected interpolation.
If you ever wonder why I’m been paid, this is it.
Goal: to find objects (in my case VMs) in gcp account which have specific labels but live for too long.