Discussion:
[ansible-project] getting values from returned data (elasticache endpoint)
DenMat Gone
2015-05-03 23:19:44 UTC
Permalink
Hi all,

I'm using the elasticache module to create an elasticache instance. This
works fine. I'm trying to parse the data returned to get the endpoint but
I'm having trouble and was hoping for an answer.

The data I'm trying to parse is like this:

TASK: [vpc | debug var=utilities_elc.elasticache.data]
************************
ok: [localhost] => {
"var": {
"utilities_elc.elasticache.data": {
"AutoMinorVersionUpgrade": true,
"CacheClusterCreateTime": 1430637402.709,
"CacheClusterId": "utilities-elc",
"CacheClusterStatus": "available",
"CacheNodeType": "cache.m3.medium",
"CacheNodes": [
{
"CacheNodeCreateTime": 1430637402.709,
"CacheNodeId": "0001",
"CacheNodeStatus": "available",
"Endpoint": {
"Address":
"utilities-elc.i4w6la.0001.apse2.cache.amazonaws.com",
"Port": 11211
},
"ParameterGroupStatus": "in-sync",
"SourceCacheNodeId": null
}
],


I thought it would be as simple as doing the following:

TASK: [vpc | debug msg="Endpoint {{
utilities_elc_data.cachenodes[0].endpoint.address }}"] ***
fatal: [localhost] => One or more undefined variables: 'dict object' has no
attribute 'cachenodes'

Which I get from this:

- debug: var=utilities_elc.elasticache.data
register: utilities_elc_data

- debug: msg="Endpoint {{ utilities_elc_data.cachenodes[0].endpoint.address
}}"
with_dict: utilities_elc_data

I would have thought that this would work. What am I doing wrong?

Regards,
Den

p.s forgive me if this is double posting but this is the second time I
tried to post but couldn't find my original in the list.
--
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+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/dc8782b2-b1e8-4158-b4fc-436ee3f1ebe9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Brian Coca
2015-05-04 20:32:17 UTC
Permalink
This is all case sensitive, for example, the key is displayed as
'CacheNodes' not cachenodes, also you are not using the full variable,
use this:

- debug: msg="Endpoint {{
utilities_elc.elasticache.data.CacheNodes[0].Endpoint.Address }}"
--
Brian Coca
--
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+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8%3DqtCW%3D9k4a3rDEfohVzTte2ae7t1oYqacSf%3D0dVkEusg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
DenMat Gone
2015-05-04 23:34:38 UTC
Permalink
Post by Brian Coca
This is all case sensitive, for example, the key is displayed as
'CacheNodes' not cachenodes, also you are not using the full variable,
- debug: msg="Endpoint {{
utilities_elc.elasticache.data.CacheNodes[0].Endpoint.Address }}"
--
Brian Coca
Man! I really thought I tried that but must have got my casing wrong.
Thanks for taking the time Brian.
--
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+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5b680346-183f-4e16-977f-5556cf00259d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dan Vaida
2015-07-20 13:58:23 UTC
Permalink
FWIW, this might come in handy if you're using
ElastiCache: https://github.com/ansible/ansible/pull/11261
My pal decided that this might ease our work and boy he was right :)
Post by DenMat Gone
Post by Brian Coca
This is all case sensitive, for example, the key is displayed as
'CacheNodes' not cachenodes, also you are not using the full variable,
- debug: msg="Endpoint {{
utilities_elc.elasticache.data.CacheNodes[0].Endpoint.Address }}"
--
Brian Coca
Man! I really thought I tried that but must have got my casing wrong.
Thanks for taking the time Brian.
--
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+***@googlegroups.com.
To post to this group, send email to ansible-***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/3148a3f1-97c3-4e62-b2f8-1ce6f485825f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...