summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-vault
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/ansible-vault')
-rw-r--r--test/integration/targets/ansible-vault/aliases2
-rw-r--r--test/integration/targets/ansible-vault/empty-password0
-rw-r--r--test/integration/targets/ansible-vault/encrypted-vault-password6
-rw-r--r--test/integration/targets/ansible-vault/encrypted_file_encrypted_var_password1
-rw-r--r--test/integration/targets/ansible-vault/example1_password1
-rw-r--r--test/integration/targets/ansible-vault/example2_password1
-rw-r--r--test/integration/targets/ansible-vault/example3_password1
-rwxr-xr-xtest/integration/targets/ansible-vault/faux-editor.py44
-rw-r--r--test/integration/targets/ansible-vault/files/test_assemble/nonsecret.txt1
-rw-r--r--test/integration/targets/ansible-vault/files/test_assemble/secret.vault7
-rw-r--r--test/integration/targets/ansible-vault/format_1_1_AES256.yml6
-rw-r--r--test/integration/targets/ansible-vault/format_1_2_AES256.yml6
-rw-r--r--test/integration/targets/ansible-vault/host_vars/myhost.yml7
-rw-r--r--test/integration/targets/ansible-vault/host_vars/testhost.yml7
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/README.md1
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/broken-group-vars-tasks.yml23
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/broken-host-vars-tasks.yml7
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/group_vars/broken-group-vars.yml8
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/host_vars/broken-host-vars.example.com/vars11
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/inventory5
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/original-broken-host-vars6
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/original-group-vars.yml2
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/some-vars6
-rw-r--r--test/integration/targets/ansible-vault/invalid_format/vault-secret1
-rw-r--r--test/integration/targets/ansible-vault/inventory.toml5
-rwxr-xr-xtest/integration/targets/ansible-vault/password-script.py33
-rw-r--r--test/integration/targets/ansible-vault/realpath.yml10
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault/tasks/main.yml9
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault/vars/main.yml9
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml13
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_embedded/vars/main.yml17
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/tasks/main.yml29
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/vars/main.yml194
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/README.md1
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml13
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/vars/main.yml76
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vaulted_template/tasks/main.yml19
-rw-r--r--test/integration/targets/ansible-vault/roles/test_vaulted_template/templates/vaulted_template.j26
-rwxr-xr-xtest/integration/targets/ansible-vault/runme.sh576
-rwxr-xr-xtest/integration/targets/ansible-vault/script/vault-secret.sh24
-rw-r--r--test/integration/targets/ansible-vault/single_vault_as_string.yml117
-rw-r--r--test/integration/targets/ansible-vault/symlink.yml10
-rwxr-xr-xtest/integration/targets/ansible-vault/symlink/get-password-symlink24
-rwxr-xr-xtest/integration/targets/ansible-vault/test-vault-client.py66
-rw-r--r--test/integration/targets/ansible-vault/test_dangling_temp.yml34
-rw-r--r--test/integration/targets/ansible-vault/test_utf8_value_in_filename.yml16
-rw-r--r--test/integration/targets/ansible-vault/test_vault.yml6
-rw-r--r--test/integration/targets/ansible-vault/test_vault_embedded.yml4
-rw-r--r--test/integration/targets/ansible-vault/test_vault_embedded_ids.yml4
-rw-r--r--test/integration/targets/ansible-vault/test_vault_file_encrypted_embedded.yml4
-rw-r--r--test/integration/targets/ansible-vault/test_vaulted_inventory.yml5
-rw-r--r--test/integration/targets/ansible-vault/test_vaulted_inventory_toml.yml9
-rw-r--r--test/integration/targets/ansible-vault/test_vaulted_template.yml6
-rw-r--r--test/integration/targets/ansible-vault/test_vaulted_utf8_value.yml15
-rw-r--r--test/integration/targets/ansible-vault/vars/vaulted.yml15
-rw-r--r--test/integration/targets/ansible-vault/vault-café.yml6
-rw-r--r--test/integration/targets/ansible-vault/vault-password1
-rw-r--r--test/integration/targets/ansible-vault/vault-password-ansible1
-rw-r--r--test/integration/targets/ansible-vault/vault-password-wrong1
-rw-r--r--test/integration/targets/ansible-vault/vault-secret.txt6
-rw-r--r--test/integration/targets/ansible-vault/vaulted.inventory8
61 files changed, 1552 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-vault/aliases b/test/integration/targets/ansible-vault/aliases
new file mode 100644
index 0000000..1d28bdb
--- /dev/null
+++ b/test/integration/targets/ansible-vault/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group5
+context/controller
diff --git a/test/integration/targets/ansible-vault/empty-password b/test/integration/targets/ansible-vault/empty-password
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/ansible-vault/empty-password
diff --git a/test/integration/targets/ansible-vault/encrypted-vault-password b/test/integration/targets/ansible-vault/encrypted-vault-password
new file mode 100644
index 0000000..7aa4e4b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/encrypted-vault-password
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+34353166613539646338666531633061646161663836373965663032313466613135313130383133
+3634383331386336333436323832356264343033323166370a323737396234376132353731643863
+62386335616635363062613562666561643931626332623464306666636131356134386531363533
+3831323230353333620a616633376363373830346332663733316634663937336663633631326361
+62343638656532393932643530633133326233316134383036316333373962626164
diff --git a/test/integration/targets/ansible-vault/encrypted_file_encrypted_var_password b/test/integration/targets/ansible-vault/encrypted_file_encrypted_var_password
new file mode 100644
index 0000000..57bc06e
--- /dev/null
+++ b/test/integration/targets/ansible-vault/encrypted_file_encrypted_var_password
@@ -0,0 +1 @@
+test-encrypted-file-password
diff --git a/test/integration/targets/ansible-vault/example1_password b/test/integration/targets/ansible-vault/example1_password
new file mode 100644
index 0000000..e723c8f
--- /dev/null
+++ b/test/integration/targets/ansible-vault/example1_password
@@ -0,0 +1 @@
+example1
diff --git a/test/integration/targets/ansible-vault/example2_password b/test/integration/targets/ansible-vault/example2_password
new file mode 100644
index 0000000..7b010f8
--- /dev/null
+++ b/test/integration/targets/ansible-vault/example2_password
@@ -0,0 +1 @@
+example2
diff --git a/test/integration/targets/ansible-vault/example3_password b/test/integration/targets/ansible-vault/example3_password
new file mode 100644
index 0000000..f5bc5a8
--- /dev/null
+++ b/test/integration/targets/ansible-vault/example3_password
@@ -0,0 +1 @@
+example3
diff --git a/test/integration/targets/ansible-vault/faux-editor.py b/test/integration/targets/ansible-vault/faux-editor.py
new file mode 100755
index 0000000..b67c747
--- /dev/null
+++ b/test/integration/targets/ansible-vault/faux-editor.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+# ansible-vault is a script that encrypts/decrypts YAML files. See
+# https://docs.ansible.com/ansible/latest/user_guide/vault.html for more details.
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import sys
+import time
+import os
+
+
+def main(args):
+ path = os.path.abspath(args[1])
+
+ fo = open(path, 'r+')
+
+ content = fo.readlines()
+
+ content.append('faux editor added at %s\n' % time.time())
+
+ fo.seek(0)
+ fo.write(''.join(content))
+ fo.close()
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[:]))
diff --git a/test/integration/targets/ansible-vault/files/test_assemble/nonsecret.txt b/test/integration/targets/ansible-vault/files/test_assemble/nonsecret.txt
new file mode 100644
index 0000000..320b6b4
--- /dev/null
+++ b/test/integration/targets/ansible-vault/files/test_assemble/nonsecret.txt
@@ -0,0 +1 @@
+THIS IS OK
diff --git a/test/integration/targets/ansible-vault/files/test_assemble/secret.vault b/test/integration/targets/ansible-vault/files/test_assemble/secret.vault
new file mode 100644
index 0000000..fd27856
--- /dev/null
+++ b/test/integration/targets/ansible-vault/files/test_assemble/secret.vault
@@ -0,0 +1,7 @@
+$ANSIBLE_VAULT;1.1;AES256
+37626439373465656332623633333336353334326531333666363766303339336134313136616165
+6561333963343739386334653636393363396366396338660a663537666561643862343233393265
+33336436633864323935356337623861663631316530336532633932623635346364363338363437
+3365313831366365350a613934313862313538626130653539303834656634353132343065633162
+34316135313837623735653932663139353164643834303534346238386435373832366564646236
+3461333465343434666639373432366139363566303564643066
diff --git a/test/integration/targets/ansible-vault/format_1_1_AES256.yml b/test/integration/targets/ansible-vault/format_1_1_AES256.yml
new file mode 100644
index 0000000..5616605
--- /dev/null
+++ b/test/integration/targets/ansible-vault/format_1_1_AES256.yml
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+33613463343938323434396164663236376438313435633837336438366530666431643031333734
+6463646538393331333239393363333830613039376562360a396635393636636539346332336364
+35303039353164386461326439346165656463383137663932323930666632326263636266656461
+3232663537653637640a643166666232633936636664376435316664656631633166323237356163
+6138
diff --git a/test/integration/targets/ansible-vault/format_1_2_AES256.yml b/test/integration/targets/ansible-vault/format_1_2_AES256.yml
new file mode 100644
index 0000000..1e3795f
--- /dev/null
+++ b/test/integration/targets/ansible-vault/format_1_2_AES256.yml
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.2;AES256;test_vault_id
+30383835613535356232333534303264656530633664616233386138396563623939626136366537
+3635323530646538626138383136636437616637616430610a386661346563346136326637656461
+64393364343964633364336666333630383164643662343930663432316333633537353938376437
+6134656262373731390a363166356461376663313532343733326438386632623930313366643038
+6133
diff --git a/test/integration/targets/ansible-vault/host_vars/myhost.yml b/test/integration/targets/ansible-vault/host_vars/myhost.yml
new file mode 100644
index 0000000..1434ec1
--- /dev/null
+++ b/test/integration/targets/ansible-vault/host_vars/myhost.yml
@@ -0,0 +1,7 @@
+myvar: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 31356335363836383937363933366135623233343830326234633633623734336636343630396464
+ 3234343638313166663237343536646336323862613739380a346266316336356230643838663031
+ 34623034383639323062373235356564393337346666393665313237313231306131356637346537
+ 3966393238666430310a363462326639323033653237373036643936613234623063643761663033
+ 3832
diff --git a/test/integration/targets/ansible-vault/host_vars/testhost.yml b/test/integration/targets/ansible-vault/host_vars/testhost.yml
new file mode 100644
index 0000000..b3e569a
--- /dev/null
+++ b/test/integration/targets/ansible-vault/host_vars/testhost.yml
@@ -0,0 +1,7 @@
+vaulted_utf8_value: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 39313961356631343234656136636231663539363963386364653436346133366366633031366364
+ 3332376636333837333036633662316135383365343335380a393331663434663238666537343163
+ 62363561336431623666633735313766613663333736653064373632666131356434336537383336
+ 3333343436613232330a643461363831633166333237653530353131316361643465353132616362
+ 3461
diff --git a/test/integration/targets/ansible-vault/invalid_format/README.md b/test/integration/targets/ansible-vault/invalid_format/README.md
new file mode 100644
index 0000000..cbbc07a
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/README.md
@@ -0,0 +1 @@
+Based on https://github.com/yves-vogl/ansible-inline-vault-issue
diff --git a/test/integration/targets/ansible-vault/invalid_format/broken-group-vars-tasks.yml b/test/integration/targets/ansible-vault/invalid_format/broken-group-vars-tasks.yml
new file mode 100644
index 0000000..71dbacc
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/broken-group-vars-tasks.yml
@@ -0,0 +1,23 @@
+---
+- hosts: broken-group-vars
+ gather_facts: false
+ tasks:
+ - name: EXPECTED FAILURE
+ debug:
+ msg: "some_var_that_fails: {{ some_var_that_fails }}"
+
+ - name: EXPECTED FAILURE Display hostvars
+ debug:
+ msg: "{{inventory_hostname}} hostvars: {{ hostvars[inventory_hostname] }}"
+
+
+# ansible-vault --vault-password-file=vault-secret encrypt_string test
+# !vault |
+# $ANSIBLE_VAULT;1.1;AES256
+# 64323332393930623633306662363165386332376638653035356132646165663632616263653366
+# 6233383362313531623238613461323861376137656265380a366464663835633065616361636231
+# 39653230653538366165623664326661653135306132313730393232343432333635326536373935
+# 3366323866663763660a323766383531396433663861656532373663373134376263383263316261
+# 3137
+
+# $ ansible-playbook -i inventory --vault-password-file=vault-secret tasks.yml
diff --git a/test/integration/targets/ansible-vault/invalid_format/broken-host-vars-tasks.yml b/test/integration/targets/ansible-vault/invalid_format/broken-host-vars-tasks.yml
new file mode 100644
index 0000000..9afbd58
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/broken-host-vars-tasks.yml
@@ -0,0 +1,7 @@
+---
+- hosts: broken-host-vars
+ gather_facts: false
+ tasks:
+ - name: EXPECTED FAILURE Display hostvars
+ debug:
+ msg: "{{inventory_hostname}} hostvars: {{ hostvars[inventory_hostname] }}"
diff --git a/test/integration/targets/ansible-vault/invalid_format/group_vars/broken-group-vars.yml b/test/integration/targets/ansible-vault/invalid_format/group_vars/broken-group-vars.yml
new file mode 100644
index 0000000..5f47743
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/group_vars/broken-group-vars.yml
@@ -0,0 +1,8 @@
+$ANSIBLE_VAULT;1.1;AES256
+64306566356165343030353932383461376334336665626135343932356431383134306338353664
+6435326361306561633165633536333234306665346437330a366265346466626464396264393262
+34616366626565336637653032336465363165363334356535353833393332313239353736623237
+6434373738633039650a353435303366323139356234616433613663626334643939303361303764
+3636363333333333333333333
+36313937643431303637353931366363643661396238303530323262326334343432383637633439
+6365373237336535353661356430313965656538363436333836
diff --git a/test/integration/targets/ansible-vault/invalid_format/host_vars/broken-host-vars.example.com/vars b/test/integration/targets/ansible-vault/invalid_format/host_vars/broken-host-vars.example.com/vars
new file mode 100644
index 0000000..2d309eb
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/host_vars/broken-host-vars.example.com/vars
@@ -0,0 +1,11 @@
+---
+example_vars:
+ some_key:
+ another_key: some_value
+ bad_vault_dict_key: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 64323332393930623633306662363165386332376638653035356132646165663632616263653366
+ 623338xyz2313531623238613461323861376137656265380a366464663835633065616361636231
+ 3366323866663763660a323766383531396433663861656532373663373134376263383263316261
+ 3137
+
diff --git a/test/integration/targets/ansible-vault/invalid_format/inventory b/test/integration/targets/ansible-vault/invalid_format/inventory
new file mode 100644
index 0000000..e6e259a
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/inventory
@@ -0,0 +1,5 @@
+[broken-group-vars]
+broken.example.com
+
+[broken-host-vars]
+broken-host-vars.example.com
diff --git a/test/integration/targets/ansible-vault/invalid_format/original-broken-host-vars b/test/integration/targets/ansible-vault/invalid_format/original-broken-host-vars
new file mode 100644
index 0000000..6be696b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/original-broken-host-vars
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+64323332393930623633306662363165386332376638653035356132646165663632616263653366
+6233383362313531623238613461323861376137656265380a366464663835633065616361636231
+3366323866663763660a323766383531396433663861656532373663373134376263383263316261
+3137
+
diff --git a/test/integration/targets/ansible-vault/invalid_format/original-group-vars.yml b/test/integration/targets/ansible-vault/invalid_format/original-group-vars.yml
new file mode 100644
index 0000000..817557b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/original-group-vars.yml
@@ -0,0 +1,2 @@
+---
+some_var_that_fails: blippy
diff --git a/test/integration/targets/ansible-vault/invalid_format/some-vars b/test/integration/targets/ansible-vault/invalid_format/some-vars
new file mode 100644
index 0000000..e841a26
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/some-vars
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+37303462633933386339386465613039363964643466663866356261313966663465646262636333
+3965643566363764356563363334363431656661636634380a333837343065326239336639373238
+64316236383836383434366662626339643561616630326137383262396331396538363136323063
+6236616130383264620a613863373631316234656236323332633166623738356664353531633239
+3533
diff --git a/test/integration/targets/ansible-vault/invalid_format/vault-secret b/test/integration/targets/ansible-vault/invalid_format/vault-secret
new file mode 100644
index 0000000..4406e35
--- /dev/null
+++ b/test/integration/targets/ansible-vault/invalid_format/vault-secret
@@ -0,0 +1 @@
+enemenemu \ No newline at end of file
diff --git a/test/integration/targets/ansible-vault/inventory.toml b/test/integration/targets/ansible-vault/inventory.toml
new file mode 100644
index 0000000..d97ed39
--- /dev/null
+++ b/test/integration/targets/ansible-vault/inventory.toml
@@ -0,0 +1,5 @@
+[vauled_group.hosts]
+vaulted_host_toml={ ansible_host="localhost", ansible_connection="local" }
+
+[vauled_group.vars]
+hello="world"
diff --git a/test/integration/targets/ansible-vault/password-script.py b/test/integration/targets/ansible-vault/password-script.py
new file mode 100755
index 0000000..1b7f02b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/password-script.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+#
+# ansible-vault is a script that encrypts/decrypts YAML files. See
+# https://docs.ansible.com/ansible/latest/user_guide/vault.html for more details.
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import sys
+
+PASSWORD = 'test-vault-password'
+
+
+def main(args):
+ print(PASSWORD)
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[:]))
diff --git a/test/integration/targets/ansible-vault/realpath.yml b/test/integration/targets/ansible-vault/realpath.yml
new file mode 100644
index 0000000..6679635
--- /dev/null
+++ b/test/integration/targets/ansible-vault/realpath.yml
@@ -0,0 +1,10 @@
+- hosts: localhost
+ gather_facts: false
+ vars_files:
+ - vaulted.yml
+ tasks:
+ - name: see if we can decrypt
+ assert:
+ that:
+ - control is defined
+ - realpath == 'this is a secret'
diff --git a/test/integration/targets/ansible-vault/roles/test_vault/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vault/tasks/main.yml
new file mode 100644
index 0000000..4e5551d
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault/tasks/main.yml
@@ -0,0 +1,9 @@
+- assert:
+ that:
+ - 'secret_var == "secret"'
+
+
+- copy: src=vault-secret.txt dest={{output_dir}}/secret.txt
+
+- name: cleanup decrypted file
+ file: path={{ output_dir }}/secret.txt state=absent
diff --git a/test/integration/targets/ansible-vault/roles/test_vault/vars/main.yml b/test/integration/targets/ansible-vault/roles/test_vault/vars/main.yml
new file mode 100644
index 0000000..cfac107
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault/vars/main.yml
@@ -0,0 +1,9 @@
+$ANSIBLE_VAULT;1.1;AES256
+31626536666232643662346539623662393436386162643439643434656231343435653936343235
+6139346364396166336636383734333430373763336434310a303137623539653939336132626234
+64613232396532313731313935333433353330666466646663303233323331636234326464643166
+6538653264636166370a613161313064653566323037393962643032353230396536313865326362
+34396262303130326632623162623230346238633932393938393766313036643835613936356233
+33323730373331386337353339613165373064323134343930333031623036326164353534646631
+31313963666234623731316238656233396638643331306231373539643039383434373035306233
+30386230363730643561
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml
new file mode 100644
index 0000000..eba9389
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+- name: Assert that a embedded vault of a string with no newline works
+ assert:
+ that:
+ - '"{{ vault_encrypted_one_line_var }}" == "Setec Astronomy"'
+
+- name: Assert that a multi line embedded vault works, including new line
+ assert:
+ that:
+ - vault_encrypted_var == "Setec Astronomy\n"
+
+# TODO: add a expected fail here
+# - debug: var=vault_encrypted_one_line_var_with_embedded_template
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_embedded/vars/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_embedded/vars/main.yml
new file mode 100644
index 0000000..54e6004
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_embedded/vars/main.yml
@@ -0,0 +1,17 @@
+# If you use normal 'ansible-vault create' or edit, files always have at least one new line
+# so c&p from a vault encrypted that wasn't specifically created sans new line ends up with one.
+# (specifically created, as in 'echo -n "just one line" > my_secret.yml'
+vault_encrypted_var: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 66386439653236336462626566653063336164663966303231363934653561363964363833313662
+ 6431626536303530376336343832656537303632313433360a626438346336353331386135323734
+ 62656361653630373231613662633962316233633936396165386439616533353965373339616234
+ 3430613539666330390a313736323265656432366236633330313963326365653937323833366536
+ 34623731376664623134383463316265643436343438623266623965636363326136
+vault_encrypted_one_line_var: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 33363965326261303234626463623963633531343539616138316433353830356566396130353436
+ 3562643163366231316662386565383735653432386435610a306664636137376132643732393835
+ 63383038383730306639353234326630666539346233376330303938323639306661313032396437
+ 6233623062366136310a633866373936313238333730653739323461656662303864663666653563
+ 3138
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/tasks/main.yml
new file mode 100644
index 0000000..9aeaf24
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/tasks/main.yml
@@ -0,0 +1,29 @@
+---
+- name: set a fact from vault_encrypted_example1_releases
+ set_fact:
+ example1_releases: "{{ vault_encrypted_example1_releases }}"
+
+- name: Assert that a embedded vault of a multiline string with a vault id works
+ assert:
+ that:
+ - "vault_encrypted_example1_releases is defined"
+ - "example1_releases is defined"
+ - "example1_releases.startswith('Ansible Releases')"
+ # - '"{{ vault_encrypted_example1_releases }}" == "Setec Astronomy"'
+
+- name: Assert that a embedded vault with a different vault id works
+ assert:
+ that:
+ - "vault_encrypted_example2_hello == 'Hello world'"
+
+- name: Assert that a embedded vault with no vault id and format 1.2 works
+ assert:
+ that:
+ - "vault_encrypted_example3_foobar == 'Foobar'"
+ #- name: Assert that a multi line embedded vault works, including new line
+ # assert:
+ # that:
+ # - vault_encrypted_var == "Setec Astronomy\n"
+
+# TODO: add a expected fail here
+# - debug: var=vault_encrypted_one_line_var_with_embedded_template
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/vars/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/vars/main.yml
new file mode 100644
index 0000000..9c8fa4b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_embedded_ids/vars/main.yml
@@ -0,0 +1,194 @@
+vault_encrypted_example2_hello: !vault |
+ $ANSIBLE_VAULT;1.2;AES256;example2
+ 30383930326535616363383537613266376364323738313835353566633533353364363837383638
+ 3737633764613862343666346337353964613138653036610a313663393231386139343835626436
+ 66633336303866323335616661366363333463616530326635383836656432396665313338313737
+ 6539616630663262650a383762303362356438616261646564303230633930336563373566623235
+ 3566
+vault_encrypted_example1_releases: !vault |
+ $ANSIBLE_VAULT;1.2;AES256;example1
+ 63643833646565393535303862343135326261343362396234656137313731313864316539616462
+ 3333313439353638393963643535633835643035383331340a393639386166313838326336363032
+ 65396565616531663839316132646230316561613865333437653666323034396337626431663931
+ 3339363233356438350a363734616337306136376139346162376334343537613032633563666361
+ 36386437356463616563646336393064626131363963643434376439346331663836663961353533
+ 62343663623863663830663531663930636532653165636238636433373835623435313632313030
+ 33333734343566393739393661383430623063323132303132306361666433386166633564626434
+ 62666361653465616636646335353230373961393863373261633461303233313965346565643434
+ 63383633303131643730366233383264373865376562623962636562343732343266636535356362
+ 62396635613231336162393630343136663731366665623835303762636161393163373361383634
+ 65333739326264346136333337363666396336353065366161316130653738356133646364316130
+ 32346636386665633131376662356238386161373565336430623263353036323561633235303135
+ 35333031316366373636326665656230343934383334303863643364613364663436383030373237
+ 35323964376564313636643633303262633033363633663966393535613064343364313161383061
+ 66393733366463393936663033633038653465636539356266353936373162303661613962393662
+ 61313534643064366432333166666130663730653333613964316130363135646532303531376537
+ 63313339623337363464343637323431336438636337386264303961333139326666306365363937
+ 36386437343036346165366439636533666237393535316536333966376536623030643663343561
+ 64626362363736316234356639663039396634653766646237376636653062383530366562323138
+ 61343537616263373137613232393731363866653038633932643163633732326463656365346535
+ 63316337346636326631326134633339363133393337393035333730663133646332343536636337
+ 36626566633162333463613735656564393764356337346535646539373536363933326139626239
+ 35386434663636343366303830663531616530616563343737653761616232303865626634646537
+ 38383430366131396133636530383865356430343965633062373366383261383231663162323566
+ 30373061366533643938383363333266636463383134393264343662623465323164356464666364
+ 35636135316333636266313038613239616638343761326332663933356164323635653861346430
+ 65616661353162633765666633393139613830626535633462633166376563313236623465626339
+ 38663138633664613738656166356431343438653833623132383330656637343661616432623362
+ 66643466343663306434353237343737633535343233653765356134373739316234353836303034
+ 37336435376135363362323130316338316135633633303861303665393766616537356666653238
+ 63366461383334356666633134616436663731633666323261393761363264333430366234353732
+ 66333732373236303338333862626537326638393964363965303532353465613638393934313538
+ 66323366353064666334626461313933333961613637663332656131383038393264636537643730
+ 35626265346363393665663431663036633461613362343330643133333232326664623833626336
+ 65353363373962383561396163653361663736383235376661626132386131353137303764623231
+ 63326538623231396366356432663537333331343335633531326331616531313039393335313139
+ 65376461323434383065383834626535393063363432326233383930626437343961313538303135
+ 39386561623662333335313661636637656336353537313466386239613166396436626630376337
+ 36633739326336366530643733393962633737343035346536366336643266346162333931633235
+ 66643966626262343862393832663132356435343561646634373835306130623637633836633166
+ 30313732333963383565373261306232663365363033376431313437326366656264346532666561
+ 63386231636634613235333363326166616238613734643739343237303963663539633535356232
+ 66393365616165393130356561363733313735336132336166353839303230643437643165353338
+ 39663138313130366635386365663830336365646562666635323361373362626339306536313664
+ 32383934623533373361666536326131316630616661623839666137656330306433326637386134
+ 34393162343535633438643036613831303265646632383231306239646132393338663564653939
+ 63613232646230616338316434376663613266303362386631353733623335643034356631383139
+ 62613932396132636339393337383065613061306162633831386236323163633439303263393663
+ 38616237313761306533636361386161666264333839616463386631633233343132373732636639
+ 61326239383961656437646236656336303638656665316633643630393063373964323534643961
+ 39383538303234343438363736373136316464643165383361336262303231353937316432366639
+ 36613662393736386433356532626162643462313234316230643639333535653064303830373166
+ 31393332336539313362373136326639386566343637623633396134643533393839353934613064
+ 65396233353363393763363231633462663537626165646666633937343733653932633733313237
+ 31323633326463333938343062626361313761646133633865623130323665336634356364366566
+ 31626562373662313064306239356336376136306336643961323839313964393734343265306137
+ 62663563306665636463356465663432346331323832666163623530666265393164336466383936
+ 64653831316162313861373462643264373965623632653430373439656535636365383066643464
+ 61366436613631386161306631386331656632636337653864343261643433363438396361373831
+ 37363532346564343562356132306432303933643431636539303039306638356537353237323036
+ 63366334623438393838383561383937313330303832326330326366303264303437646666613638
+ 37653266633362636330656666303437323138346666373265663466616635326366313233323430
+ 62616165626239363833613565326264373063376232303837363062616663333461373062323266
+ 32626636316465666230626634396431323032323962313437323837336562313438346634656335
+ 33613566636461663334623966646465623531653631653565333836613261633534393439613738
+ 66356364383637666465336666333962393735643766633836383833396533626635633734326136
+ 65656562366337326161303466336232646533346135353332643030383433643662363465633931
+ 63323761623537383438333837333733363263663630336264376239336234663866633131376463
+ 66663438313439643565316138383439353839366365393238376439626537656535643739373237
+ 66666266366533393738363138613437666435366163643835383830643333323730303537313139
+ 32313436663932633933353265356431336138306437353936363638643539383236323232326630
+ 62323963626138633865376238666264666531613237636232373938303030393632643230336138
+ 38663237646637616232343664396136376534313533613364663062356535313766343331616431
+ 36616237336532333239386663643538643239613866393631393364306463303131643863363533
+ 31356436373062666266656431643038323766383632613939616539663637623164323161633464
+ 39666663353339383164363534616330323936333865663564646334373438303061656662656331
+ 37633530663666323834383333623136633164326632313938643234326235616461323734353638
+ 63393365313334646538373631643266383936333533383630623861343764373863346161316333
+ 38356466626234653336326433353234613430623135343739323433326435373663363237643531
+ 36626238613832633661343263383962373536353766653631323431393330623634656166333437
+ 66376537643836626264383961303465363035336666306165316631316661366637303361656332
+ 36616463626135653235393562343464353262616331326539316361393036623134623361383635
+ 39383565313433653139663963306362373233313738613933626563333230656239613462363164
+ 65396539333833633137313163396635373433303164633463383935663939343266396366666231
+ 30353434323837343563613662643632386662616363646630353530386466643939623866626331
+ 63613266366135646562653064333166356561626138343364373631376336393931313262323063
+ 32653938333837366231343865656239353433663537313763376132613366363333313137323065
+ 31666663656539333438343664323062323238353061663439326333366162303636626634313037
+ 38366631306438393333356138393730316161336233656239626565366134643535383536613034
+ 37343733663631663863643337373462633462666234393063336330306465366637653136393533
+ 63336535316438303564613366343565363831666233626466623161356635363464343634303136
+ 61616561393861393036353433356364376533656334326433323934643236346133363535613334
+ 32626332653362313731643035653335383164303534616537333132356535376233343566313736
+ 39353037636530376338383739366230346134643738313037386438613461323934663537666164
+ 66353330303730336435313735343333316364373432313030396361343061343632653765646336
+ 39666537366537343635396235373433363438393637663166666530356339316334313834363938
+ 33393837336265353265303635663363353439343062316363643637623564353261643637306434
+ 36393662363737316234323461373763663364356535313165656661613137396366386464663866
+ 63653562313539313839613436653137663262346233626464616237373737373736306231383265
+ 35323532373631613762616234386162643035613838376264343532396263626562623262363532
+ 36303530353137616134346262646464633462646662323262633366393736383834616665666466
+ 34393363353135616437346332386634396635363130623337653230666334303630653738633334
+ 33316162326335373838643261656561303736363331316134363736393362313734346236306638
+ 65343163646264643539643635633761393665623039653232623435383062363462346336613238
+ 38306138353832306263356265316236303065626566643134373836303933323130303634393931
+ 31633334373064353263353135656433623863636261633664646439336539343636656464306531
+ 36373364323637393634623666353730626532613534343638663966313332636437383233303864
+ 33356432613638303936653134373338626261353662653930333534643732656130653636316433
+ 33653364373636613739353439383066646530303565383432356134396436306134643030643034
+ 63323433396238636330383836396364613738616338356563633565613537313138346661636164
+ 34333566393738343661663062346433396532613032663331313566333161396230343336346264
+ 66333935316630653936346336366336303363376633623034346536643731313136363835303964
+ 37346537373236343832306637653563386435363435333537393733333966643461623064316639
+ 65323363343338326435633631303037623234303334353366303936373664383762316364663036
+ 61353638376335333663343066303961616234336664313732366630343331613537633336316534
+ 31656561626430383338353231376263383362333966666363316435373533613138323039363463
+ 33363031373035316431353930626632666165376538303638353631303931326262386363376330
+ 36333531303235306532363763313233616165646234343235306332383262663261366164623130
+ 66613232636264636336313230303261626639316465383265373762346434616362383562633533
+ 64346438653161306266663634623666646239383363313862383563386461626264383165373561
+ 64383431653061393132623833653337643266663462666462366339363233353335386264383936
+ 38396264373833343935653264373631626662653962353438313262633339316537306463663930
+ 31613634613535346364643930613739383035336164303064653736663031633135613966656463
+ 64333539643534376662666539653766666532333832333430346333613236356534643964383135
+ 38326235626164663364366163353434613530306531343735353761396563326536636335326336
+ 34613835333362346363623235316564363934333732646435373033613863346565353034306333
+ 33643763363838656339396435316162616539623764366163376438656266353137633262613464
+ 31393434646435623032383934373262666430616262353165343231666631666238653134396539
+ 32323137616639306262366638366536366665633331653363643234643238656338316133613166
+ 38343566623137353566306538616639363935303766633732633638356362373463616563663438
+ 66346133636562373031316363616662663132636263653037343962313630313535396563313230
+ 34613735663838613130346461343166663830623861393634353438376336363961326263333634
+ 34646465326238636630316164316339333961333939363139623262396531303665383230363562
+ 63626431333365663337323430653230613837396133636431303863366239303531653966653932
+ 65363139366637623531306333363465386636366334383734353330626566346532653263633238
+ 39383434346665323730366261316433303739313032653638636232666432323930653837643831
+ 63393565306538663365616364326334306333346463343330316161616362323063666666373035
+ 66383938383238353134386333343437623030363032303531643736353636643165373362363666
+ 31363037613064633164346638306231663161626265663535363634336665656163636637393161
+ 64313363373965396262386337613533393639353332316234643666613065343939393336366633
+ 64303637323531393936386365316366656432346230653066306334626431366335353130663233
+ 62303961663362623637303535333432313635303936363462336438663232333862303934383166
+ 31626438623963346262376135633434643533316162376633353661356463616538363733346464
+ 65646563626139356264363132616161303438653133353961636135333833376364333138353263
+ 36613437373365666665643664343666366234636164626437396139393864653031396331303938
+ 35323839646265393232326434616233323535396134346465363131366165373163353932363538
+ 39353764623463393732346134656539353966643366653765663038323631373432663839396239
+ 35623665623661326231643734346134623961663539363436323134333630306663653039653062
+ 36623730663538666166363436616131363233643739393966333437643637303737383733356138
+ 34343733623137326265343332326437316365346439316137663361373066333166383032396636
+ 35623561626139666264373363363965383633653633656464393932666634353962623637643262
+ 32323663303861376166656266653962643166326535363237316333663631323235333833636361
+ 31633038353265386439313766313966633536346230646566633333646632383938363761373363
+ 38353931343136633062303366643930323034616265653030643062333461616637366666336437
+ 36346330636666313833346534363461336366393533346338653061356333653839623364336266
+ 32373965346363613165383639366365396665353966393262393562353664623231326132363735
+ 38386238336135306464366332353035613938313262323739326638623733663030656533383438
+ 38316364393030376436313031613936363435633562633862323063643035383030313865396666
+ 66646338316262653734633431393862626633643163313732343638313066646163353264653531
+ 64346265656363323666656239333466313666373234626261633630653133316639313233303466
+ 62353735626634616661396238356138343064386332366361643530613364366365663764393037
+ 31613730313234393263653964376262373131383064393133636533656534343431613964663634
+ 65656365393439306433313333346234333332346230666462633132313863623765306665306461
+ 65633862656637646134353030393637353339646265613731646564333561313431346135626532
+ 66646363383932636562343731626164633138386463356634353062323965376235383130633231
+ 61623537333030383130623064356662356463646532613339303336666631366539613835646364
+ 37636634353430386632656331313936393261643638326162376238326139643939636333366364
+ 31626163376436336631
+vault_encrypted_example3_foobar: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 37336431373836376339373763306436396334623061366266353763363766313063363230636138
+ 3665663061366436306232323636376261303064616339620a333365323266643364396136626665
+ 62363862653134623665326635396563643832636234386266616436626334363839326434383431
+ 3330373333366233380a363431386334636164643936313430623661633265346632343331373866
+ 3732
+# We dont have a secret for this vaulttext, but nothing references it
+# so nothing should ever try to decrypt it. So this is testing that
+# we dont require all vaulted vars to be decrypted.
+vault_encrypted_example4_unknown_password: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 64316436303566666563393931613833316533346539373635663031376664366131353264366132
+ 3637623935356263643639313562366434383234633232660a353636666134353030646539643139
+ 65376235333932353531356666363434313066366161383532363166653762326533323233623431
+ 3934393962633637330a356337626634343736313339316365373239663031663938353063326665
+ 30643339386131663336366531663031383030313936356631613432336338313962
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/README.md b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/README.md
new file mode 100644
index 0000000..4a75cec
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/README.md
@@ -0,0 +1 @@
+file is encrypted with password of 'test-encrypted-file-password'
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml
new file mode 100644
index 0000000..e09004a
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+- name: Assert that a vault encrypted file with embedded vault of a string with no newline works
+ assert:
+ that:
+ - '"{{ vault_file_encrypted_with_encrypted_one_line_var }}" == "Setec Astronomy"'
+
+- name: Assert that a vault encrypted file with multi line embedded vault works, including new line
+ assert:
+ that:
+ - vault_file_encrypted_with_encrypted_var == "Setec Astronomy\n"
+
+# TODO: add a expected fail here
+# - debug: var=vault_encrypted_one_line_var_with_embedded_template
diff --git a/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/vars/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/vars/main.yml
new file mode 100644
index 0000000..89cc4a0
--- /dev/null
+++ b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/vars/main.yml
@@ -0,0 +1,76 @@
+$ANSIBLE_VAULT;1.1;AES256
+31613535653961393639346266636234373833316530373965356161373735666662613137386466
+3365303539306132613861646362396161323962373839640a653030376530316136643961623665
+65643665616338363432383264363730386538353635663339633932353933653132343430613332
+6136663837306333370a643139336230663465346637663032613231656364316533613235623532
+65643738663735636662363565313561646162343865393733663838393239646634633936336262
+39626235616537663934363932323831376539666331353334386636663738643932306239663265
+64646664616331643663326561386638393764313737303865326166373031336665663533373431
+35353736346264616135656164636337363966323935643032646138366166636537333565306230
+65646533623134393633623663336263393533613632663464653663313835306265333139646563
+35393061343266343138333936646364333735373930666262376137396562356231393330313731
+36363164623939393436363564353162373364626536376434626463343161646437316665613662
+38343534363965373735316339643061333931666264353566316235616433666536313065306132
+31623933633533366162323961343662323364353065316235303162306635663435663066393865
+64356634363761333838326331343865653633396665353638633730663134313565653166656131
+33366464396532313635326237363135316230663838393030303963616161393966393836633237
+30333338343031366235396438663838633136666563646161363332663533626662663531653439
+63643435383931663038613637346637383365336431646663366436626333313536396135636566
+31373133363661636338376166356664353366343730373164663361623338383636336464373038
+36306437363139346233623036636330333664323165636538666138306465653435666132623835
+30363266333666626363366465313165643761396562653761313764616562666439366437623766
+33343666623866653461376137353731356530363732386261383863666439333735666638653533
+38393430323961356333383464643036383739663064633461363937336538373539666662653764
+36376266333230666232396665616434303432653562353131383430643533623932363537346435
+33326335663561643564663936323832376634336363373531363666333732643363646130383464
+30656366633863643966656134653833343634383136363539366330336261313736343838663936
+39333835353035386664633331303264356339613933393162393037306565636563386436633532
+34376564343237303166613461383963353030383166326538643932323130643830376165366564
+30366432623761623366653966313865653262363064316130393339393366323539373338306265
+31626564393065303032383161343137636432353061333964613935363865356139313766303039
+32333863353465306265653237396232383330333438303866316362353161383266316633663364
+66353130326237376331656334633965633339303138656263616239323261663864666236323662
+33643463303965313264396463333963376464313838373765633463396534363836366132653437
+30303132633232623265303966316639373664656262636166653438323534326435363966616133
+33663463626536643930623034343237613933623462346635306565623834346532613539383838
+39356339303930663739333236316234666633623961323362323537313833383538363132636165
+31396433386664356532383432666464613137376561396534316665386134333665626430373064
+30626561363731326635393334633837303934653062616461303732316239663764633565353633
+33336161623332383064376538353531343534333836313139376439316564313436623462396134
+31643831656135653234396362653861643933346433646633383130323139353465616430383061
+34623164376436326466333765353037323630356662646364366265303534313764393862653238
+66376365323561643030343534636263386338333566613436383630613561646639616265313465
+66336239303432666361383038323038383663346561356664626634333037313838363732643463
+33373734663933373238363635623336323232313161353861306430323334353836616265623639
+65613436323939643932383537666530306134633435373331623963633436386162306565656433
+35383962633163643837343436383664313565656134646633393237353065666535316561613266
+64653234366462623764313438666466616664303138656565663036376230323763393135323330
+35383861306262356430656531343938643763306663323031636638383762626564616366393434
+33373035363633396230396161623433336530326432343666346332613262376338313731626462
+63616463363831333239643535383936646264336466616635353063383163306564373263656265
+65383466653162626132633463613037343865316639653931633965323637373733653131666233
+35643831646638383232616538656265663365306136343733633535323537653165636665383832
+65303162656238303665346232353136346639316263636264346533356263353066353438323535
+36303236326663303763653137656264336566646161663538383361306138323064336235616438
+32373731643331373239383339326365366337646237643836373238656339646362366239623533
+33306531353863653834666361393161366465626632643061363266353465653964363263613430
+32323132613866343733376437643239316661313330323661633234343630626132383434343461
+61663765383134666330316237633963323463363762383666323866386336316438373461306138
+38613266346532313134386236386131626262663534313935623635343533383831386332343534
+65333963353861656232383134396438613034663333633661346465636436373533346561306661
+33656535613963663938313233333736343036393734373363316236373765343736633635386336
+30323036393431363636316466393561626365366333623431353435633963613935346239666534
+33623037306334343464633932313430616666633631313366356532643938333835333231313039
+65363734336630303861626636613139663130616362333662616532313734393636353963643032
+39626162623933616561383736636466316331346135613063383261373865366232376562316237
+65393563633131653761646365313831646265316233343833653363626465363863363936316664
+63363863363761353264316662643338656432356336326339623961396538643838666330303934
+62343537653262353737316266366134623961323637613338303164383734613034383964623135
+35646130363038356530383638663431663238336337313034303631366538326361646530626138
+34653533383964353866653562666463333961313434373063333163346537636631393138316465
+62656361613365366137346337363830356263633162623466373564346437653036386136333333
+32323863393866373932353534343133306333303265336564383132616365363439393364336562
+62333130343664343436356338623336643735373164373962313762333763343137626238316536
+36376539666331376162376361646631396231306165316362343164616232393864656161393735
+63313439643865346231346363376137306464396637356539353139343932333438323964323035
+326532383066643037653036333166346238
diff --git a/test/integration/targets/ansible-vault/roles/test_vaulted_template/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vaulted_template/tasks/main.yml
new file mode 100644
index 0000000..b4af5ef
--- /dev/null
+++ b/test/integration/targets/ansible-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_template_out
+
+- debug:
+ msg: "{{ vaulted_template_out.content|b64decode }}"
+
+- assert:
+ that:
+ - vaulted_template_out.content|b64decode == 'here_i_am\n'
diff --git a/test/integration/targets/ansible-vault/roles/test_vaulted_template/templates/vaulted_template.j2 b/test/integration/targets/ansible-vault/roles/test_vaulted_template/templates/vaulted_template.j2
new file mode 100644
index 0000000..af9c3eb
--- /dev/null
+++ b/test/integration/targets/ansible-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/ansible-vault/runme.sh b/test/integration/targets/ansible-vault/runme.sh
new file mode 100755
index 0000000..50720ea
--- /dev/null
+++ b/test/integration/targets/ansible-vault/runme.sh
@@ -0,0 +1,576 @@
+#!/usr/bin/env bash
+
+set -euvx
+source virtualenv.sh
+
+
+MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
+trap 'rm -rf "${MYTMPDIR}"' EXIT
+
+# create a test file
+TEST_FILE="${MYTMPDIR}/test_file"
+echo "This is a test file" > "${TEST_FILE}"
+
+TEST_FILE_1_2="${MYTMPDIR}/test_file_1_2"
+echo "This is a test file for format 1.2" > "${TEST_FILE_1_2}"
+
+TEST_FILE_ENC_PASSWORD="${MYTMPDIR}/test_file_enc_password"
+echo "This is a test file for encrypted with a vault password that is itself vault encrypted" > "${TEST_FILE_ENC_PASSWORD}"
+
+TEST_FILE_ENC_PASSWORD_DEFAULT="${MYTMPDIR}/test_file_enc_password_default"
+echo "This is a test file for encrypted with a vault password that is itself vault encrypted using --encrypted-vault-id default" > "${TEST_FILE_ENC_PASSWORD_DEFAULT}"
+
+TEST_FILE_OUTPUT="${MYTMPDIR}/test_file_output"
+
+TEST_FILE_EDIT="${MYTMPDIR}/test_file_edit"
+echo "This is a test file for edit" > "${TEST_FILE_EDIT}"
+
+TEST_FILE_EDIT2="${MYTMPDIR}/test_file_edit2"
+echo "This is a test file for edit2" > "${TEST_FILE_EDIT2}"
+
+# test case for https://github.com/ansible/ansible/issues/35834
+# (being prompted for new password on vault-edit with no configured passwords)
+
+TEST_FILE_EDIT3="${MYTMPDIR}/test_file_edit3"
+echo "This is a test file for edit3" > "${TEST_FILE_EDIT3}"
+
+# ansible-config view
+ansible-config view
+
+# ansible-config
+ansible-config dump --only-changed
+ansible-vault encrypt "$@" --vault-id vault-password "${TEST_FILE_EDIT3}"
+# EDITOR=./faux-editor.py ansible-vault edit "$@" "${TEST_FILE_EDIT3}"
+EDITOR=./faux-editor.py ansible-vault edit --vault-id vault-password -vvvvv "${TEST_FILE_EDIT3}"
+echo $?
+
+# view the vault encrypted password file
+ansible-vault view "$@" --vault-id vault-password encrypted-vault-password
+
+# encrypt with a password from a vault encrypted password file and multiple vault-ids
+# should fail because we dont know which vault id to use to encrypt with
+ansible-vault encrypt "$@" --vault-id vault-password --vault-id encrypted-vault-password "${TEST_FILE_ENC_PASSWORD}" && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (5 is expected)"
+[ $WRONG_RC -eq 5 ]
+
+# try to view the file encrypted with the vault-password we didnt specify
+# to verify we didnt choose the wrong vault-id
+ansible-vault view "$@" --vault-id vault-password encrypted-vault-password
+
+FORMAT_1_1_HEADER="\$ANSIBLE_VAULT;1.1;AES256"
+FORMAT_1_2_HEADER="\$ANSIBLE_VAULT;1.2;AES256"
+
+
+VAULT_PASSWORD_FILE=vault-password
+# new format, view, using password client script
+ansible-vault view "$@" --vault-id vault-password@test-vault-client.py format_1_1_AES256.yml
+
+# view, using password client script, unknown vault/keyname
+ansible-vault view "$@" --vault-id some_unknown_vault_id@test-vault-client.py format_1_1_AES256.yml && :
+
+# Use linux setsid to test without a tty. No setsid if osx/bsd though...
+if [ -x "$(command -v setsid)" ]; then
+ # tests related to https://github.com/ansible/ansible/issues/30993
+ CMD='ansible-playbook -i ../../inventory -vvvvv --ask-vault-pass test_vault.yml'
+ setsid sh -c "echo test-vault-password|${CMD}" < /dev/null > log 2>&1 && :
+ WRONG_RC=$?
+ cat log
+ echo "rc was $WRONG_RC (0 is expected)"
+ [ $WRONG_RC -eq 0 ]
+
+ setsid sh -c 'tty; ansible-vault view --ask-vault-pass -vvvvv test_vault.yml' < /dev/null > log 2>&1 && :
+ WRONG_RC=$?
+ echo "rc was $WRONG_RC (1 is expected)"
+ [ $WRONG_RC -eq 1 ]
+ cat log
+
+ setsid sh -c 'tty; echo passbhkjhword|ansible-playbook -i ../../inventory -vvvvv --ask-vault-pass test_vault.yml' < /dev/null > log 2>&1 && :
+ WRONG_RC=$?
+ echo "rc was $WRONG_RC (1 is expected)"
+ [ $WRONG_RC -eq 1 ]
+ cat log
+
+ setsid sh -c 'tty; echo test-vault-password |ansible-playbook -i ../../inventory -vvvvv --ask-vault-pass test_vault.yml' < /dev/null > log 2>&1
+ echo $?
+ cat log
+
+ setsid sh -c 'tty; echo test-vault-password|ansible-playbook -i ../../inventory -vvvvv --ask-vault-pass test_vault.yml' < /dev/null > log 2>&1
+ echo $?
+ cat log
+
+ setsid sh -c 'tty; echo test-vault-password |ansible-playbook -i ../../inventory -vvvvv --ask-vault-pass test_vault.yml' < /dev/null > log 2>&1
+ echo $?
+ cat log
+
+ setsid sh -c 'tty; echo test-vault-password|ansible-vault view --ask-vault-pass -vvvvv vaulted.inventory' < /dev/null > log 2>&1
+ echo $?
+ cat log
+
+ # test using --ask-vault-password option
+ CMD='ansible-playbook -i ../../inventory -vvvvv --ask-vault-password test_vault.yml'
+ setsid sh -c "echo test-vault-password|${CMD}" < /dev/null > log 2>&1 && :
+ WRONG_RC=$?
+ cat log
+ echo "rc was $WRONG_RC (0 is expected)"
+ [ $WRONG_RC -eq 0 ]
+fi
+
+ansible-vault view "$@" --vault-password-file vault-password-wrong format_1_1_AES256.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+set -eux
+
+
+# new format, view
+ansible-vault view "$@" --vault-password-file vault-password format_1_1_AES256.yml
+
+# new format, view with vault-id
+ansible-vault view "$@" --vault-id=vault-password format_1_1_AES256.yml
+
+# new format, view, using password script
+ansible-vault view "$@" --vault-password-file password-script.py format_1_1_AES256.yml
+
+# new format, view, using password script with vault-id
+ansible-vault view "$@" --vault-id password-script.py format_1_1_AES256.yml
+
+# new 1.2 format, view
+ansible-vault view "$@" --vault-password-file vault-password format_1_2_AES256.yml
+
+# new 1.2 format, view with vault-id
+ansible-vault view "$@" --vault-id=test_vault_id@vault-password format_1_2_AES256.yml
+
+# new 1,2 format, view, using password script
+ansible-vault view "$@" --vault-password-file password-script.py format_1_2_AES256.yml
+
+# new 1.2 format, view, using password script with vault-id
+ansible-vault view "$@" --vault-id password-script.py format_1_2_AES256.yml
+
+# newish 1.1 format, view, using a vault-id list from config env var
+ANSIBLE_VAULT_IDENTITY_LIST='wrong-password@vault-password-wrong,default@vault-password' ansible-vault view "$@" --vault-id password-script.py format_1_1_AES256.yml
+
+# new 1.2 format, view, ENFORCE_IDENTITY_MATCH=true, should fail, no 'test_vault_id' vault_id
+ANSIBLE_VAULT_ID_MATCH=1 ansible-vault view "$@" --vault-password-file vault-password format_1_2_AES256.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# new 1.2 format, view with vault-id, ENFORCE_IDENTITY_MATCH=true, should work, 'test_vault_id' is provided
+ANSIBLE_VAULT_ID_MATCH=1 ansible-vault view "$@" --vault-id=test_vault_id@vault-password format_1_2_AES256.yml
+
+# new 1,2 format, view, using password script, ENFORCE_IDENTITY_MATCH=true, should fail, no 'test_vault_id'
+ANSIBLE_VAULT_ID_MATCH=1 ansible-vault view "$@" --vault-password-file password-script.py format_1_2_AES256.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+
+# new 1.2 format, view, using password script with vault-id, ENFORCE_IDENTITY_MATCH=true, should fail
+ANSIBLE_VAULT_ID_MATCH=1 ansible-vault view "$@" --vault-id password-script.py format_1_2_AES256.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# new 1.2 format, view, using password script with vault-id, ENFORCE_IDENTITY_MATCH=true, 'test_vault_id' provided should work
+ANSIBLE_VAULT_ID_MATCH=1 ansible-vault view "$@" --vault-id=test_vault_id@password-script.py format_1_2_AES256.yml
+
+# test with a default vault password set via config/env, right password
+ANSIBLE_VAULT_PASSWORD_FILE=vault-password ansible-vault view "$@" format_1_1_AES256.yml
+
+# test with a default vault password set via config/env, wrong password
+ANSIBLE_VAULT_PASSWORD_FILE=vault-password-wrong ansible-vault view "$@" format_1_1_AES.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# test with a default vault-id list set via config/env, right password
+ANSIBLE_VAULT_PASSWORD_FILE=wrong@vault-password-wrong,correct@vault-password ansible-vault view "$@" format_1_1_AES.yml && :
+
+# test with a default vault-id list set via config/env,wrong passwords
+ANSIBLE_VAULT_PASSWORD_FILE=wrong@vault-password-wrong,alsowrong@vault-password-wrong ansible-vault view "$@" format_1_1_AES.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# try specifying a --encrypt-vault-id that doesnt exist, should exit with an error indicating
+# that --encrypt-vault-id and the known vault-ids
+ansible-vault encrypt "$@" --vault-password-file vault-password --encrypt-vault-id doesnt_exist "${TEST_FILE}" && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# encrypt it
+ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE}"
+
+ansible-vault view "$@" --vault-password-file vault-password "${TEST_FILE}"
+
+# view with multiple vault-password files, including a wrong one
+ansible-vault view "$@" --vault-password-file vault-password --vault-password-file vault-password-wrong "${TEST_FILE}"
+
+# view with multiple vault-password files, including a wrong one, using vault-id
+ansible-vault view "$@" --vault-id vault-password --vault-id vault-password-wrong "${TEST_FILE}"
+
+# And with the password files specified in a different order
+ansible-vault view "$@" --vault-password-file vault-password-wrong --vault-password-file vault-password "${TEST_FILE}"
+
+# And with the password files specified in a different order, using vault-id
+ansible-vault view "$@" --vault-id vault-password-wrong --vault-id vault-password "${TEST_FILE}"
+
+# And with the password files specified in a different order, using --vault-id and non default vault_ids
+ansible-vault view "$@" --vault-id test_vault_id@vault-password-wrong --vault-id test_vault_id@vault-password "${TEST_FILE}"
+
+ansible-vault decrypt "$@" --vault-password-file vault-password "${TEST_FILE}"
+
+# encrypt it, using a vault_id so we write a 1.2 format file
+ansible-vault encrypt "$@" --vault-id test_vault_1_2@vault-password "${TEST_FILE_1_2}"
+
+ansible-vault view "$@" --vault-id vault-password "${TEST_FILE_1_2}"
+ansible-vault view "$@" --vault-id test_vault_1_2@vault-password "${TEST_FILE_1_2}"
+
+# view with multiple vault-password files, including a wrong one
+ansible-vault view "$@" --vault-id vault-password --vault-id wrong_password@vault-password-wrong "${TEST_FILE_1_2}"
+
+# And with the password files specified in a different order, using vault-id
+ansible-vault view "$@" --vault-id vault-password-wrong --vault-id vault-password "${TEST_FILE_1_2}"
+
+# And with the password files specified in a different order, using --vault-id and non default vault_ids
+ansible-vault view "$@" --vault-id test_vault_id@vault-password-wrong --vault-id test_vault_id@vault-password "${TEST_FILE_1_2}"
+
+ansible-vault decrypt "$@" --vault-id test_vault_1_2@vault-password "${TEST_FILE_1_2}"
+
+# multiple vault passwords
+ansible-vault view "$@" --vault-password-file vault-password --vault-password-file vault-password-wrong format_1_1_AES256.yml
+
+# multiple vault passwords, --vault-id
+ansible-vault view "$@" --vault-id test_vault_id@vault-password --vault-id test_vault_id@vault-password-wrong format_1_1_AES256.yml
+
+# encrypt it, with password from password script
+ansible-vault encrypt "$@" --vault-password-file password-script.py "${TEST_FILE}"
+
+ansible-vault view "$@" --vault-password-file password-script.py "${TEST_FILE}"
+
+ansible-vault decrypt "$@" --vault-password-file password-script.py "${TEST_FILE}"
+
+# encrypt it, with password from password script
+ansible-vault encrypt "$@" --vault-id test_vault_id@password-script.py "${TEST_FILE}"
+
+ansible-vault view "$@" --vault-id test_vault_id@password-script.py "${TEST_FILE}"
+
+ansible-vault decrypt "$@" --vault-id test_vault_id@password-script.py "${TEST_FILE}"
+
+# new password file for rekeyed file
+NEW_VAULT_PASSWORD="${MYTMPDIR}/new-vault-password"
+echo "newpassword" > "${NEW_VAULT_PASSWORD}"
+
+ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE}"
+
+ansible-vault rekey "$@" --vault-password-file vault-password --new-vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FILE}"
+
+# --new-vault-password-file and --new-vault-id should cause options error
+ansible-vault rekey "$@" --vault-password-file vault-password --new-vault-id=foobar --new-vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FILE}" && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (2 is expected)"
+[ $WRONG_RC -eq 2 ]
+
+ansible-vault view "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FILE}"
+
+# view file with unicode in filename
+ansible-vault view "$@" --vault-password-file vault-password vault-café.yml
+
+# view with old password file and new password file
+ansible-vault view "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --vault-password-file vault-password "${TEST_FILE}"
+
+# view with old password file and new password file, different order
+ansible-vault view "$@" --vault-password-file vault-password --vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FILE}"
+
+# view with old password file and new password file and another wrong
+ansible-vault view "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --vault-password-file vault-password-wrong --vault-password-file vault-password "${TEST_FILE}"
+
+# view with old password file and new password file and another wrong, using --vault-id
+ansible-vault view "$@" --vault-id "tmp_new_password@${NEW_VAULT_PASSWORD}" --vault-id wrong_password@vault-password-wrong --vault-id myorg@vault-password "${TEST_FILE}"
+
+ansible-vault decrypt "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" "${TEST_FILE}"
+
+# reading/writing to/from stdin/stdin (See https://github.com/ansible/ansible/issues/23567)
+ansible-vault encrypt "$@" --vault-password-file "${VAULT_PASSWORD_FILE}" --output="${TEST_FILE_OUTPUT}" < "${TEST_FILE}"
+OUTPUT=$(ansible-vault decrypt "$@" --vault-password-file "${VAULT_PASSWORD_FILE}" --output=- < "${TEST_FILE_OUTPUT}")
+echo "${OUTPUT}" | grep 'This is a test file'
+
+OUTPUT_DASH=$(ansible-vault decrypt "$@" --vault-password-file "${VAULT_PASSWORD_FILE}" --output=- "${TEST_FILE_OUTPUT}")
+echo "${OUTPUT_DASH}" | grep 'This is a test file'
+
+OUTPUT_DASH_SPACE=$(ansible-vault decrypt "$@" --vault-password-file "${VAULT_PASSWORD_FILE}" --output - "${TEST_FILE_OUTPUT}")
+echo "${OUTPUT_DASH_SPACE}" | grep 'This is a test file'
+
+
+# test using an empty vault password file
+ansible-vault view "$@" --vault-password-file empty-password format_1_1_AES256.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+ansible-vault view "$@" --vault-id=empty@empty-password --vault-password-file empty-password format_1_1_AES256.yml && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+echo 'foo' > some_file.txt
+ansible-vault encrypt "$@" --vault-password-file empty-password some_file.txt && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+
+ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" "a test string"
+
+# Test with multiple vault password files
+# https://github.com/ansible/ansible/issues/57172
+env ANSIBLE_VAULT_PASSWORD_FILE=vault-password ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --encrypt-vault-id default "a test string"
+
+ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --name "blippy" "a test string names blippy"
+
+ansible-vault encrypt_string "$@" --vault-id "${NEW_VAULT_PASSWORD}" "a test string"
+
+ansible-vault encrypt_string "$@" --vault-id "${NEW_VAULT_PASSWORD}" --name "blippy" "a test string names blippy"
+
+
+# from stdin
+ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" < "${TEST_FILE}"
+
+ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --stdin-name "the_var_from_stdin" < "${TEST_FILE}"
+
+# write to file
+ansible-vault encrypt_string "$@" --vault-password-file "${NEW_VAULT_PASSWORD}" --name "blippy" "a test string names blippy" --output "${MYTMPDIR}/enc_string_test_file"
+
+[ -f "${MYTMPDIR}/enc_string_test_file" ];
+
+# test ansible-vault edit with a faux editor
+ansible-vault encrypt "$@" --vault-password-file vault-password "${TEST_FILE_EDIT}"
+
+# edit a 1.1 format with no vault-id, should stay 1.1
+EDITOR=./faux-editor.py ansible-vault edit "$@" --vault-password-file vault-password "${TEST_FILE_EDIT}"
+head -1 "${TEST_FILE_EDIT}" | grep "${FORMAT_1_1_HEADER}"
+
+# edit a 1.1 format with vault-id, should stay 1.1
+cat "${TEST_FILE_EDIT}"
+EDITOR=./faux-editor.py ansible-vault edit "$@" --vault-id vault_password@vault-password "${TEST_FILE_EDIT}"
+cat "${TEST_FILE_EDIT}"
+head -1 "${TEST_FILE_EDIT}" | grep "${FORMAT_1_1_HEADER}"
+
+ansible-vault encrypt "$@" --vault-id vault_password@vault-password "${TEST_FILE_EDIT2}"
+
+# verify that we aren't prompted for a new vault password on edit if we are running interactively (ie, with prompts)
+# have to use setsid nd --ask-vault-pass to force a prompt to simulate.
+# See https://github.com/ansible/ansible/issues/35834
+setsid sh -c 'tty; echo password |ansible-vault edit --ask-vault-pass vault_test.yml' < /dev/null > log 2>&1 && :
+grep 'New Vault password' log && :
+WRONG_RC=$?
+echo "The stdout log had 'New Vault password' in it and it is not supposed to. rc of grep was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# edit a 1.2 format with vault id, should keep vault id and 1.2 format
+EDITOR=./faux-editor.py ansible-vault edit "$@" --vault-id vault_password@vault-password "${TEST_FILE_EDIT2}"
+head -1 "${TEST_FILE_EDIT2}" | grep "${FORMAT_1_2_HEADER};vault_password"
+
+# edit a 1.2 file with no vault-id, should keep vault id and 1.2 format
+EDITOR=./faux-editor.py ansible-vault edit "$@" --vault-password-file vault-password "${TEST_FILE_EDIT2}"
+head -1 "${TEST_FILE_EDIT2}" | grep "${FORMAT_1_2_HEADER};vault_password"
+
+# encrypt with a password from a vault encrypted password file and multiple vault-ids
+# should fail because we dont know which vault id to use to encrypt with
+ansible-vault encrypt "$@" --vault-id vault-password --vault-id encrypted-vault-password "${TEST_FILE_ENC_PASSWORD}" && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (5 is expected)"
+[ $WRONG_RC -eq 5 ]
+
+
+# encrypt with a password from a vault encrypted password file and multiple vault-ids
+# but this time specify with --encrypt-vault-id, but specifying vault-id names (instead of default)
+# ansible-vault encrypt "$@" --vault-id from_vault_password@vault-password --vault-id from_encrypted_vault_password@encrypted-vault-password --encrypt-vault-id from_encrypted_vault_password "${TEST_FILE(_ENC_PASSWORD}"
+
+# try to view the file encrypted with the vault-password we didnt specify
+# to verify we didnt choose the wrong vault-id
+# ansible-vault view "$@" --vault-id vault-password "${TEST_FILE_ENC_PASSWORD}" && :
+# WRONG_RC=$?
+# echo "rc was $WRONG_RC (1 is expected)"
+# [ $WRONG_RC -eq 1 ]
+
+ansible-vault encrypt "$@" --vault-id vault-password "${TEST_FILE_ENC_PASSWORD}"
+
+# view the file encrypted with a password from a vault encrypted password file
+ansible-vault view "$@" --vault-id vault-password --vault-id encrypted-vault-password "${TEST_FILE_ENC_PASSWORD}"
+
+# try to view the file encrypted with a password from a vault encrypted password file but without the password to the password file.
+# This should fail with an
+ansible-vault view "$@" --vault-id encrypted-vault-password "${TEST_FILE_ENC_PASSWORD}" && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+
+# test playbooks using vaulted files
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password --list-tasks
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password --list-hosts
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password --syntax-check
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password
+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
+
+# test using --vault-pass-file option
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-pass-file vault-password
+
+# install TOML for parse toml inventory
+# test playbooks using vaulted files(toml)
+pip install toml
+ansible-vault encrypt ./inventory.toml -v "$@" --vault-password-file=./vault-password
+ansible-playbook test_vaulted_inventory_toml.yml -i ./inventory.toml -v "$@" --vault-password-file vault-password
+ansible-vault decrypt ./inventory.toml -v "$@" --vault-password-file=./vault-password
+
+# test a playbook with a host_var whose value is non-ascii utf8 (see https://github.com/ansible/ansible/issues/37258)
+ansible-playbook -i ../../inventory -v "$@" --vault-id vault-password test_vaulted_utf8_value.yml
+
+# test with password from password script
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file password-script.py
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file password-script.py
+
+# with multiple password files
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password --vault-password-file vault-password-wrong
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong --vault-password-file vault-password
+
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password --vault-password-file vault-password-wrong --syntax-check
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong --vault-password-file vault-password
+
+# test with a default vault password file set in config
+ANSIBLE_VAULT_PASSWORD_FILE=vault-password ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong
+
+# test using vault_identity_list config
+ANSIBLE_VAULT_IDENTITY_LIST='wrong-password@vault-password-wrong,default@vault-password' ansible-playbook test_vault.yml -i ../../inventory -v "$@"
+
+# test that we can have a vault encrypted yaml file that includes embedded vault vars
+# that were encrypted with a different vault secret
+ansible-playbook test_vault_file_encrypted_embedded.yml -i ../../inventory "$@" --vault-id encrypted_file_encrypted_var_password --vault-id vault-password
+
+# with multiple password files, --vault-id, ordering
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-id vault-password --vault-id vault-password-wrong
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-id vault-password-wrong --vault-id vault-password
+
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-id vault-password --vault-id vault-password-wrong --syntax-check
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-id vault-password-wrong --vault-id vault-password
+
+# test with multiple password files, including a script, and a wrong password
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong --vault-password-file password-script.py --vault-password-file vault-password
+
+# test with multiple password files, including a script, and a wrong password, and a mix of --vault-id and --vault-password-file
+ansible-playbook test_vault_embedded.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong --vault-id password-script.py --vault-id vault-password
+
+# test with multiple password files, including a script, and a wrong password, and a mix of --vault-id and --vault-password-file
+ansible-playbook test_vault_embedded_ids.yml -i ../../inventory -v "$@" \
+ --vault-password-file vault-password-wrong \
+ --vault-id password-script.py --vault-id example1@example1_password \
+ --vault-id example2@example2_password --vault-password-file example3_password \
+ --vault-id vault-password
+
+# with wrong password
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# with multiple wrong passwords
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-password-file vault-password-wrong --vault-password-file vault-password-wrong && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# with wrong password, --vault-id
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-id vault-password-wrong && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# with multiple wrong passwords with --vault-id
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-id vault-password-wrong --vault-id vault-password-wrong && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# with multiple wrong passwords with --vault-id
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-id wrong1@vault-password-wrong --vault-id wrong2@vault-password-wrong && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# with empty password file
+ansible-playbook test_vault.yml -i ../../inventory -v "$@" --vault-id empty@empty-password && :
+WRONG_RC=$?
+echo "rc was $WRONG_RC (1 is expected)"
+[ $WRONG_RC -eq 1 ]
+
+# test invalid format ala https://github.com/ansible/ansible/issues/28038
+EXPECTED_ERROR='Vault format unhexlify error: Non-hexadecimal digit found'
+ansible-playbook "$@" -i invalid_format/inventory --vault-id invalid_format/vault-secret invalid_format/broken-host-vars-tasks.yml 2>&1 | grep "${EXPECTED_ERROR}"
+
+EXPECTED_ERROR='Vault format unhexlify error: Odd-length string'
+ansible-playbook "$@" -i invalid_format/inventory --vault-id invalid_format/vault-secret invalid_format/broken-group-vars-tasks.yml 2>&1 | grep "${EXPECTED_ERROR}"
+
+# Run playbook with vault file with unicode in filename (https://github.com/ansible/ansible/issues/50316)
+ansible-playbook -i ../../inventory -v "$@" --vault-password-file vault-password test_utf8_value_in_filename.yml
+
+# Ensure we don't leave unencrypted temp files dangling
+ansible-playbook -v "$@" --vault-password-file vault-password test_dangling_temp.yml
+
+ansible-playbook "$@" --vault-password-file vault-password single_vault_as_string.yml
+
+# Test that only one accessible vault password is required
+export ANSIBLE_VAULT_IDENTITY_LIST="id1@./nonexistent, id2@${MYTMPDIR}/unreadable, id3@./vault-password"
+
+touch "${MYTMPDIR}/unreadable"
+sudo chmod 000 "${MYTMPDIR}/unreadable"
+
+ansible-vault encrypt_string content
+ansible-vault encrypt_string content --encrypt-vault-id id3
+
+set +e
+
+# Try to use a missing vault password file
+ansible-vault encrypt_string content --encrypt-vault-id id1 2>&1 | tee out.txt
+test $? -ne 0
+grep out.txt -e '[WARNING]: Error getting vault password file (id1)'
+grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids ['id3']"
+
+# Try to use an inaccessible vault password file
+ansible-vault encrypt_string content --encrypt-vault-id id2 2>&1 | tee out.txt
+test $? -ne 0
+grep out.txt -e "[WARNING]: Error in vault password file loading (id2)"
+grep out.txt -e "ERROR! Did not find a match for --encrypt-vault-id=id2 in the known vault-ids ['id3']"
+
+set -e
+unset ANSIBLE_VAULT_IDENTITY_LIST
+
+# 'real script'
+ansible-playbook realpath.yml "$@" --vault-password-file script/vault-secret.sh
+
+# using symlink
+ansible-playbook symlink.yml "$@" --vault-password-file symlink/get-password-symlink
+
+### NEGATIVE TESTS
+
+ER='Attempting to decrypt'
+#### no secrets
+# 'real script'
+ansible-playbook realpath.yml "$@" 2>&1 |grep "${ER}"
+
+# using symlink
+ansible-playbook symlink.yml "$@" 2>&1 |grep "${ER}"
+
+ER='Decryption failed'
+### wrong secrets
+# 'real script'
+ansible-playbook realpath.yml "$@" --vault-password-file symlink/get-password-symlink 2>&1 |grep "${ER}"
+
+# using symlink
+ansible-playbook symlink.yml "$@" --vault-password-file script/vault-secret.sh 2>&1 |grep "${ER}"
diff --git a/test/integration/targets/ansible-vault/script/vault-secret.sh b/test/integration/targets/ansible-vault/script/vault-secret.sh
new file mode 100755
index 0000000..3aa1c2e
--- /dev/null
+++ b/test/integration/targets/ansible-vault/script/vault-secret.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+set -eu
+
+# shellcheck disable=SC2086
+basename="$(basename $0)"
+# shellcheck disable=SC2046
+# shellcheck disable=SC2086
+dirname="$(basename $(dirname $0))"
+basename_prefix="get-password"
+default_password="foo-bar"
+
+case "${basename}" in
+ "${basename_prefix}"-*)
+ password="${default_password}-${basename#${basename_prefix}-}"
+ ;;
+ *)
+ password="${default_password}"
+ ;;
+esac
+
+# the password is different depending on the path used (direct or symlink)
+# it would be the same if symlink is 'resolved'.
+echo "${password}_${dirname}"
diff --git a/test/integration/targets/ansible-vault/single_vault_as_string.yml b/test/integration/targets/ansible-vault/single_vault_as_string.yml
new file mode 100644
index 0000000..2d523a0
--- /dev/null
+++ b/test/integration/targets/ansible-vault/single_vault_as_string.yml
@@ -0,0 +1,117 @@
+- hosts: localhost
+ vars:
+ vaulted_value: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 35323961353038346165643738646465376139363061353835303739663538343266303232326635
+ 3365353662646236356665323135633630656238316530640a663362363763633436373439663031
+ 33663433383037396438656464636433653837376361313638366362333037323961316364363363
+ 3835616438623261650a636164376534376661393134326662326362323131373964313961623365
+ 3833
+ tasks:
+ - debug:
+ msg: "{{ vaulted_value }}"
+
+ - debug:
+ msg: "{{ vaulted_value|type_debug }}"
+
+ - assert:
+ that:
+ - vaulted_value is vault_encrypted
+ - vaulted_value == 'foo bar'
+ - vaulted_value|string == 'foo bar'
+ - vaulted_value|quote == "'foo bar'"
+ - vaulted_value|capitalize == 'Foo bar'
+ - vaulted_value|center(width=9) == ' foo bar '
+ - vaulted_value|default('monkey') == 'foo bar'
+ - vaulted_value|escape == 'foo bar'
+ - vaulted_value|forceescape == 'foo bar'
+ - vaulted_value|first == 'f'
+ - "'%s'|format(vaulted_value) == 'foo bar'"
+ - vaulted_value|indent(first=True) == ' foo bar'
+ - vaulted_value.split() == ['foo', 'bar']
+ - vaulted_value|join('-') == 'f-o-o- -b-a-r'
+ - vaulted_value|last == 'r'
+ - vaulted_value|length == 7
+ - vaulted_value|list == ['f', 'o', 'o', ' ', 'b', 'a', 'r']
+ - vaulted_value|lower == 'foo bar'
+ - vaulted_value|replace('foo', 'baz') == 'baz bar'
+ - vaulted_value|reverse|string == 'rab oof'
+ - vaulted_value|safe == 'foo bar'
+ - vaulted_value|slice(2)|list == [['f', 'o', 'o', ' '], ['b', 'a', 'r']]
+ - vaulted_value|sort|list == [" ", "a", "b", "f", "o", "o", "r"]
+ - vaulted_value|trim == 'foo bar'
+ - vaulted_value|upper == 'FOO BAR'
+ # jinja2.filters.do_urlencode uses an isinstance against string_types
+ # - vaulted_value|urlencode == 'foo%20bar'
+ - vaulted_value|urlize == 'foo bar'
+ - vaulted_value is not callable
+ - vaulted_value is iterable
+ - vaulted_value is lower
+ - vaulted_value is not none
+ # This is not exactly a string, and UserString doesn't fulfill this
+ # - vaulted_value is string
+ - vaulted_value is not upper
+
+ - vaulted_value|b64encode == 'Zm9vIGJhcg=='
+ - vaulted_value|to_uuid == '0271fe51-bb26-560f-b118-5d6513850860'
+ - vaulted_value|string|to_json == '"foo bar"'
+ - vaulted_value|md5 == '327b6f07435811239bc47e1544353273'
+ - vaulted_value|sha1 == '3773dea65156909838fa6c22825cafe090ff8030'
+ - vaulted_value|hash == '3773dea65156909838fa6c22825cafe090ff8030'
+ - vaulted_value|regex_replace('foo', 'baz') == 'baz bar'
+ - vaulted_value|regex_escape == 'foo\ bar'
+ - vaulted_value|regex_search('foo') == 'foo'
+ - vaulted_value|regex_findall('foo') == ['foo']
+ - vaulted_value|comment == '#\n# foo bar\n#'
+
+ - assert:
+ that:
+ - vaulted_value|random(seed='foo') == ' '
+ - vaulted_value|shuffle(seed='foo') == ["o", "f", "r", "b", "o", "a", " "]
+ - vaulted_value|pprint == "'foo bar'"
+ when: ansible_python.version.major == 3
+
+ - assert:
+ that:
+ - vaulted_value|random(seed='foo') == 'r'
+ - vaulted_value|shuffle(seed='foo') == ["b", "o", "a", " ", "o", "f", "r"]
+ - vaulted_value|pprint == "u'foo bar'"
+ when: ansible_python.version.major == 2
+
+ - assert:
+ that:
+ - vaulted_value|map('upper')|list == ['F', 'O', 'O', ' ', 'B', 'A', 'R']
+
+ - assert:
+ that:
+ - vaulted_value.split()|first|int(base=36) == 20328
+ - vaulted_value|select('equalto', 'o')|list == ['o', 'o']
+ - vaulted_value|title == 'Foo Bar'
+ - vaulted_value is equalto('foo bar')
+
+ - assert:
+ that:
+ - vaulted_value|string|tojson == '"foo bar"'
+ - vaulted_value|truncate(4) == 'foo bar'
+
+ - assert:
+ that:
+ - vaulted_value|wordwrap(4) == 'foo\nbar'
+
+ - assert:
+ that:
+ - vaulted_value|wordcount == 2
+
+ - ping:
+ data: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 35323961353038346165643738646465376139363061353835303739663538343266303232326635
+ 3365353662646236356665323135633630656238316530640a663362363763633436373439663031
+ 33663433383037396438656464636433653837376361313638366362333037323961316364363363
+ 3835616438623261650a636164376534376661393134326662326362323131373964313961623365
+ 3833
+ register: ping_result
+
+ - assert:
+ that:
+ - ping_result.ping == 'foo bar'
diff --git a/test/integration/targets/ansible-vault/symlink.yml b/test/integration/targets/ansible-vault/symlink.yml
new file mode 100644
index 0000000..2dcf8a9
--- /dev/null
+++ b/test/integration/targets/ansible-vault/symlink.yml
@@ -0,0 +1,10 @@
+- hosts: localhost
+ gather_facts: false
+ vars_files:
+ - vaulted.yml
+ tasks:
+ - name: see if we can decrypt
+ assert:
+ that:
+ - control is defined
+ - symlink == 'this is a test'
diff --git a/test/integration/targets/ansible-vault/symlink/get-password-symlink b/test/integration/targets/ansible-vault/symlink/get-password-symlink
new file mode 100755
index 0000000..3aa1c2e
--- /dev/null
+++ b/test/integration/targets/ansible-vault/symlink/get-password-symlink
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+set -eu
+
+# shellcheck disable=SC2086
+basename="$(basename $0)"
+# shellcheck disable=SC2046
+# shellcheck disable=SC2086
+dirname="$(basename $(dirname $0))"
+basename_prefix="get-password"
+default_password="foo-bar"
+
+case "${basename}" in
+ "${basename_prefix}"-*)
+ password="${default_password}-${basename#${basename_prefix}-}"
+ ;;
+ *)
+ password="${default_password}"
+ ;;
+esac
+
+# the password is different depending on the path used (direct or symlink)
+# it would be the same if symlink is 'resolved'.
+echo "${password}_${dirname}"
diff --git a/test/integration/targets/ansible-vault/test-vault-client.py b/test/integration/targets/ansible-vault/test-vault-client.py
new file mode 100755
index 0000000..ee46188
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test-vault-client.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+ANSIBLE_METADATA = {'status': ['preview'],
+ 'supported_by': 'community',
+ 'version': '1.0'}
+
+import argparse
+import sys
+
+# TODO: could read these from the files I suppose...
+secrets = {'vault-password': 'test-vault-password',
+ 'vault-password-wrong': 'hunter42',
+ 'vault-password-ansible': 'ansible',
+ 'password': 'password',
+ 'vault-client-password-1': 'password-1',
+ 'vault-client-password-2': 'password-2'}
+
+
+def build_arg_parser():
+ parser = argparse.ArgumentParser(description='Get a vault password from user keyring')
+
+ parser.add_argument('--vault-id', action='store', default=None,
+ dest='vault_id',
+ help='name of the vault secret to get from keyring')
+ parser.add_argument('--username', action='store', default=None,
+ help='the username whose keyring is queried')
+ parser.add_argument('--set', action='store_true', default=False,
+ dest='set_password',
+ help='set the password instead of getting it')
+ return parser
+
+
+def get_secret(keyname):
+ return secrets.get(keyname, None)
+
+
+def main():
+ rc = 0
+
+ arg_parser = build_arg_parser()
+ args = arg_parser.parse_args()
+ # print('args: %s' % args)
+
+ keyname = args.vault_id or 'ansible'
+
+ if args.set_password:
+ print('--set is not supported yet')
+ sys.exit(1)
+
+ secret = get_secret(keyname)
+ if secret is None:
+ sys.stderr.write('test-vault-client could not find key for vault-id="%s"\n' % keyname)
+ # key not found rc=2
+ return 2
+
+ sys.stdout.write('%s\n' % secret)
+
+ return rc
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/test/integration/targets/ansible-vault/test_dangling_temp.yml b/test/integration/targets/ansible-vault/test_dangling_temp.yml
new file mode 100644
index 0000000..71a9d73
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_dangling_temp.yml
@@ -0,0 +1,34 @@
+- hosts: localhost
+ gather_facts: False
+ vars:
+ od: "{{output_dir|default('/tmp')}}/test_vault_assemble"
+ tasks:
+ - name: create target directory
+ file:
+ path: "{{od}}"
+ state: directory
+
+ - name: assemble_file file with secret
+ assemble:
+ src: files/test_assemble
+ dest: "{{od}}/dest_file"
+ remote_src: no
+ mode: 0600
+
+ - name: remove assembled file with secret (so nothing should have unencrypted secret)
+ file: path="{{od}}/dest_file" state=absent
+
+ - name: find temp files with secrets
+ find:
+ paths: '{{temp_paths}}'
+ contains: 'VAULT TEST IN WHICH BAD THING HAPPENED'
+ recurse: yes
+ register: badthings
+ vars:
+ temp_paths: "{{[lookup('env', 'TMP'), lookup('env', 'TEMP'), hardcoded]|flatten(1)|unique|list}}"
+ hardcoded: ['/tmp', '/var/tmp']
+
+ - name: ensure we failed to find any
+ assert:
+ that:
+ - badthings['matched'] == 0
diff --git a/test/integration/targets/ansible-vault/test_utf8_value_in_filename.yml b/test/integration/targets/ansible-vault/test_utf8_value_in_filename.yml
new file mode 100644
index 0000000..9bd394d
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_utf8_value_in_filename.yml
@@ -0,0 +1,16 @@
+- name: "Test that the vaulted file with UTF-8 in filename decrypts correctly"
+ gather_facts: false
+ hosts: testhost
+ vars:
+ expected: "my_secret"
+ vars_files:
+ - vault-café.yml
+ tasks:
+ - name: decrypt vaulted file with utf8 in filename and show it in debug
+ debug:
+ var: vault_string
+
+ - name: assert decrypted value matches expected
+ assert:
+ that:
+ - "vault_string == expected"
diff --git a/test/integration/targets/ansible-vault/test_vault.yml b/test/integration/targets/ansible-vault/test_vault.yml
new file mode 100644
index 0000000..7f8ed11
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vault.yml
@@ -0,0 +1,6 @@
+- hosts: testhost
+ gather_facts: False
+ vars:
+ - output_dir: .
+ roles:
+ - { role: test_vault, tags: test_vault}
diff --git a/test/integration/targets/ansible-vault/test_vault_embedded.yml b/test/integration/targets/ansible-vault/test_vault_embedded.yml
new file mode 100644
index 0000000..ee9739f
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vault_embedded.yml
@@ -0,0 +1,4 @@
+- hosts: testhost
+ gather_facts: False
+ roles:
+ - { role: test_vault_embedded, tags: test_vault_embedded}
diff --git a/test/integration/targets/ansible-vault/test_vault_embedded_ids.yml b/test/integration/targets/ansible-vault/test_vault_embedded_ids.yml
new file mode 100644
index 0000000..23ebbb9
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vault_embedded_ids.yml
@@ -0,0 +1,4 @@
+- hosts: testhost
+ gather_facts: False
+ roles:
+ - { role: test_vault_embedded_ids, tags: test_vault_embedded_ids}
diff --git a/test/integration/targets/ansible-vault/test_vault_file_encrypted_embedded.yml b/test/integration/targets/ansible-vault/test_vault_file_encrypted_embedded.yml
new file mode 100644
index 0000000..685d20e
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vault_file_encrypted_embedded.yml
@@ -0,0 +1,4 @@
+- hosts: testhost
+ gather_facts: False
+ roles:
+ - { role: test_vault_file_encrypted_embedded, tags: test_vault_file_encrypted_embedded}
diff --git a/test/integration/targets/ansible-vault/test_vaulted_inventory.yml b/test/integration/targets/ansible-vault/test_vaulted_inventory.yml
new file mode 100644
index 0000000..06b6582
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vaulted_inventory.yml
@@ -0,0 +1,5 @@
+- hosts: vaulted_host
+ gather_facts: no
+ tasks:
+ - name: See if we knew vaulted_host
+ debug: msg="Found vaulted_host from vaulted.inventory"
diff --git a/test/integration/targets/ansible-vault/test_vaulted_inventory_toml.yml b/test/integration/targets/ansible-vault/test_vaulted_inventory_toml.yml
new file mode 100644
index 0000000..f6e2c5d
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vaulted_inventory_toml.yml
@@ -0,0 +1,9 @@
+- hosts: vaulted_host_toml
+ gather_facts: no
+ tasks:
+ - name: See if we knew vaulted_host_toml
+ debug: msg="Found vaulted_host from vaulted.inventory.toml"
+
+ - assert:
+ that:
+ - 'hello=="world"'
diff --git a/test/integration/targets/ansible-vault/test_vaulted_template.yml b/test/integration/targets/ansible-vault/test_vaulted_template.yml
new file mode 100644
index 0000000..b495211
--- /dev/null
+++ b/test/integration/targets/ansible-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}
diff --git a/test/integration/targets/ansible-vault/test_vaulted_utf8_value.yml b/test/integration/targets/ansible-vault/test_vaulted_utf8_value.yml
new file mode 100644
index 0000000..63b602b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/test_vaulted_utf8_value.yml
@@ -0,0 +1,15 @@
+- name: "test that the vaulted_utf8_value decrypts correctly"
+ gather_facts: false
+ hosts: testhost
+ vars:
+ expected: "aöffü"
+ tasks:
+ - name: decrypt vaulted_utf8_value and show it in debug
+ debug:
+ var: vaulted_utf8_value
+
+ - name: assert decrypted vaulted_utf8_value matches expected
+ assert:
+ that:
+ - "vaulted_utf8_value == expected"
+ - "vaulted_utf8_value == 'aöffü'"
diff --git a/test/integration/targets/ansible-vault/vars/vaulted.yml b/test/integration/targets/ansible-vault/vars/vaulted.yml
new file mode 100644
index 0000000..40f5c54
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vars/vaulted.yml
@@ -0,0 +1,15 @@
+control: 1
+realpath: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 64343436666664636436363065356463363630653766323230333931366661656262343030386366
+ 6536616433353864616132303033623835316430623762360a646234383932656637623439353333
+ 36336362616564333663353739313766363333376461353962643531366338633336613565636636
+ 3663663664653538620a646132623835666336393333623439363361313934666530646334333765
+ 39386364646262396234616666666438313233626336376330366539663765373566
+symlink: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 61656138353366306464386332353938623338336333303831353164633834353437643635343635
+ 3461646235303261613766383437623664323032623137350a663934653735316334363832383534
+ 33623733346164376430643535616433383331663238383363316634353339326235663461353166
+ 3064663735353766660a653963373432383432373365633239313033646466653664346236363635
+ 6637
diff --git a/test/integration/targets/ansible-vault/vault-café.yml b/test/integration/targets/ansible-vault/vault-café.yml
new file mode 100644
index 0000000..0d179ae
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vault-café.yml
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+63363732353363646661643038636339343263303161346533393636336562336465396265373834
+6366313833613236356666646532613636303532366231340a316238666435306332656662613731
+31623433613434633539333564613564656439343661363831336364376266653462366161383038
+6530386533363933350a336631653833666663643166303932653261323431623333356539666265
+37316464303231366163333430346537353631376538393939646362313337363866
diff --git a/test/integration/targets/ansible-vault/vault-password b/test/integration/targets/ansible-vault/vault-password
new file mode 100644
index 0000000..9697392
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vault-password
@@ -0,0 +1 @@
+test-vault-password
diff --git a/test/integration/targets/ansible-vault/vault-password-ansible b/test/integration/targets/ansible-vault/vault-password-ansible
new file mode 100644
index 0000000..90d4055
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vault-password-ansible
@@ -0,0 +1 @@
+ansible
diff --git a/test/integration/targets/ansible-vault/vault-password-wrong b/test/integration/targets/ansible-vault/vault-password-wrong
new file mode 100644
index 0000000..50e2efa
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vault-password-wrong
@@ -0,0 +1 @@
+hunter42
diff --git a/test/integration/targets/ansible-vault/vault-secret.txt b/test/integration/targets/ansible-vault/vault-secret.txt
new file mode 100644
index 0000000..b6bc9bf
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vault-secret.txt
@@ -0,0 +1,6 @@
+$ANSIBLE_VAULT;1.1;AES256
+39303432393062643236616234306333383838333662386165616633303735336537613337396337
+6662666233356462326631653161663663363166323338320a653131656636666339633863346530
+32326238646631653133643936306666643065393038386234343736663239363665613963343661
+3230353633643361650a363034323631613864326438396665343237383566336339323837326464
+3930
diff --git a/test/integration/targets/ansible-vault/vaulted.inventory b/test/integration/targets/ansible-vault/vaulted.inventory
new file mode 100644
index 0000000..1ed258b
--- /dev/null
+++ b/test/integration/targets/ansible-vault/vaulted.inventory
@@ -0,0 +1,8 @@
+$ANSIBLE_VAULT;1.1;AES256
+62663838646564656432633932396339666332653932656230356332316530613665336461653731
+3839393466623734663861313636356530396434376462320a623966363661306334333639356263
+37366332626434326537353562636139333835613961333635633333313832666432396361393861
+3538626339636634360a396239383139646438323662383637663138646439306532613732306263
+64666237366334663931363462313131323861613237613337366562373532373537613531636334
+64653938333938313539653539303031393936306432623862363263663438653932643338373338
+633436626431656361633934363263303962