Hi all,
I have a question regarding the data returned from the elasticache module.
I am able to create a memcached elasticache endpoint but I would like to retrieve that endpoint for use later in the playbook.
I register the result and can use debug to show that all the data I need is returned.
So something like the following:
- name: create utilities elasticcache
elasticache:
name: “utilities-elc”
…
< snip >
…
register: utilities_elc
-
debug: var=utilities_elc.elasticache.data
register: utilities_elc_data -
debug: var=utilities_elc_data
That returns what I expect:
TASK: [vpc | debug var=utilities_elc_data] ************************************
ok: [localhost] => {
“var”: {
“utilities_elc_data”: {
“invocation”: {
“module_args”: “var=utilities_elc.elasticache.data”,
“module_name”: “debug”
},
“var”: {
“utilities_elc.elasticache.data”: {
“AutoMinorVersionUpgrade”: true,
“CacheClusterCreateTime”: 1430609910.496,
“CacheClusterId”: “utilities-elc”,
“CacheClusterStatus”: “available”,
“CacheNodeType”: “cache.m3.medium”,
“CacheNodes”: [
{
“CacheNodeCreateTime”: 1430609910.496,
“CacheNodeId”: “0001”,
“CacheNodeStatus”: “available”,
“Endpoint”: {
“Address”: “utilities-elc.i4w6la.0001.apse2.cache.amazonaws.com”,
“Port”: 11211
},
“ParameterGroupStatus”: “in-sync”,
“SourceCacheNodeId”: null
}
],
…
}
So my solution I tried to get the endpoint is:
utilities_elc.elasticache.data.cachenodes[0].endpoint.address
But that returns:
“One or more undefined variables: ‘dict object’ has no attribute ‘cachenodes’”
I would have thought that worked? What aren’t I getting?
If I use a with_dict: on the variable I can list the cachenodes key so it is baffling me.
Regards,
Den