Hello guys,

I have the following problem:
I'm reading a simple json file which contains some names of my hosts.
The file looks like this:
 {  "redundancynode": "node4", "service": "dhcp", "servicenode" "node1" }

Now i have a task to read the contents of that file:
  
 vars:
   file_content: "{{ lookup('file', '/tmp/info') }}

  tasks:
     - name: Read from local file /tmp/info
       debug: 
         msg: "{{ file_content }}"

The Output of Ansible for that file looks like this:

ok: [127.0.0.1] => {
    "msg": {
        "redundancynode": "node4",
        "service": "dhcp",
        "servicenode": "node1"
    }
}
I used set_fact to get the actual nodes for servicenode and redundancynode:

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

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

debggung for example redundancynode gives me as expected the following 
output:

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

Now,  I want to use the content of "redundancy node", which is "node4" in 
another task as condition:
when: inventory_hostname == "redundanynode"

But this does not work. It just skips the task for all nodes.

(BTW: node4 does exist in my inventory file of course) 

What am I missing? Im searching  for a solution since hours.

Thank you advance!

-- 
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/c66990f7-be94-40c5-a4fe-346c76ec8655n%40googlegroups.com.

Reply via email to