Thank you for your Input.

But what do you mean by setting the variable?

I thought im setting the variable by using set_fact:

- set_fact: redundancynode="{{output.msg.redundancynode}}" 

- set_fact: servicenode="{{ output.msg.servicenode }}"

By using  this task:
  - debug: 
        msg: "{{ redundancynode }}"

I already get the correct output

ok: [127.0.0.1] => {
    "msg": "node4"
}

So the variable redundancynode should contain "node4", isn't it?

[email protected] schrieb am Dienstag, 8. September 2020 um 14:14:54 UTC+2:

> On 9/8/20 1:47 PM, [email protected] wrote:
> > I tried this, but it just gives me error:
> > "The conditional check 'inventory_hostname == redundancynode' failed. 
> The error was: error while evaluating conditional
> > (inventory_hostname == redundancynode): 'redundancynode' is undefined"
>
> You have to set this variable, otherwise your playbook doesn't work.
>
> > 
> > It is also not possible to use jinja2 for that
> > 
> > when: inventory_hostname == {{ redundancynode }} or
> > when: inventory_hostname == "{{ redundancynode }}"
>
> when conditions are automatically wrapped in curly braces, so it is Jinja 
> already.
>
> > 
> > Can the problem be that redundancynode is already in quotes?
> > 
> > So that ansible is reading this as:
> > when: inventory_hostname == ""node4""
>
> See above.
>
> Regards
> Racke
>
> > 
> > 
> > [email protected] schrieb am Dienstag, 8. September 2020 um 13:26:35 
> UTC+2:
> > 
> > On 9/8/20 1:20 PM, Peter Gebirgslok wrote:
> > > I dont know how to edit my post, but there is also no typo in the when 
> condition
> > >
> > > this i how the when condition looks like.
> > >
> > > when: inventory_hostname == "redundancynode"
> > >
> > 
> > You can't edit your post of course. Change that line to:
> > 
> > when: inventory_hostname == redundancynode
> > 
> > Regards
> > Racke
> > 
> > > --
> > > 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] <mailto:
> [email protected]>.
> > > To view this discussion on the web visit
> > > 
> https://groups.google.com/d/msgid/ansible-project/1b42b037-424a-4028-a742-703be574f215o%40googlegroups.com
> > >
> > <
> https://groups.google.com/d/msgid/ansible-project/1b42b037-424a-4028-a742-703be574f215o%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
> > [email protected] <mailto:
> [email protected]>.
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/ansible-project/016641c5-92b0-4940-93c5-3fe154f368d3n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/016641c5-92b0-4940-93c5-3fe154f368d3n%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20ed1dc9-dd21-467d-8707-f3fdad7732fbn%40googlegroups.com.

Reply via email to