summaryrefslogtreecommitdiff
path: root/lib/ansible/constants.py
diff options
context:
space:
mode:
authorLee Garrett <lgarrett@rocketjump.eu>2022-11-28 08:44:02 +0100
committerLee Garrett <lgarrett@rocketjump.eu>2022-11-28 08:44:02 +0100
commita6f601d820bf261c5f160bfcadb7ca6aa14d6ec2 (patch)
tree9ad0ffc7adc851191aa4787886c45d890d98a48b /lib/ansible/constants.py
parentdfc95dfc10415e8ba138e2c042c39632c9251abb (diff)
downloaddebian-ansible-core-a6f601d820bf261c5f160bfcadb7ca6aa14d6ec2.zip
New upstream version 2.14.0
Diffstat (limited to 'lib/ansible/constants.py')
-rw-r--r--lib/ansible/constants.py36
1 files changed, 11 insertions, 25 deletions
diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py
index afe3936b..23b1cf41 100644
--- a/lib/ansible/constants.py
+++ b/lib/ansible/constants.py
@@ -7,15 +7,12 @@ __metaclass__ = type
import re
-from ast import literal_eval
-from jinja2 import Template
from string import ascii_letters, digits
-from ansible.config.manager import ConfigManager, ensure_type
+from ansible.config.manager import ConfigManager
from ansible.module_utils._text import to_text
from ansible.module_utils.common.collections import Sequence
from ansible.module_utils.parsing.convert_bool import BOOLEANS_TRUE
-from ansible.module_utils.six import string_types
from ansible.release import __version__
from ansible.utils.fqcn import add_internal_fqcns
@@ -102,6 +99,11 @@ COLOR_CODES = {
REJECT_EXTS = ('.pyc', '.pyo', '.swp', '.bak', '~', '.rpm', '.md', '.txt', '.rst')
BOOL_TRUE = BOOLEANS_TRUE
COLLECTION_PTYPE_COMPAT = {'module': 'modules'}
+
+PYTHON_DOC_EXTENSIONS = ('.py',)
+YAML_DOC_EXTENSIONS = ('.yml', '.yaml')
+DOC_EXTENSIONS = PYTHON_DOC_EXTENSIONS + YAML_DOC_EXTENSIONS
+
DEFAULT_BECOME_PASS = None
DEFAULT_PASSWORD_CHARS = to_text(ascii_letters + digits + ".,:-_", errors='strict') # characters included in auto-generated passwords
DEFAULT_REMOTE_PASS = None
@@ -109,8 +111,8 @@ DEFAULT_SUBSET = None
# FIXME: expand to other plugins, but never doc fragments
CONFIGURABLE_PLUGINS = ('become', 'cache', 'callback', 'cliconf', 'connection', 'httpapi', 'inventory', 'lookup', 'netconf', 'shell', 'vars')
# NOTE: always update the docs/docsite/Makefile to match
-DOCUMENTABLE_PLUGINS = CONFIGURABLE_PLUGINS + ('module', 'strategy')
-IGNORE_FILES = ("COPYING", "CONTRIBUTING", "LICENSE", "README", "VERSION", "GUIDELINES") # ignore during module search
+DOCUMENTABLE_PLUGINS = CONFIGURABLE_PLUGINS + ('module', 'strategy', 'test', 'filter')
+IGNORE_FILES = ("COPYING", "CONTRIBUTING", "LICENSE", "README", "VERSION", "GUIDELINES", "MANIFEST", "Makefile") # ignore during module search
INTERNAL_RESULT_KEYS = ('add_host', 'add_group')
LOCALHOST = ('127.0.0.1', 'localhost', '::1')
MODULE_REQUIRE_ARGS = tuple(add_internal_fqcns(('command', 'win_command', 'ansible.windows.win_command', 'shell', 'win_shell',
@@ -118,6 +120,7 @@ MODULE_REQUIRE_ARGS = tuple(add_internal_fqcns(('command', 'win_command', 'ansib
MODULE_NO_JSON = tuple(add_internal_fqcns(('command', 'win_command', 'ansible.windows.win_command', 'shell', 'win_shell',
'ansible.windows.win_shell', 'raw')))
RESTRICTED_RESULT_KEYS = ('ansible_rsync_path', 'ansible_playbook_python', 'ansible_facts')
+SYNTHETIC_COLLECTIONS = ('ansible.builtin', 'ansible.legacy')
TREE_DIR = None
VAULT_VERSION_MIN = 1.0
VAULT_VERSION_MAX = 1.0
@@ -181,25 +184,8 @@ MAGIC_VARIABLE_MAPPING = dict(
config = ConfigManager()
# Generate constants from config
-for setting in config.data.get_settings():
-
- value = setting.value
- if setting.origin == 'default' and \
- isinstance(setting.value, string_types) and \
- (setting.value.startswith('{{') and setting.value.endswith('}}')):
- try:
- t = Template(setting.value)
- value = t.render(vars())
- try:
- value = literal_eval(value)
- except ValueError:
- pass # not a python data structure
- except Exception:
- pass # not templatable
-
- value = ensure_type(value, setting.type)
-
- set_constant(setting.name, value)
+for setting in config.get_configuration_definitions():
+ set_constant(setting, config.get_config_value(setting, variables=vars()))
for warn in config.WARNINGS:
_warning(warn)