retrieving endpoint from data in the elasticache module

148 views
Skip to first unread message

DenMat Gone

unread,
May 4, 2015, 9:13:09 AM5/4/15
to ansible...@googlegroups.com
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

Matt Martz

unread,
May 4, 2015, 10:19:16 AM5/4/15
to ansible...@googlegroups.com
Case matters when accessing keys.

Instead of cachenodes it should likely be CacheNodes.
--
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-proje...@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
@sivel
sivel.net

DenMat Gone

unread,
May 4, 2015, 8:12:31 PM5/4/15
to ansible...@googlegroups.com
Thanks Matt,

You're correct.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.

Dan Vaida

unread,
Jul 20, 2015, 9:59:19 AM7/20/15
to ansible...@googlegroups.com
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages