golden hour
/usr/lib/python3.9/site-packages/ansible/plugins/filter
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.py
510 B
Del
OK
__pycache__
-
Del
OK
b64decode.yml
927 B
Del
OK
b64encode.yml
543 B
Del
OK
basename.yml
809 B
Del
OK
bool.yml
631 B
Del
OK
checksum.yml
524 B
Del
OK
combinations.yml
780 B
Del
OK
combine.yml
1.63 KB
Del
OK
comment.yml
2.09 KB
Del
OK
core.py
21.05 KB
Del
OK
dict2items.yml
1.28 KB
Del
OK
difference.yml
1024 B
Del
OK
dirname.yml
820 B
Del
OK
encryption.py
2.63 KB
Del
OK
expanduser.yml
506 B
Del
OK
expandvars.yml
569 B
Del
OK
extract.yml
1.34 KB
Del
OK
fileglob.yml
589 B
Del
OK
flatten.yml
846 B
Del
OK
from_json.yml
905 B
Del
OK
from_yaml.yml
959 B
Del
OK
from_yaml_all.yml
1.25 KB
Del
OK
hash.yml
861 B
Del
OK
human_readable.yml
993 B
Del
OK
human_to_bytes.yml
1.02 KB
Del
OK
intersect.yml
969 B
Del
OK
items2dict.yml
1.52 KB
Del
OK
log.yml
904 B
Del
OK
mandatory.yml
537 B
Del
OK
mathstuff.py
8.12 KB
Del
OK
md5.yml
709 B
Del
OK
password_hash.yml
1.09 KB
Del
OK
path_join.yml
846 B
Del
OK
permutations.yml
969 B
Del
OK
pow.yml
692 B
Del
OK
product.yml
1.87 KB
Del
OK
quote.yml
492 B
Del
OK
random.yml
1.16 KB
Del
OK
realpath.yml
546 B
Del
OK
regex_escape.yml
688 B
Del
OK
regex_findall.yml
1.12 KB
Del
OK
regex_replace.yml
1.47 KB
Del
OK
regex_search.yml
1.04 KB
Del
OK
rekey_on_member.yml
921 B
Del
OK
relpath.yml
758 B
Del
OK
root.yml
618 B
Del
OK
sha1.yml
729 B
Del
OK
shuffle.yml
685 B
Del
OK
split.yml
833 B
Del
OK
splitext.yml
746 B
Del
OK
strftime.yml
1.33 KB
Del
OK
subelements.yml
1.4 KB
Del
OK
symmetric_difference.yml
1 KB
Del
OK
ternary.yml
1.52 KB
Del
OK
to_datetime.yml
1.58 KB
Del
OK
to_json.yml
2.69 KB
Del
OK
to_nice_json.yml
2.21 KB
Del
OK
to_nice_yaml.yml
1.55 KB
Del
OK
to_uuid.yml
785 B
Del
OK
to_yaml.yml
1.64 KB
Del
OK
type_debug.yml
508 B
Del
OK
union.yml
954 B
Del
OK
unique.yml
839 B
Del
OK
unvault.yml
1.04 KB
Del
OK
urldecode.yml
1.53 KB
Del
OK
urls.py
508 B
Del
OK
urlsplit.py
2.56 KB
Del
OK
vault.yml
1.63 KB
Del
OK
win_basename.yml
673 B
Del
OK
win_dirname.yml
679 B
Del
OK
win_splitdrive.yml
819 B
Del
OK
zip.yml
1.32 KB
Del
OK
zip_longest.yml
1.23 KB
Del
OK
Edit: encryption.py
# Copyright: (c) 2021, Ansible Project # Make coding more python3-ish from __future__ import (absolute_import, division, print_function) __metaclass__ = type from jinja2.runtime import Undefined from jinja2.exceptions import UndefinedError from ansible.errors import AnsibleFilterError, AnsibleFilterTypeError from ansible.module_utils._text import to_native, to_bytes from ansible.module_utils.six import string_types, binary_type from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode from ansible.parsing.vault import is_encrypted, VaultSecret, VaultLib from ansible.utils.display import Display display = Display() def do_vault(data, secret, salt=None, vaultid='filter_default', wrap_object=False): if not isinstance(secret, (string_types, binary_type, Undefined)): raise AnsibleFilterTypeError("Secret passed is required to be a string, instead we got: %s" % type(secret)) if not isinstance(data, (string_types, binary_type, Undefined)): raise AnsibleFilterTypeError("Can only vault strings, instead we got: %s" % type(data)) vault = '' vs = VaultSecret(to_bytes(secret)) vl = VaultLib() try: vault = vl.encrypt(to_bytes(data), vs, vaultid, salt) except UndefinedError: raise except Exception as e: raise AnsibleFilterError("Unable to encrypt: %s" % to_native(e), orig_exc=e) if wrap_object: vault = AnsibleVaultEncryptedUnicode(vault) else: vault = to_native(vault) return vault def do_unvault(vault, secret, vaultid='filter_default'): if not isinstance(secret, (string_types, binary_type, Undefined)): raise AnsibleFilterTypeError("Secret passed is required to be as string, instead we got: %s" % type(secret)) if not isinstance(vault, (string_types, binary_type, AnsibleVaultEncryptedUnicode, Undefined)): raise AnsibleFilterTypeError("Vault should be in the form of a string, instead we got: %s" % type(vault)) data = '' vs = VaultSecret(to_bytes(secret)) vl = VaultLib([(vaultid, vs)]) if isinstance(vault, AnsibleVaultEncryptedUnicode): vault.vault = vl data = vault.data elif is_encrypted(vault): try: data = vl.decrypt(vault) except UndefinedError: raise except Exception as e: raise AnsibleFilterError("Unable to decrypt: %s" % to_native(e), orig_exc=e) else: data = vault return to_native(data) class FilterModule(object): ''' Ansible vault jinja2 filters ''' def filters(self): filters = { 'vault': do_vault, 'unvault': do_unvault, } return filters
Save