
    Vhm
                     x    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 dlmZ  G d d	e      Z G d
 de
      Zy)    )absolute_importdivisionprint_functiona  
author:
  - Juan Manuel Parrilla (@jparrill)
name: hiera
short_description: get info from hiera data
requirements:
  - hiera (command line utility)
description:
  - Retrieves data from an Puppetmaster node using Hiera as ENC.
options:
  _terms:
    description:
      - The list of keys to lookup on the Puppetmaster.
    type: list
    elements: string
    required: true
  executable:
    description:
      - Binary file to execute Hiera.
    type: string
    default: '/usr/bin/hiera'
    env:
      - name: ANSIBLE_HIERA_BIN
  config_file:
    description:
      - File that describes the hierarchy of Hiera.
    type: string
    default: '/etc/hiera.yaml'
    env:
      - name: ANSIBLE_HIERA_CFG
# FIXME: incomplete options .. _terms? environment/fqdn?
a  
# All this examples depends on hiera.yml that describes the hierarchy

- name: "a value from Hiera 'DB'"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.hiera', 'foo') }}"

- name: "a value from a Hiera 'DB' on other environment"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.hiera', 'foo environment=production') }}"

- name: "a value from a Hiera 'DB' for a concrete node"
  ansible.builtin.debug:
    msg: "{{ lookup('community.general.hiera', 'foo fqdn=puppet01.localdomain') }}"
z\
_raw:
  description:
    - A value associated with input key.
  type: list
  elements: str
)
LookupBase)run_cmd)to_textc                       e Zd Zd Zd Zy)Hierac                      || _         || _        y N)	hiera_cfg	hiera_bin)selfr   r   s      j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/lookup/hiera.py__init__zHiera.__init__H   s    ""    c                    | j                   g}|j                  d| j                  g       |j                  |       t        | j                    d| j                   d|d          \  }}}t	        |j                               S )Nz-cz -c  r   )r   extendr   r   r   strip)r   	hiera_keypargsrcoutputerrs         r   getz	Hiera.getL   sp     dDNN+,Y!T^^$4D8H)TU,"XYFCv||~&&r   N)__name__
__module____qualname__r   r    r   r   r
   r
   G   s    #'r   r
   c                       e Zd ZddZy)LookupModuleNc                     | j                  ||       t        | j                  d      | j                  d            }|j                  |      g}|S )N)var_optionsdirectconfig_file
executable)set_optionsr
   
get_optionr   )r   terms	variableskwargshierarets         r   runzLookupModule.runX   sI    Yv>doom4dool6STyy 
r   r   )r   r   r   r/   r    r   r   r"   r"   W   s    r   r"   N)
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLESRETURNansible.plugins.lookupr   ansible.utils.cmd_functionsr   +ansible.module_utils.common.text.convertersr   objectr
   r"   r    r   r   <module>r:      sL    C BB 
 . / ?'F ' : r   