File: //usr/lib/python3.9/site-packages/ansible/plugins/lookup/__pycache__/config.cpython-39.pyc
a
�)g � @ s� d dl mZmZmZ eZdZdZdZd dl m
mZ d dl
mZ d dlmZmZmZ d dlmZ d d lmZ d d
lmZ d dlmZ G dd
� d
e�Zdd� Zdd� ZG dd� de�ZdS )� )�absolute_import�division�print_functiona�
name: config
author: Ansible Core Team
version_added: "2.5"
short_description: Lookup current Ansible configuration values
description:
- Retrieves the value of an Ansible configuration setting.
- You can use C(ansible-config list) to see all available settings.
options:
_terms:
description: The key(s) to look up
required: True
on_missing:
description:
- action to take if term is missing from config
- Error will raise a fatal error
- Skip will just ignore the term
- Warn will skip over it but issue a warning
default: error
type: string
choices: ['error', 'skip', 'warn']
plugin_type:
description: the type of the plugin referenced by 'plugin_name' option.
choices: ['become', 'cache', 'callback', 'cliconf', 'connection', 'httpapi', 'inventory', 'lookup', 'netconf', 'shell', 'vars']
type: string
version_added: '2.12'
plugin_name:
description: name of the plugin for which you want to retrieve configuration settings.
type: string
version_added: '2.12'
a
- name: Show configured default become user
ansible.builtin.debug: msg="{{ lookup('ansible.builtin.config', 'DEFAULT_BECOME_USER')}}"
- name: print out role paths
ansible.builtin.debug:
msg: "These are the configured role paths: {{lookup('ansible.builtin.config', 'DEFAULT_ROLES_PATH')}}"
- name: find retry files, skip if missing that key
ansible.builtin.find:
paths: "{{lookup('ansible.builtin.config', 'RETRY_FILES_SAVE_PATH')|default(playbook_dir, True)}}"
patterns: "*.retry"
- name: see the colors
ansible.builtin.debug: msg="{{item}}"
loop: "{{lookup('ansible.builtin.config', 'COLOR_OK', 'COLOR_CHANGED', 'COLOR_SKIP', wantlist=True)}}"
- name: skip if bad value in var
ansible.builtin.debug: msg="{{ lookup('ansible.builtin.config', config_in_var, on_missing='skip')}}"
var:
config_in_var: UNKNOWN
- name: show remote user and port for ssh connection
ansible.builtin.debug: msg={{q("ansible.builtin.config", "remote_user", "port", plugin_type="connection", plugin_name="ssh", on_missing='skip')}}
- name: show remote_tmp setting for shell (sh) plugin
ansible.builtin.debug: msg={{q("ansible.builtin.config", "remote_tmp", plugin_type="shell", plugin_name="sh")}}
zM
_raw:
description:
- value(s) of the key(s) in the config
type: raw
N)� constants)�AnsibleError�AnsibleLookupError�AnsibleOptionsError)� to_native)�string_types)�
LookupBase)�Sentinelc @ s e Zd ZdS )�MissingSettingN)�__name__�
__module__�__qualname__� r r �A/usr/lib/python3.9/site-packages/ansible/plugins/lookup/config.pyr
T s r
c
C s� zNt td| �}|j| dd�}|d u r6td|| f ��tjj|||j|d�}W nV tyb � Y nD ty� } z,t |�}d|v r�t
||d��|�W Y d }~n
d }~0 0 |S )Nz %s_loaderT)Z
class_onlyzUnable to load %s plugin "%s")�plugin_type�plugin_name� variableszwas not defined�Zorig_exc)�getattr�
plugin_loader�getr �C�configZget_config_valueZ
_load_namer r r
) �pname�ptyper r �loader�p�result�e�msgr r r �_get_plugin_configX s r# c
C s\ z"t t| �}t|�r td| ��W n4 tyV } ztt|�|d��W Y d }~n
d }~0 0 |S )NzInvalid setting "%s" attemptedr )r r �callabler �AttributeErrorr
r )r r r! r r r �_get_global_configk s
&r&