mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
f9079274e7
commit
6d604f9b01
6 changed files with 55 additions and 31 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- Allow for vaulted templates in template lookup (https://github.com/ansible/ansible/issues/34209)
|
|
@ -73,8 +73,8 @@ class LookupModule(LookupBase):
|
|||
lookupfile = self.find_file_in_search_path(variables, 'templates', term)
|
||||
display.vvvv("File lookup using %s as file" % lookupfile)
|
||||
if lookupfile:
|
||||
with open(to_bytes(lookupfile, errors='surrogate_or_strict'), 'rb') as f:
|
||||
template_data = to_text(f.read(), errors='surrogate_or_strict')
|
||||
b_template_data, show_data = self._loader._get_file_contents(lookupfile)
|
||||
template_data = to_text(b_template_data, errors='surrogate_or_strict')
|
||||
|
||||
# set jinja2 internal search path for includes
|
||||
searchpath = variables.get('ansible_search_path', [])
|
||||
|
|
|
@ -7,3 +7,5 @@ set -eux
|
|||
pip install passlib
|
||||
|
||||
ANSIBLE_ROLES_PATH=../ ansible-playbook lookups.yml -i ../../inventory -e @../../integration_config.yml "$@"
|
||||
|
||||
ansible-playbook template_lookup_vaulted.yml -i ../../inventory -e @../../integration_config.yml --vault-password-file test_vault_pass "$@"
|
||||
|
|
13
test/integration/targets/lookups/template_lookup_vaulted.yml
Normal file
13
test/integration/targets/lookups/template_lookup_vaulted.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
# https://github.com/ansible/ansible/issues/34209
|
||||
- hosts: localhost
|
||||
gather_facts: no
|
||||
vars:
|
||||
hello_world: Hello World
|
||||
tasks:
|
||||
- name: Test that template lookup can handle vaulted templates
|
||||
set_fact:
|
||||
vaulted_hello_world: "{{ lookup('template', 'vaulted_hello.j2') }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "vaulted_hello_world|trim == 'Unvaulted Hello World!'"
|
|
@ -0,0 +1,6 @@
|
|||
$ANSIBLE_VAULT;1.1;AES256
|
||||
33623433323331343363343830343365376233386637366264646634663632343963396664393463
|
||||
3734626234626639323061643863613164643365363063310a663336663762356135396430353435
|
||||
39303930613231336135623761363130653235666433383965306235653963343166633233323638
|
||||
6635303662333734300a623063393761376531636535383164333632613839663237336463616436
|
||||
62643437623538633335366435346532636666616139386332323034336530356131
|
1
test/integration/targets/lookups/test_vault_pass
Normal file
1
test/integration/targets/lookups/test_vault_pass
Normal file
|
@ -0,0 +1 @@
|
|||
test
|
Loading…
Reference in a new issue