ansible
2.9.27
About: Ansible is an IT Configuration Management, Deployment \ About: Ansible (2.x) is an IT Configuration Management, Deployment & Orchestration tool.
![]() ![]() |
Namespaces | |
namespace | native_helpers |
namespace | safe_eval |
namespace | template |
namespace | vars |
Classes | |
class | AnsibleContext |
class | AnsibleEnvironment |
class | AnsibleUndefined |
class | JinjaPluginIntercept |
class | Templar |
Functions | |
def | generate_ansible_template_vars (path, dest_path=None) |
def | _escape_backslashes (data, jinja_env) |
def | is_template (data, jinja_env) |
def | _count_newlines_from_end (in_str) |
def | recursive_check_defined (item) |
Variables | |
__metaclass__ = type | |
display = Display() | |
list | __all__ = ['Templar', 'generate_ansible_template_vars'] |
tuple | NON_TEMPLATED_TYPES = (bool, Number) |
string | JINJA2_OVERRIDE = '#jinja2:' |
bool | USE_JINJA2_NATIVE = False |
JINJA2_BEGIN_TOKENS = frozenset(('variable_begin', 'block_begin', 'comment_begin', 'raw_begin')) | |
JINJA2_END_TOKENS = frozenset(('variable_end', 'block_end', 'comment_end', 'raw_end')) | |
|
private |
Counts the number of newlines at the end of a string. This is used during the jinja2 templating to ensure the count matches the input, since some newlines may be thrown away during the templating.
Definition at line 198 of file __init__.py.
References ansible.template._count_newlines_from_end().
Referenced by ansible.template._count_newlines_from_end(), and ansible.template.Templar.do_template().
|
private |
Double backslashes within jinja2 expressions A user may enter something like this in a playbook:: debug: msg: "Test Case 1\\3; {{ test1_name | regex_replace('^(.*)_name$', '\\1')}}" The string inside of the {{ gets interpreted multiple times First by yaml. Then by python. And finally by jinja2 as part of it's variable. Because it is processed by both python and jinja2, the backslash escaped characters get unescaped twice. This means that we'd normally have to use four backslashes to escape that. This is painful for playbook authors as they have to remember different rules for inside vs outside of a jinja2 expression (The backslashes outside of the "{{ }}" only get processed by yaml and python. So they only need to be escaped once). The following code fixes this by automatically performing the extra quoting of backslashes inside of a jinja2 expression.
Definition at line 122 of file __init__.py.
References ansible.template._escape_backslashes(), and ansible.modules.cloud.amazon.ec2_asg.replace().
Referenced by ansible.template._escape_backslashes(), and ansible.template.Templar.do_template().
def ansible.template.generate_ansible_template_vars | ( | path, | |
dest_path = None |
|||
) |
Definition at line 94 of file __init__.py.
References ansible.template.generate_ansible_template_vars(), ansible.module_utils._text.to_bytes(), ansible.module_utils._text.to_native, and ansible.module_utils._text.to_text().
Referenced by ansible.template.generate_ansible_template_vars(), ansible.plugins.lookup.template.LookupModule.run(), and ansible.plugins.action.template.ActionModule.run().
def ansible.template.is_template | ( | data, | |
jinja_env | |||
) |
This function attempts to quickly detect whether a value is a jinja2 template. To do so, we look for the first 2 matching jinja2 tokens for start and end delimiters.
Definition at line 165 of file __init__.py.
References ansible.template.is_template(), and ansible.modules.network.junos.junos_command.split().
Referenced by ansible.plugins.strategy.StrategyBase._set_hosts_cache(), and ansible.template.is_template().
def ansible.template.recursive_check_defined | ( | item | ) |
Definition at line 216 of file __init__.py.
References ansible.utils.display.format, and ansible.template.recursive_check_defined().
Referenced by ansible.plugins.filter.core.combine(), and ansible.template.recursive_check_defined().
|
private |
Definition at line 60 of file __init__.py.
|
private |
Definition at line 20 of file __init__.py.
ansible.template.display = Display() |
Definition at line 57 of file __init__.py.
ansible.template.JINJA2_BEGIN_TOKENS = frozenset(('variable_begin', 'block_begin', 'comment_begin', 'raw_begin')) |
Definition at line 90 of file __init__.py.
ansible.template.JINJA2_END_TOKENS = frozenset(('variable_end', 'block_end', 'comment_end', 'raw_end')) |
Definition at line 91 of file __init__.py.
string ansible.template.JINJA2_OVERRIDE = '#jinja2:' |
Definition at line 68 of file __init__.py.
tuple ansible.template.NON_TEMPLATED_TYPES = (bool, Number) |
Definition at line 66 of file __init__.py.
bool ansible.template.USE_JINJA2_NATIVE = False |
Definition at line 72 of file __init__.py.