
    Vh                        d dl mZ dZdZdZd dlmZ d dlZd dlm	Z
 d dlmZ d dlmZ d d	lmZ d d
lmZmZ d dlmZ d dlmZ  e       Z G d de      Zy)    )annotationsaF  
    name: template
    author: Michael DeHaan
    version_added: "0.9"
    short_description: retrieve contents of file after templating with Jinja2
    description:
      - Returns a list of strings; for each template in the list of templates you pass in, returns a string containing the results of processing that template.
    options:
      _terms:
        description: list of files to template
      convert_data:
        type: bool
        description:
            - Whether to convert YAML into data. If False, strings that are YAML will be left untouched.
            - Mutually exclusive with the jinja2_native option.
        default: true
      variable_start_string:
        description: The string marking the beginning of a print statement.
        default: '{{'
        version_added: '2.8'
        type: str
      variable_end_string:
        description: The string marking the end of a print statement.
        default: '}}'
        version_added: '2.8'
        type: str
      jinja2_native:
        description:
            - Controls whether to use Jinja2 native types.
            - It is off by default even if global jinja2_native is True.
            - Has no effect if global jinja2_native is False.
            - This offers more flexibility than the template module which does not use Jinja2 native types at all.
            - Mutually exclusive with the convert_data option.
        default: False
        version_added: '2.11'
        type: bool
      template_vars:
        description: A dictionary, the keys become additional variables available for templating.
        default: {}
        version_added: '2.3'
        type: dict
      comment_start_string:
        description: The string marking the beginning of a comment statement.
        version_added: '2.12'
        type: str
        default: '{#'
      comment_end_string:
        description: The string marking the end of a comment statement.
        version_added: '2.12'
        type: str
        default: '#}'
    seealso:
      - ref: playbook_task_paths
        description: Search paths used for relative templates.
aO  
- name: show templating results
  ansible.builtin.debug:
    msg: "{{ lookup('ansible.builtin.template', './some_template.j2') }}"

- name: show templating results with different variable start and end string
  ansible.builtin.debug:
    msg: "{{ lookup('ansible.builtin.template', './some_template.j2', variable_start_string='[%', variable_end_string='%]') }}"

- name: show templating results with different comment start and end string
  ansible.builtin.debug:
    msg: "{{ lookup('ansible.builtin.template', './some_template.j2', comment_start_string='[#', comment_end_string='#]') }}"
zW
_raw:
   description: file(s) content after templating
   type: list
   elements: raw
)deepcopyN)AnsibleError)
LookupBase)to_text)generate_ansible_template_varsAnsibleEnvironment)Display)NativeJinjaTextc                      e Zd Zd Zy)LookupModulec           	     4   g }| j                  ||       | j                  d      }| j                  d      }| j                  d      xr t        j                  }| j                  d      }| j                  d      }	| j                  d      }
| j                  d      }|r| j                  }n | j                  j                  t        	      }|D ]  }t        j                  d
|z         | j                  |d|      }t        j                  d|z         |rc| j                  j                  |      \  }}t        |d      }|j                  dg       }|rKg }|D ]B  }|j                  t         j"                  j%                  |d             |j                  |       D |}|j'                  dt         j"                  j)                  |             t+        |      }|j-                  t/        ||             |j-                  |       |j1                  ||      5  t3        ||	|
|      }|j5                  |d|d|      }d d d        t        j                  r|r|st7              }|j                         t9        d|z         |S # 1 sw Y   LxY w)N)var_optionsdirectconvert_datatemplate_varsjinja2_nativevariable_start_stringvariable_end_stringcomment_start_stringcomment_end_string)environment_classzFile lookup term: %s	templateszFile lookup using %s as filesurrogate_or_strict)errorsansible_search_pathr   )available_variables
searchpath)r   r   r   r   TF)preserve_trailing_newlinesr   escape_backslashes	overridesz6the template file %s could not be found for the lookup)set_options
get_optionCDEFAULT_JINJA2_NATIVE_templarcopy_with_new_envr	   displaydebugfind_file_in_search_pathvvvv_loader_get_file_contentsr   getappendospathjoininsertdirnamer   updater   set_temporary_contextdicttemplater   r   )selfterms	variableskwargsretconvert_data_plookup_template_varsr   r   r   r   r   templarterm
lookupfileb_template_data	show_datatemplate_datar   newsearchpathpvarsr!   ress                           O/home/dcms/DCMS/lib/python3.12/site-packages/ansible/plugins/lookup/template.pyrunzLookupModule.runf   sz   Yv> 8#?8TQ=T=T $0G H"oo.CD#/EF!__-ABmmGmm55HZ5[G 0	dDMM047866y+tTJLL7*DE-1\\-L-LZ-X* '@U V ']]+@"E
 %'M' 0%,,RWW\\![-IJ%,,Q/0 "/J!!!RWW__Z%@A  	*:4LM0122tXb2c 	@ $.C,?-A+=	!I "**=UY8F[`5> + @C	@ ++M. *#.C

3"#[^b#bcca0	dd 
)	@ 	@s   &JJ	N)__name__
__module____qualname__rK        rJ   r   r   d   s    FrP   r   )
__future__r   DOCUMENTATIONEXAMPLESRETURNcopyr   r0   ansible.constants	constantsr$   ansible.errorsr   ansible.plugins.lookupr   +ansible.module_utils.common.text.convertersr   ansible.templater   r	   ansible.utils.displayr
   ansible.utils.native_jinjar   r(   r   rO   rP   rJ   <module>r^      sT   
 #6p
  	  ' - ? O ) 6 )H: HrP   