Search code examples
ansibleetcd

Ansible etcd lookup plugin issue


I've etcd running on the Ansible control machine (local). I can get and put the values as shown below but Ansible wouldn't get values, any thoughts?

enter image description here

I can also get the value using curl

enter image description here

I got this simple playbook

#!/usr/bin/env ansible-playbook
---
- name: simple ansible playbook ping
  hosts: all
  gather_facts: false
  tasks:    
  - name: look up value in etcd
    debug: msg="{{ lookup('etcd', 'weather') }}"

And running this playbook wouldn't fetch values from etcd

TASK: [look up value in etcd]     *************************************************
ok: [app1.test.com] => {
    "msg": ""
}
ok: [app2.test.com] => {
    "msg": ""
}

Solution

  • Currently (31.05.2016) Ansible etcd lookup plugin support only calls to v1 API and not compatible with newer etcd instances that publish v2 API endpoint.
    Here is the issue.

    You can use my quickly patched etcd2.py lookup plugin.
    Place it into lookup_plugins subdirectory near you playbook (or into Ansible global lookup_plugins path).

    Use lookup('etcd2', 'weather') in your playbook.