community.general.etcd3 (8.5.0) — lookup

Get key values from etcd3 server

| "added in version" 0.2.0 of community.general"

Authors: Eric Belhomme (@eric-belhomme) <ebelhomme@fr.scc.com>

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Retrieves key values and/or key prefixes from etcd3 server using its native gRPC API.

Try to reuse M(community.general.etcd3) options for connection parameters, but add support for some C(ETCDCTL_*) environment variables.

See U(https://github.com/etcd-io/etcd/tree/master/Documentation/op-guide) for etcd overview.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "a value from a locally running etcd"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd3', 'foo/bar') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "values from multiple folders on a locally running etcd"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd3', 'foo', 'bar', 'baz') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "look for a key prefix"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd3', '/foo/bar', prefix=True) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "connect to etcd3 with a client certificate"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.etcd3', 'foo/bar', cert_cert='/etc/ssl/etcd/client.pem', cert_key='/etc/ssl/etcd/client.key') }}"

Inputs

    
host:
    description:
    - etcd3 listening client host.
    - Takes precedence over O(endpoints).
    type: str

port:
    description:
    - etcd3 listening client port.
    - Takes precedence over O(endpoints).
    type: int

user:
    description:
    - Authenticated user name.
    env:
    - name: ETCDCTL_USER
    type: str

_terms:
    description:
    - The list of keys (or key prefixes) to look up on the etcd3 server.
    elements: str
    required: true
    type: list

prefix:
    default: false
    description:
    - Look for key or prefix key.
    type: bool

ca_cert:
    description:
    - etcd3 CA authority.
    env:
    - name: ETCDCTL_CACERT
    type: str

timeout:
    default: 60
    description:
    - Client timeout.
    env:
    - name: ETCDCTL_DIAL_TIMEOUT
    type: int

cert_key:
    description:
    - etcd3 client private key.
    env:
    - name: ETCDCTL_KEY
    type: str

password:
    description:
    - Authenticated user password.
    env:
    - name: ETCDCTL_PASSWORD
    type: str

cert_cert:
    description:
    - etcd3 client certificate.
    env:
    - name: ETCDCTL_CERT
    type: str

endpoints:
    default: 127.0.0.1:2379
    description:
    - Counterpart of E(ETCDCTL_ENDPOINTS) environment variable. Specify the etcd3 connection
      with and URL form, for example V(https://hostname:2379), or V(<host>:<port>) form.
    - The V(host) part is overwritten by O(host) option, if defined.
    - The V(port) part is overwritten by O(port) option, if defined.
    env:
    - name: ETCDCTL_ENDPOINTS
    type: str

Outputs

_raw:
  contains:
    key:
      description: The element's key.
      type: str
    value:
      description: The element's value.
      type: str
  description:
  - List of keys and associated values.
  elements: dict
  type: list

See also