Re: [ansible-project] Re: Access a variable defined in a playbook - within a role

2015-03-15 Thread Adrian Paraschiv
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 |

Re: [ansible-project] Re: Access a variable defined in a playbook - within a role

2015-03-15 Thread Adrian Paraschiv
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

[ansible-project] Re: Access a variable defined in a playbook - within a role

2015-03-15 Thread Chip Selden
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

[ansible-project] Re: How can I run a role with different variables in a loop? Or am I looking at things the wrong way

2015-03-15 Thread Chip Selden
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:

[ansible-project] Re: cannot substitute the key path with variable inside the lookup module

2015-03-15 Thread Arbab Nazar
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

[ansible-project] cannot substitute the key path with variable inside the lookup module

2015-03-15 Thread Arbab Nazar
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

Re: [ansible-project] register: variable as {{item}}?

2015-03-15 Thread Rick Kasten
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

Re: [ansible-project] register: variable as {{item}}?

2015-03-15 Thread Serge van Ginderachter
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