Hi James,
Awesome! Worked like a charm.
Thank you!
/Micke
On Sunday, September 14, 2014 8:09:21 PM UTC+2, Mikael Sandström wrote:
>
>
> Hi,
>
> I've got a dictionary as below. I loop through that dictionary using a
> value and grep a file searching to see if the value already exists. If it
> doesnt I want to use that value in the next task (mytask) to do something.
> If the value exists should just skip that value and move on.
> The grep command can only be 0 or 1 and I can see in the debug that is:
> "stdout": "0" #<-- value doesnt exists
> or
> "stdout": "1" #<-- value exists
>
>
> dictname:
> mykey1:
> myvalue: foo
> mykey2:
> myvalue: bar
> mykey3:
> myvalue: blerg
> ...
>
>
> ---
> - name: Check if line exists
> shell: grep {{ item.value.myvalue }} /some/file |wc -l
> with_dict: dictname
> register: check
>
> - debug: var=check.stdout
> with_items: check.results
>
>
> - name: Mytask
> template: src=asdad.j2 dest=/tmp/asdads .......
> with_dict: dictname
> when: check.stdout != "1"
>
>
>
> I'm not sure how to reference the result from the check in the 'when' in
> mytask. If I try the above I get this:
>
> error while evaluating conditional: check.stdout != "1"
>
> Any ideas?
>
> Thanks!
> /Micke
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b8903a5e-861e-4395-93af-97574baf7d9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.