Hello, I’m new to Ansible, I’m using DigitalOcean cloud, but my question concerns general Ansible scripting.
We have an application that requires, say, 40 servers during Saturday and Sunday and only 20 servers during week days.
I’m trying to compose a playbook that, given a desired quantity of machines, compares it with actual number of machines and:
— if desired < actual: performs include/block/role/whatever that sets up new machines until the desired quantity of machines is reached
— else: randomly shuts down machines in the cloud until the desired quantity is reached.
I found that it is surprisingly difficult to achive with Ansible. There are no -block with :until loop, -include with :until loop seems not to work with variables that are
set inside include. What I was able to do so far is calculating ‘delta’ variable and using ‘with_sequence’ which is not that I actually need, since execution inside the loop may fail to add/shut down a machine.
What whould you suggest as a ‘right Ansible way’ to do what we need, to achive “there are N servers in the cloud” state?
Regards,
Ivan