community.general.redis (8.5.0) — lookup

fetch data from Redis

Authors: Jan-Piet Mens (@jpmens) <jpmens(at)gmail.com>, Ansible Core Team

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

This lookup returns a list of results from a Redis DB corresponding to a list of items given to it


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: query redis for somekey (default or configured settings used)
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', 'somekey') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: query redis for list of keys and non-default host and port
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', item, host='myredis.internal.com', port=2121) }}"
  loop: '{{list_of_redis_keys}}'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: use list directly
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', 'key1', 'key2', 'key3') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: use list directly with a socket
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', 'key1', 'key2', socket='/var/tmp/redis.sock') }}"

Inputs

    
host:
    default: 127.0.0.1
    description: location of Redis host
    env:
    - name: ANSIBLE_REDIS_HOST
    ini:
    - key: host
      section: lookup_redis

port:
    default: 6379
    description: port on which Redis is listening on
    env:
    - name: ANSIBLE_REDIS_PORT
    ini:
    - key: port
      section: lookup_redis
    type: int

_terms:
    description: list of keys to query

socket:
    description: path to socket on which to query Redis, this option overrides host and
      port options when set.
    env:
    - name: ANSIBLE_REDIS_SOCKET
    ini:
    - key: socket
      section: lookup_redis
    type: path

Outputs

_raw:
  description: value(s) stored in Redis
  elements: str
  type: list