mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
5babe2daea
commit
6f6bdf7914
12 changed files with 58 additions and 71 deletions
|
@ -237,15 +237,17 @@ class DataLoader:
|
||||||
b_main = b'main%s' % (suffix)
|
b_main = b'main%s' % (suffix)
|
||||||
b_tasked = b'tasks/%s' % (b_main)
|
b_tasked = b'tasks/%s' % (b_main)
|
||||||
|
|
||||||
if b_path.endswith(b'tasks') and os.path.exists(os.path.join(b_path, b_main)) \
|
if (
|
||||||
or os.path.exists(os.path.join(b_upath, b_tasked)) \
|
b_path.endswith(b'tasks') and
|
||||||
or os.path.exists(os.path.join(os.path.dirname(b_path), b_tasked)):
|
os.path.exists(os.path.join(b_path, b_main)) or
|
||||||
|
os.path.exists(os.path.join(b_upath, b_tasked)) or
|
||||||
|
os.path.exists(os.path.join(os.path.dirname(b_path), b_tasked))
|
||||||
|
):
|
||||||
isit = True
|
isit = True
|
||||||
break
|
break
|
||||||
|
|
||||||
return isit
|
return isit
|
||||||
|
|
||||||
|
|
||||||
def path_dwim_relative(self, path, dirname, source, is_role=False):
|
def path_dwim_relative(self, path, dirname, source, is_role=False):
|
||||||
'''
|
'''
|
||||||
find one file in either a role or playbook dir with or without
|
find one file in either a role or playbook dir with or without
|
||||||
|
|
|
@ -19,12 +19,11 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
||||||
from ansible.errors import AnsibleParserError, AnsibleError
|
from ansible.errors import AnsibleParserError, AnsibleError
|
||||||
from ansible.module_utils.six import iteritems, string_types
|
from ansible.module_utils.six import iteritems, string_types
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
from ansible.plugins import module_loader
|
|
||||||
from ansible.parsing.splitter import parse_kv, split_args
|
from ansible.parsing.splitter import parse_kv, split_args
|
||||||
|
from ansible.plugins import module_loader
|
||||||
from ansible.template import Templar
|
from ansible.template import Templar
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +95,6 @@ class ModuleArgsParser:
|
||||||
assert isinstance(task_ds, dict)
|
assert isinstance(task_ds, dict)
|
||||||
self._task_ds = task_ds
|
self._task_ds = task_ds
|
||||||
|
|
||||||
|
|
||||||
def _split_module_string(self, module_string):
|
def _split_module_string(self, module_string):
|
||||||
'''
|
'''
|
||||||
when module names are expressed like:
|
when module names are expressed like:
|
||||||
|
@ -111,7 +109,6 @@ class ModuleArgsParser:
|
||||||
else:
|
else:
|
||||||
return (tokens[0], "")
|
return (tokens[0], "")
|
||||||
|
|
||||||
|
|
||||||
def _handle_shell_weirdness(self, action, args):
|
def _handle_shell_weirdness(self, action, args):
|
||||||
'''
|
'''
|
||||||
given an action name and an args dictionary, return the
|
given an action name and an args dictionary, return the
|
||||||
|
@ -259,7 +256,6 @@ class ModuleArgsParser:
|
||||||
delegate_to = self._task_ds.get('delegate_to', None)
|
delegate_to = self._task_ds.get('delegate_to', None)
|
||||||
args = dict()
|
args = dict()
|
||||||
|
|
||||||
|
|
||||||
# This is the standard YAML form for command-type modules. We grab
|
# This is the standard YAML form for command-type modules. We grab
|
||||||
# the args and pass them in as additional arguments, which can/will
|
# the args and pass them in as additional arguments, which can/will
|
||||||
# be overwritten via dict updates from the other arg sources below
|
# be overwritten via dict updates from the other arg sources below
|
||||||
|
@ -272,7 +268,6 @@ class ModuleArgsParser:
|
||||||
thing = self._task_ds['action']
|
thing = self._task_ds['action']
|
||||||
action, args = self._normalize_parameters(thing, action=action, additional_args=additional_args)
|
action, args = self._normalize_parameters(thing, action=action, additional_args=additional_args)
|
||||||
|
|
||||||
|
|
||||||
# local_action
|
# local_action
|
||||||
if 'local_action' in self._task_ds:
|
if 'local_action' in self._task_ds:
|
||||||
# local_action is similar but also implies a delegate_to
|
# local_action is similar but also implies a delegate_to
|
||||||
|
@ -294,7 +289,6 @@ class ModuleArgsParser:
|
||||||
thing = value
|
thing = value
|
||||||
action, args = self._normalize_parameters(thing, action=action, additional_args=additional_args)
|
action, args = self._normalize_parameters(thing, action=action, additional_args=additional_args)
|
||||||
|
|
||||||
|
|
||||||
# if we didn't see any module in the task at all, it's not a task really
|
# if we didn't see any module in the task at all, it's not a task really
|
||||||
if action is None:
|
if action is None:
|
||||||
if 'ping' not in module_loader:
|
if 'ping' not in module_loader:
|
||||||
|
|
|
@ -23,6 +23,7 @@ __metaclass__ = type
|
||||||
def is_quoted(data):
|
def is_quoted(data):
|
||||||
return len(data) > 1 and data[0] == data[-1] and data[0] in ('"', "'") and data[-2] != '\\'
|
return len(data) > 1 and data[0] == data[-1] and data[0] in ('"', "'") and data[-2] != '\\'
|
||||||
|
|
||||||
|
|
||||||
def unquote(data):
|
def unquote(data):
|
||||||
''' removes first and last quotes from a string, if the string starts and ends with the same quotes '''
|
''' removes first and last quotes from a string, if the string starts and ends with the same quotes '''
|
||||||
if is_quoted(data):
|
if is_quoted(data):
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import re
|
|
||||||
import codecs
|
import codecs
|
||||||
|
import re
|
||||||
|
|
||||||
from ansible.errors import AnsibleParserError
|
from ansible.errors import AnsibleParserError
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
|
@ -177,7 +177,7 @@ def split_args(args):
|
||||||
|
|
||||||
# now we loop over each split chunk, coalescing tokens if the white space
|
# now we loop over each split chunk, coalescing tokens if the white space
|
||||||
# split occurred within quotes or a jinja2 block of some kind
|
# split occurred within quotes or a jinja2 block of some kind
|
||||||
for itemidx,item in enumerate(items):
|
for (itemidx, item) in enumerate(items):
|
||||||
|
|
||||||
# we split on spaces and newlines separately, so that we
|
# we split on spaces and newlines separately, so that we
|
||||||
# can tell which character we split on for reassembly
|
# can tell which character we split on for reassembly
|
||||||
|
@ -185,7 +185,7 @@ def split_args(args):
|
||||||
tokens = item.strip().split(' ')
|
tokens = item.strip().split(' ')
|
||||||
|
|
||||||
line_continuation = False
|
line_continuation = False
|
||||||
for idx,token in enumerate(tokens):
|
for (idx, token) in enumerate(tokens):
|
||||||
|
|
||||||
# if we hit a line continuation character, but
|
# if we hit a line continuation character, but
|
||||||
# we're not inside quotes, ignore it and continue
|
# we're not inside quotes, ignore it and continue
|
||||||
|
|
|
@ -18,4 +18,3 @@
|
||||||
# Make coding more python3-ish
|
# Make coding more python3-ish
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ patterns = {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def parse_address(address, allow_ranges=False):
|
def parse_address(address, allow_ranges=False):
|
||||||
"""
|
"""
|
||||||
Takes a string and returns a (host, port) tuple. If the host is None, then
|
Takes a string and returns a (host, port) tuple. If the host is None, then
|
||||||
|
|
|
@ -24,6 +24,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import simplejson as json
|
import simplejson as json
|
||||||
|
|
||||||
|
|
||||||
def jsonify(result, format=False):
|
def jsonify(result, format=False):
|
||||||
''' format JSON output (uncompressed or uncompressed) '''
|
''' format JSON output (uncompressed or uncompressed) '''
|
||||||
|
|
||||||
|
@ -38,4 +39,3 @@ def jsonify(result, format=False):
|
||||||
return json.dumps(result, sort_keys=True, indent=indent, ensure_ascii=False)
|
return json.dumps(result, sort_keys=True, indent=indent, ensure_ascii=False)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return json.dumps(result, sort_keys=True, indent=indent)
|
return json.dumps(result, sort_keys=True, indent=indent)
|
||||||
|
|
||||||
|
|
|
@ -712,7 +712,8 @@ class VaultAES256:
|
||||||
hash_function = SHA256
|
hash_function = SHA256
|
||||||
|
|
||||||
# make two keys and one iv
|
# make two keys and one iv
|
||||||
pbkdf2_prf = lambda p, s: HMAC.new(p, s, hash_function).digest()
|
def pbkdf2_prf(p, s):
|
||||||
|
return HMAC.new(p, s, hash_function).digest()
|
||||||
|
|
||||||
b_derivedkey = PBKDF2(b_password, b_salt, dkLen=(2 * keylength) + ivlength,
|
b_derivedkey = PBKDF2(b_password, b_salt, dkLen=(2 * keylength) + ivlength,
|
||||||
count=10000, prf=pbkdf2_prf)
|
count=10000, prf=pbkdf2_prf)
|
||||||
|
|
|
@ -18,4 +18,3 @@
|
||||||
# Make coding more python3-ish
|
# Make coding more python3-ish
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,10 @@ from yaml.nodes import MappingNode
|
||||||
|
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
from ansible.parsing.vault import VaultLib
|
from ansible.parsing.vault import VaultLib
|
||||||
from ansible.parsing.yaml.objects import AnsibleMapping, AnsibleSequence, AnsibleUnicode
|
from ansible.parsing.yaml.objects import AnsibleMapping, AnsibleSequence, AnsibleUnicode, AnsibleVaultEncryptedUnicode
|
||||||
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
|
|
||||||
from ansible.utils.unsafe_proxy import wrap_var
|
from ansible.utils.unsafe_proxy import wrap_var
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from __main__ import display
|
from __main__ import display
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -99,8 +99,7 @@ class AnsibleConstructor(SafeConstructor):
|
||||||
ciphertext_data = to_bytes(value)
|
ciphertext_data = to_bytes(value)
|
||||||
|
|
||||||
if self._b_vault_password is None:
|
if self._b_vault_password is None:
|
||||||
raise ConstructorError(None, None,
|
raise ConstructorError(None, None, "found vault but no vault password provided", node.start_mark)
|
||||||
"found vault but no vault password provided", node.start_mark)
|
|
||||||
|
|
||||||
# could pass in a key id here to choose the vault to associate with
|
# could pass in a key id here to choose the vault to associate with
|
||||||
vault = self._vaults['default']
|
vault = self._vaults['default']
|
||||||
|
@ -159,4 +158,5 @@ AnsibleConstructor.add_constructor(
|
||||||
AnsibleConstructor.add_constructor(
|
AnsibleConstructor.add_constructor(
|
||||||
u'!vault',
|
u'!vault',
|
||||||
AnsibleConstructor.construct_vault_encrypted_unicode)
|
AnsibleConstructor.construct_vault_encrypted_unicode)
|
||||||
|
|
||||||
AnsibleConstructor.add_constructor(u'!vault-encrypted', AnsibleConstructor.construct_vault_encrypted_unicode)
|
AnsibleConstructor.add_constructor(u'!vault-encrypted', AnsibleConstructor.construct_vault_encrypted_unicode)
|
||||||
|
|
|
@ -22,8 +22,7 @@ __metaclass__ = type
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from ansible.module_utils.six import PY3
|
from ansible.module_utils.six import PY3
|
||||||
from ansible.parsing.yaml.objects import AnsibleUnicode, AnsibleSequence, AnsibleMapping
|
from ansible.parsing.yaml.objects import AnsibleUnicode, AnsibleSequence, AnsibleMapping, AnsibleVaultEncryptedUnicode
|
||||||
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
|
|
||||||
from ansible.utils.unsafe_proxy import AnsibleUnsafeText
|
from ansible.utils.unsafe_proxy import AnsibleUnsafeText
|
||||||
from ansible.vars.hostvars import HostVars
|
from ansible.vars.hostvars import HostVars
|
||||||
|
|
||||||
|
@ -35,9 +34,11 @@ class AnsibleDumper(yaml.SafeDumper):
|
||||||
'''
|
'''
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def represent_hostvars(self, data):
|
def represent_hostvars(self, data):
|
||||||
return self.represent_dict(dict(data))
|
return self.represent_dict(dict(data))
|
||||||
|
|
||||||
|
|
||||||
# Note: only want to represent the encrypted data
|
# Note: only want to represent the encrypted data
|
||||||
def represent_vault_encrypted_unicode(self, data):
|
def represent_vault_encrypted_unicode(self, data):
|
||||||
return self.represent_scalar(u'!vault', data._ciphertext.decode(), style='|')
|
return self.represent_scalar(u'!vault', data._ciphertext.decode(), style='|')
|
||||||
|
|
|
@ -682,17 +682,6 @@ lib/ansible/modules/utilities/logic/async_wrapper.py
|
||||||
lib/ansible/modules/utilities/logic/wait_for.py
|
lib/ansible/modules/utilities/logic/wait_for.py
|
||||||
lib/ansible/modules/web_infrastructure/ejabberd_user.py
|
lib/ansible/modules/web_infrastructure/ejabberd_user.py
|
||||||
lib/ansible/modules/web_infrastructure/jboss.py
|
lib/ansible/modules/web_infrastructure/jboss.py
|
||||||
lib/ansible/parsing/dataloader.py
|
|
||||||
lib/ansible/parsing/mod_args.py
|
|
||||||
lib/ansible/parsing/quoting.py
|
|
||||||
lib/ansible/parsing/splitter.py
|
|
||||||
lib/ansible/parsing/utils/__init__.py
|
|
||||||
lib/ansible/parsing/utils/addresses.py
|
|
||||||
lib/ansible/parsing/utils/jsonify.py
|
|
||||||
lib/ansible/parsing/vault/__init__.py
|
|
||||||
lib/ansible/parsing/yaml/__init__.py
|
|
||||||
lib/ansible/parsing/yaml/constructor.py
|
|
||||||
lib/ansible/parsing/yaml/dumper.py
|
|
||||||
lib/ansible/playbook/__init__.py
|
lib/ansible/playbook/__init__.py
|
||||||
lib/ansible/playbook/attribute.py
|
lib/ansible/playbook/attribute.py
|
||||||
lib/ansible/playbook/base.py
|
lib/ansible/playbook/base.py
|
||||||
|
|
Loading…
Add table
Reference in a new issue