Skip to content

Commit

Permalink
do not convert to string on lookup plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
TerryHowe committed Jun 7, 2017
1 parent 596b0a0 commit 170b41f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ansible/plugins/lookup/hashivault.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run(self, terms, variables, **kwargs):

if 'value' not in result:
raise AnsibleError('Error reading vault %s/%s: %s\n%s' % (path, key, result.get('msg', 'msg not set'), result.get('stack_trace', '')))
return [str(result['value'])]
return [result['value']]


def main(argv=sys.argv[1:]):
Expand Down
1 change: 1 addition & 0 deletions functional/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ ansible-playbook -v test_policy.yml
ansible-playbook -v test_status.yml
ansible-playbook -v test_userpass.yml
ansible-playbook -v test_secret.yml
ansible-playbook -v test_complex.yml
# do last
ansible-playbook -v test_unseal.yml
27 changes: 27 additions & 0 deletions functional/test_complex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- hosts: localhost
tasks:
- hashivault_write:
secret: 'array'
data:
value:
- 'one'
- 'two'
- 'three'

- set_fact:
expected_value:
- 'one'
- 'two'
- 'three'
- hashivault_read:
secret: 'array'
key: 'value'
register: 'vault_read'
- assert: { that: "'{{vault_read.value[0]}}' == '{{expected_value[0]}}'" }
- assert: { that: "'{{vault_read.value[1]}}' == '{{expected_value[1]}}'" }
- assert: { that: "'{{vault_read.value[2]}}' == '{{expected_value[2]}}'" }

- set_fact:
looky_secret: "{{lookup('hashivault', 'array', 'value') | first}}"
- assert: { that: "'{{looky_secret}}' == 'one'" }

0 comments on commit 170b41f

Please sign in to comment.