I found the solution:
You can use the set_fact module to increment your variable:
- set_fact: some_variable={{ some_variable | int + 1 }}
Your condition for running the extra task then should look like this:
when: some_variable | int == 5
Make sure you always cast the value to and int with |
That's a very big workaround for a simple var++ stuff :)
It weird to say "Ansible's human-readable IT automation language" and you
can't even do a basic value to variable assignment
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscri
Adrian,
Interesting idea. Ansible is tricky when it comes to assigning values to
variables and having them persist through roles, plays, or between hosts. I
don't know about how you could manipulate variable values, but one way I've
found to keep track of things between plays and hosts is by wo
gitted,
Your approach depends on how you're organizing your variables. Ansible (as
of now) does not let you loop through roles or includes. The best way to do
this is to loop in each task.
Here's a sample:
vars:
apps:
app1:
path: /var/www/app1
build: app1.tar
app2:
Hi I am able to get it working, totally my mistake, due to limited janja2
knowledge. Thanks
I was making a mistake here:
On Sunday, March 15, 2015 at 8:50:24 PM UTC+5, Arbab Nazar wrote:
>
> Hi everyone,
>
> I have a problem again with the lookup module where it didn't substitute
> the key pa
Hi everyone,
I have a problem again with the lookup module where it didn't substitute
the key path with variable. here is my var file
vars/ec2_key.yml
Here is my task file:
---
key_name: nat_key
ssh_key_location: ~/.ssh/id_rsa.pub
tasks/ec2_key.yml
---
- name: display variable
debug: v
I plan to run 'alternatives --install {{ item }} yadayada' for each in the
list which will be only those items for which the above shell: command
failed. I don't want to run it against all three all the time. So are you
saying that using a register: with multiple items will result in a list of
On 15 March 2015 at 05:55, Rick Kasten wrote:
> Nothing's stopping me. I don't know what you're referring to.
I meant, don;t use the jinja variable construct on register, just a plain
variable.
A registered variable on with_items will have a list of registered results.
Perhaps you need to to