community.general.etcd lookup – get info from an etcd server

Note

This lookup plugin is part of the community.general collection (version 6.6.2).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.etcd.

Synopsis

  • Retrieves data from an etcd server

Terms

Parameter

Comments

Terms

list / elements=string / required

the list of keys to lookup on the etcd server

Parameters

Parameter

Comments

url

string

Environment variable with the url for the etcd server

Default: "http://127.0.0.1:4001"

Configuration:

  • Environment variable: ANSIBLE_ETCD_URL

validate_certs

boolean

toggle checking that the ssl certificates are valid, you normally only want to turn this off with self-signed certs.

Choices:

  • false

  • true ← (default)

version

string

Environment variable with the etcd protocol version

Default: "v1"

Configuration:

  • Environment variable: ANSIBLE_ETCD_VERSION

Examples

- name: "a value from a locally running etcd"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd', 'foo/bar') }}"

- name: "values from multiple folders on a locally running etcd"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd', 'foo', 'bar', 'baz') }}"

- name: "since Ansible 2.5 you can set server options inline"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd', 'foo', version='v2', url='http://192.168.0.27:4001') }}"

Return Value

Key

Description

Return value

list / elements=string

list of values associated with input keys

Returned: success

Authors

  • Jan-Piet Mens (@jpmens)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.