Discussion:
[ansible-project] retrieving endpoint from data in the elasticache module
DenMat Gone
2015-05-03 01:37:52 UTC
Permalink
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
--
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/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matt Martz
2015-05-04 14:19:12 UTC
Permalink
Case matters when accessing keys.

Instead of cachenodes it should likely be CacheNodes.
Post by DenMat Gone
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.
- name: create utilities elasticcache
name: "utilities-elc"
...
< snip >
...
register: utilities_elc
- debug: var=utilities_elc.elasticache.data
register: utilities_elc_data
- debug: var=utilities_elc_data
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
}
],
.....
}
utilities_elc.elasticache.data.cachenodes[0].endpoint.address
"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
--
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
.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Matt Martz
@sivel
sivel.net
--
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/CAD8N0v8VdkKPnNjV%3DS5BYrjidY18HjsAkT3s%2BCo9Y6AuCA-Kmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
DenMat Gone
2015-05-05 00:12:31 UTC
Permalink
Thanks Matt,

You're correct.
Post by Matt Martz
Case matters when accessing keys.
Instead of cachenodes it should likely be CacheNodes.
Post by DenMat Gone
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.
- name: create utilities elasticcache
name: "utilities-elc"
...
< snip >
...
register: utilities_elc
- debug: var=utilities_elc.elasticache.data
register: utilities_elc_data
- debug: var=utilities_elc_data
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
}
],
.....
}
utilities_elc.elasticache.data.cachenodes[0].endpoint.address
"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
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Matt Martz
@sivel
sivel.net
--
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/89dde12d-5fe2-4b1c-8486-c9d1505aef6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dan Vaida
2015-07-20 13:59:19 UTC
Permalink
see
here: https://groups.google.com/d/msg/ansible-project/qJ2UNWuaIJk/-S0GyDfTbPoJ
Post by DenMat Gone
Thanks Matt,
You're correct.
Post by Matt Martz
Case matters when accessing keys.
Instead of cachenodes it should likely be CacheNodes.
Post by DenMat Gone
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.
- name: create utilities elasticcache
name: "utilities-elc"
...
< snip >
...
register: utilities_elc
- debug: var=utilities_elc.elasticache.data
register: utilities_elc_data
- debug: var=utilities_elc_data
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
}
],
.....
}
utilities_elc.elasticache.data.cachenodes[0].endpoint.address
"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
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com
<https://groups.google.com/d/msgid/ansible-project/aa9d749f-e42d-4940-a443-44586afd1cbb%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Matt Martz
@sivel
sivel.net
--
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/8bfe4f65-65cd-4816-b5ed-62a340c6b2e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...