jhaals / ansible-vault

ansible lookup plugin for secrets stored in Vault(by HashiCorp)
BSD 3-Clause "New" or "Revised" License
347 stars 65 forks source link

Support quoted params & only split params on first '='. #49

Closed ajrgrubbs closed 7 years ago

ajrgrubbs commented 7 years ago

This allows users to submit values with whitespace. Fixes #48.

Noticed while I was making this that param values with = chars would silently lose everything after that character, so I added it in as well.

Used the following playbook as a test case - not too familiar with ansible plugin development, please advise if there's a better method.

---
- hosts: localhost

  tasks:
    # This task writes the value fine, but must ignore_errors since nothing is returned
    - name: Create test value
      debug:
        msg: "{{ lookup('vault', 'secret/dev/vaulttest hello=world whitespace=\"one two\tthree\nfour\rfive\r\nsix\" equals=two+two=four') }}"
      ignore_errors: yes

    - name: Read test value into dict
      set_fact:
        my_result: "{{ lookup('vault', 'secret/dev/vaulttest') }}"

    - name: Show it
      debug:
        var: my_result
jhaals commented 7 years ago

👍