summaryrefslogtreecommitdiff
path: root/test/integration/targets
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2017-06-07 13:16:03 -0500
committerBrian Coca <bcoca@users.noreply.github.com>2017-06-07 14:16:03 -0400
commit004e99316c2646f7ec39042a834d3a11e75c8de4 (patch)
treec2274036e61a6ce1ea9a199c862205f0ab34d31c /test/integration/targets
parent24f2a616dd8894361eb66fa0f5c6e8ea3aa08cfd (diff)
downloadansible-004e99316c2646f7ec39042a834d3a11e75c8de4.tar.gz
Allow template files to be vaulted (#22951)
* Allow template files to be vaulted * Make sure to import exceptions we need * get_real_file can't take bytes, since it looks specifically for string_types * Now that we aren't using open() we don't need b_source * Expand playbooks_vault docs to include modules that support vaulted src files * Add vaulted template test
Diffstat (limited to 'test/integration/targets')
-rw-r--r--test/integration/targets/vault/roles/test_vaulted_template/tasks/main.yml19
-rw-r--r--test/integration/targets/vault/roles/test_vaulted_template/templates/vaulted_template.j26
-rwxr-xr-xtest/integration/targets/vault/runme.sh2
-rw-r--r--test/integration/targets/vault/test_vaulted_template.yml6
4 files changed, 32 insertions, 1 deletions
diff --git a/test/integration/targets/vault/roles/test_vaulted_template/tasks/main.yml b/test/integration/targets/vault/roles/test_vaulted_template/tasks/main.yml
new file mode 100644
index 0000000000..b6e6ce78f1
--- /dev/null
+++ b/test/integration/targets/vault/roles/test_vaulted_template/tasks/main.yml
@@ -0,0 +1,19 @@
+---
+- name: Template from a vaulted template file
+ template:
+ src: vaulted_template.j2
+ dest: "{{ output_dir }}/vaulted_template.out"
+ vars:
+ vaulted_template_var: "here_i_am"
+
+- name: Get output template contents
+ slurp:
+ path: "{{ output_dir }}/vaulted_template.out"
+ register: vaulted_tempalte_out
+
+- debug:
+ msg: "{{ vaulted_tempalte_out.content|b64decode }}"
+
+- assert:
+ that:
+ - vaulted_tempalte_out.content|b64decode == 'here_i_am\n'
diff --git a/test/integration/targets/vault/roles/test_vaulted_template/templates/vaulted_template.j2 b/test/integration/targets/vault/roles/test_vaulted_template/templates/vaulted_template.j2
new file mode 100644
index 0000000000..af9c3eb1eb
--- /dev/null
+++ b/test/integration/targets/vault/roles/test_vaulted_template/templates/vaulted_template.j2
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+65626437623461633630303033303939616334373263633438623938396564376435366534303865
+6363663439346464336437346263343235626463663130640a373233623733653830306262376430
+31666538323132343039613537323761343234613531353035373434666632333932623064316564
+3532363462643736380a303136353830636635313662663065343066323631633562356663633536
+31343265376433633234656432393066393865613235303165666338663930303035
diff --git a/test/integration/targets/vault/runme.sh b/test/integration/targets/vault/runme.sh
index 05603ee747..8b32720296 100755
--- a/test/integration/targets/vault/runme.sh
+++ b/test/integration/targets/vault/runme.sh
@@ -57,4 +57,4 @@ ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-pass
ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password --syntax-check
ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password
ansible-playbook test_vaulted_inventory.yml -i vaulted.inventory -v "$@" --vault-password-file vault-password
-
+ansible-playbook test_vaulted_template.yml -i ../../inventory -v "$@" --vault-password-file vault-password
diff --git a/test/integration/targets/vault/test_vaulted_template.yml b/test/integration/targets/vault/test_vaulted_template.yml
new file mode 100644
index 0000000000..b495211de8
--- /dev/null
+++ b/test/integration/targets/vault/test_vaulted_template.yml
@@ -0,0 +1,6 @@
+- hosts: testhost
+ gather_facts: False
+ vars:
+ - output_dir: .
+ roles:
+ - { role: test_vaulted_template, tags: test_vaulted_template}