
    Vh                         d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZ dZ	 d dlZd	Z G d
 de      Zy# e$ r dZY w xY w)    )absolute_importdivisionprint_functionah  
author: Unknown (!UNKNOWN)
name: credstash
short_description: retrieve secrets from Credstash on AWS
requirements:
  - credstash (python library)
description:
  - "Credstash is a small utility for managing secrets using AWS's KMS and DynamoDB: https://github.com/fugue/credstash."
options:
  _terms:
    description: Term or list of terms to lookup in the credit store.
    type: list
    elements: string
    required: true
  table:
    description: Name of the credstash table to query.
    type: str
    default: 'credential-store'
  version:
    description: Credstash version.
    type: str
    default: ''
  region:
    description: AWS region.
    type: str
  profile_name:
    description: AWS profile to use for authentication.
    type: str
    env:
      - name: AWS_PROFILE
  aws_access_key_id:
    description: AWS access key ID.
    type: str
    env:
      - name: AWS_ACCESS_KEY_ID
  aws_secret_access_key:
    description: AWS access key.
    type: str
    env:
      - name: AWS_SECRET_ACCESS_KEY
  aws_session_token:
    description: AWS session token.
    type: str
    env:
      - name: AWS_SESSION_TOKEN
a]  
- name: first use credstash to store your secrets
  ansible.builtin.shell: credstash put my-github-password secure123

- name: "Test credstash lookup plugin -- get my github password"
  ansible.builtin.debug:
    msg: "Credstash lookup! {{ lookup('community.general.credstash', 'my-github-password') }}"

- name: "Test credstash lookup plugin -- get my other password from us-west-1"
  ansible.builtin.debug:
    msg: "Credstash lookup! {{ lookup('community.general.credstash', 'my-other-password', region='us-west-1') }}"

- name: "Test credstash lookup plugin -- get the company's github password"
  ansible.builtin.debug:
    msg: "Credstash lookup! {{ lookup('community.general.credstash', 'company-github-password', table='company-passwords') }}"

- name: Example play using the 'context' feature
  hosts: localhost
  vars:
    context:
      app: my_app
      environment: production
  tasks:

    - name: "Test credstash lookup plugin -- get the password with a context passed as a variable"
      ansible.builtin.debug:
        msg: "{{ lookup('community.general.credstash', 'some-password', context=context) }}"

    - name: "Test credstash lookup plugin -- get the password with a context defined here"
      ansible.builtin.debug:
        msg: "{{ lookup('community.general.credstash', 'some-password', context=dict(app='my_app', environment='production')) }}"
zF
_raw:
  description:
    - Value(s) stored in Credstash.
  type: str
)AnsibleError)
LookupBaseFNTc                       e Zd ZddZy)LookupModuleNc           	         t         st        d      | j                  ||       | j                  d      }| j                  d      }| j                  d      }| j                  d      }| j                  d      }| j                  d      }	| j                  d	      }
|j	                         D ci c]  \  }}|d
vr|| }}}|||	|
d}g }|D ]-  }	 |j                  t        j                  ||||fd|i|       / |S c c}}w # t        j                  $ r t        d| d      t        $ r}t        d| d|       d }~ww xY w)Nz?The credstash lookup plugin requires credstash to be installed.)var_optionsdirectversionregiontableprofile_nameaws_access_key_idaws_secret_access_keyaws_session_token)r   r   r   r   r   r   r   )r   r   r   r   contextzKey z
 not foundz%Encountered exception while fetching z: )
CREDSTASH_INSTALLEDr   set_options
get_optionitemsappend	credstash	getSecretItemNotFound	Exception)selfterms	variableskwargsr   r   r   r   r   r   r   kvr   kwargs_passrettermes                     n/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/lookup/credstash.pyrunzLookupModule.runm   s   "`aaYv>//),*(~6 OO,?@ $0G H OO,?@ $\\^
Q  J  J qD
 
 )!2%:!2	
  	XDX

9..tWfelU\l`klm	X 
+
  )) <"T$z#:;; X"%J4&PRSTRU#VWWXs   /D *D*E0EE)N)__name__
__module____qualname__r)        r(   r	   r	   l   s    #r.   r	   )
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNansible.errorsr   ansible.plugins.lookupr   r   r   ImportErrorr	   r-   r.   r(   <module>r8      si    C B-^B
 ( -  
$: $	    s   4 >>