Re: [ansible-project] 'when: item not in' conditional issues?

2020-06-12 Thread Doug OLeary
That did the trick, sir, thank you!

I didn't see that syntax anywhere in my searching.  I would've spent much 
longer on that.  Thank you again.  I appreciate it.

Doug O'Leary

On Friday, June 12, 2020 at 8:42:59 AM UTC-5, Stefan Hornburg (Racke) wrote:
>
> On 6/12/20 3:34 PM, Doug OLeary wrote: 
> > Hey; 
> > 
> > I'm trying to execute pvcreate on a disk but would like to ensure I 
> don't run it on a disk that's already defined.  I 
> > have a short playbook that gathers facts, 
> displays ansible_lvm.pvs.keys() 
> > and then: 
> > 
> > | 
> >   -name:run pvcreate 
> > command:pvcreate /dev/{{item.key}} 
> > when:item.key isnotinansible_lvm.pvs.keys() 
> > with_dict:"{{disks}}" 
> > | 
> > 
> > That particular one resulted in: 
> > 
> > The error was: template error while templating string: expected token 
> 'end of statement block', got '.'. 
> > 
> > Even if it didn't error out, I suspect it wouldn't work because the keys 
> are: 
> > 
> > | 
> > "msg":"dict_keys(['/dev/sdd', '/dev/sdb1', '/dev/sdc', 
> '/dev/sda2'])" 
> > | 
> > 
> > I've also tried "when: /dev/item.key is not in..." and 'when: 
> "/dev/item.key" is not in..." Those two result in: 
> > 
> > The error was: template error while templating string: unexpected '/'. 
> > 
> > Any hints on how to verify "/dev/{{item.key}" is not in the pvs 
> dictionary? 
>
> Please try: 
>
>   when: "( '/dev/' + item.key ) not in ansible_lvm.pvs" 
>
> Regards 
> Racke 
>
> > 
> > Thanks 
> > 
> > Doug O'Leary 
> > 
> > -- 
> > 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 
> > ansible...@googlegroups.com   ansible-project+unsubscr...@googlegroups.com >. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/71ead50e-54ce-43d0-ac07-3640e68eeaedo%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/71ead50e-54ce-43d0-ac07-3640e68eeaedo%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d572dd6b-9e84-46a0-8a8a-510b49eb7ce3o%40googlegroups.com.


Re: [ansible-project] 'when: item not in' conditional issues?

2020-06-12 Thread Stefan Hornburg (Racke)
On 6/12/20 3:34 PM, Doug OLeary wrote:
> Hey;
> 
> I'm trying to execute pvcreate on a disk but would like to ensure I don't run 
> it on a disk that's already defined.  I
> have a short playbook that gathers facts, displays ansible_lvm.pvs.keys()
> and then:
> 
> |
>   -name:run pvcreate
>     command:pvcreate /dev/{{item.key}}
>     when:item.key isnotinansible_lvm.pvs.keys()
>     with_dict:"{{disks}}"
> |
> 
> That particular one resulted in:
> 
> The error was: template error while templating string: expected token 'end of 
> statement block', got '.'.
> 
> Even if it didn't error out, I suspect it wouldn't work because the keys are:
> 
> |
>     "msg":"dict_keys(['/dev/sdd', '/dev/sdb1', '/dev/sdc', '/dev/sda2'])"
> |
> 
> I've also tried "when: /dev/item.key is not in..." and 'when: "/dev/item.key" 
> is not in..." Those two result in:
> 
> The error was: template error while templating string: unexpected '/'.
> 
> Any hints on how to verify "/dev/{{item.key}" is not in the pvs dictionary?

Please try:

  when: "( '/dev/' + item.key ) not in ansible_lvm.pvs"

Regards
Racke

> 
> Thanks
> 
> Doug O'Leary
> 
> -- 
> 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
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/71ead50e-54ce-43d0-ac07-3640e68eeaedo%40googlegroups.com
> .


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7229be73-d5d5-8115-1f80-8d2778c85731%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


[ansible-project] 'when: item not in' conditional issues?

2020-06-12 Thread Doug OLeary
Hey;

I'm trying to execute pvcreate on a disk but would like to ensure I don't 
run it on a disk that's already defined.  I have a short playbook that 
gathers facts, displays ansible_lvm.pvs.keys()
and then:

  - name: run pvcreate
command: pvcreate /dev/{{item.key}}
when: item.key is not in ansible_lvm.pvs.keys()
with_dict: "{{disks}}"

That particular one resulted in:

The error was: template error while templating string: expected token 'end 
of statement block', got '.'.

Even if it didn't error out, I suspect it wouldn't work because the keys 
are:

"msg": "dict_keys(['/dev/sdd', '/dev/sdb1', '/dev/sdc', '/dev/sda2'])"

I've also tried "when: /dev/item.key is not in..." and 'when: 
"/dev/item.key" is not in..." Those two result in:

The error was: template error while templating string: unexpected '/'.

Any hints on how to verify "/dev/{{item.key}" is not in the pvs dictionary?

Thanks

Doug O'Leary

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/71ead50e-54ce-43d0-ac07-3640e68eeaedo%40googlegroups.com.