2 variables with same values being treated differently

This is a head scratcher, well for me anyways.

I have two values that are being treated as if they weren’t equal, yet everything on the debug is showing me they have the same value.

In the playbook, the debug msg shows that $riak_primary_node $primary_node have the same value, but when tested with when_string: $riak_primary_node == $primary_node they are shown not to be equal.

$riak_primary_node is derivced from a fact and $primary_node is derived from : primary_node: ${groups.tag_stackName_source_primary}.

I’d like ${hostvars.${riak_primary_node}.ansible_eth0.ipv4.address} to return a proper value, but it never does.

playbook, options, and output available here:

https://gist.github.com/7b76b2cfc5704edd3738

(don’t worry, those hosts have been terminated to protected the innocent).

Thanks,

James

Possibly a string vs integer issue?

(ex: "0" vs 0, etc)

Possibly a string vs integer issue?

(ex: "0" vs 0, etc)

I'm fairly certain that's not the case if you look at line 45 on the gist,

you can see

$riak_primary_node ${groups.tag_stackName_source_primary}

being debugged and each have a value of
ec2-184-72-193-106.compute-1.amazonaws.com
ec2-184-72-193-106.compute-1.amazonaws.com

What I'm thinking is happing is that they are two different data types, one
is a dictionary ($riak_primary_node) and is getting evaluated properly,
and one is a string. So I guess then the question is, why can't I access
the hostvars of the previous play by simply specify the target of the
previous play by a string?

I've even tried

${hostvars.ec2-184-72-193-106.compute-1.amazonaws.com.ansible_eth0.ipv4.address}

to no avail, and you clearly can see it was the target of the previous play.

Thanks,

James

Apologies for the formatted text on the previous reply. Had to find
the magic triangle in GG to disable it.

James Martin wrote:

This is a head scratcher, well for me anyways.

I have two values that are being treated as if they weren't equal, yet
everything on the debug is showing me they have the same value.

In the playbook, the debug msg shows that $riak_primary_node $primary_node
have the same value, but when tested with when_string:
$riak_primary_node == $primary_node they are shown not to be equal.

$riak_primary_node is derivced from a fact and $primary_node is derived
from : primary_node: ${groups.tag_stackName_source_primary}.

groups is a list. If you know it is only going to contain one node, you
could use ${groups.tag_stackName_source_primary[0]}, or change your test to
be
  only_if: "'$riak_primary_node' in $primary_node"

Daniel

James Martin wrote:

Possibly a string vs integer issue?

(ex: "0" vs 0, etc)

I'm fairly certain that's not the case if you look at line 45 on the
gist,

you can see

$riak_primary_node ${groups.tag_stackName_source_primary}

being debugged and each have a value of
ec2-184-72-193-106.compute-1.amazonaws.com
ec2-184-72-193-106.compute-1.amazonaws.com

What I'm thinking is happing is that they are two different data types,
one
is a dictionary ($riak_primary_node) and is getting evaluated properly,
and one is a string. So I guess then the question is, why can't I access
the hostvars of the previous play by simply specify the target of the
previous play by a string?

I've even tried

${hostvars.ec2-184-72-193-106.compute-1.amazonaws.com.ansible_eth0.ipv4.address}

You have to escape the dots in the hostname, so make that
${hostvars.{ec2-184-72-193-106.compute-1.amazonaws.com}.ansible_eth0.ipv4.address}
and it should do what you want.

Daniel