
    Vhc                         d dl mZmZmZ eZdZdZdZdZ		 d dl
Z
dZ	d dlmZ d d	lmZ d d
lmZ  G d de      Zy# e$ r Y %w xY w)    )absolute_importdivisionprint_functiona  
name: redis
author:
  - Jan-Piet Mens (@jpmens) <jpmens(at)gmail.com>
  - Ansible Core Team
short_description: fetch data from Redis
description:
  - This lookup returns a list of results from a Redis DB corresponding to a list of items given to it.
requirements:
  - redis (python library https://github.com/andymccurdy/redis-py/)
options:
  _terms:
    description: List of keys to query.
    type: list
    elements: string
  host:
    description: Location of Redis host.
    type: string
    default: '127.0.0.1'
    env:
      - name: ANSIBLE_REDIS_HOST
    ini:
      - section: lookup_redis
        key: host
  port:
    description: Port on which Redis is listening on.
    default: 6379
    type: int
    env:
      - name: ANSIBLE_REDIS_PORT
    ini:
      - section: lookup_redis
        key: port
  socket:
    description: Path to socket on which to query Redis, this option overrides host and port options when set.
    type: path
    env:
      - name: ANSIBLE_REDIS_SOCKET
    ini:
      - section: lookup_redis
        key: socket
a  
- name: query redis for somekey (default or configured settings used)
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', 'somekey') }}"

- 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}}'

- name: use list directly
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', 'key1', 'key2', 'key3') }}"

- name: use list directly with a socket
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.redis', 'key1', 'key2', socket='/var/tmp/redis.sock') }}"
zM
_raw:
  description: Value(s) stored in Redis.
  type: list
  elements: str
FNT)to_text)AnsibleError)
LookupBasec                       e Zd Zd Zy)LookupModulec                    t         st        d      | j                  |       | j                  d      }| j                  d      }| j                  d      }|t	        j
                  ||      }nt	        j
                  |      }g }|D ]2  }		 |j                  |	      }
|
d}
|j                  t        |
             4 |S # t        $ r}t        d	|	 d
|       d }~ww xY w)Nz5Can't LOOKUP(redis_kv): module redis is not installed)directhostportsocket)r   r   )unix_socket_path z%Encountered exception while fetching z: )

HAVE_REDISr   set_options
get_optionredisRedisgetappendr   	Exception)selfterms	variableskwargsr   r   r   connrettermreses               j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/lookup/redis.pyrunzLookupModule.run\   s    VWW 	' v&v&*>;;Dt4D;;7D 	XDXhhtn;C

73<(	X 
  X"%J4&PRSTRU#VWWXs   /C	C!CC!N)__name__
__module____qualname__r$        r#   r
   r
   Z   s    r)   r
   )
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNr   r   ImportError+ansible.module_utils.common.text.convertersr   ansible.errorsr   ansible.plugins.lookupr   r
   r(   r)   r#   <module>r4      si    C B)V&
 
	J @ ' -:   		s   : AA