Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for getting status #21

Open
jmgilman opened this issue Nov 4, 2021 · 0 comments
Open

Add support for getting status #21

jmgilman opened this issue Nov 4, 2021 · 0 comments

Comments

@jmgilman
Copy link

jmgilman commented Nov 4, 2021

The way the module currently handles a locked vault is by throwing an error. There doesn't appear to be a way to check beforehand if vault data can be accessed - this makes conditional access difficult. My current workaround is a bit tedious:

- block:
    - set_fact:
        status: "{{ lookup('bitwarden') }}"
        unlocked: true
  rescue:
    - set_fact:
        unlocked: false
- block:
    - set_fact:
        home: "{{ lookup('env','HOME') }}"
        key: "{{ lookup('bitwarden', item, field='item') }}"
    - name: SSH directory exists
      ansible.builtin.file:
        path: "{{ home }}/.ssh"
        state: directory
        mode: 0700
    - debug:
        msg: "{{ lookup('bitwarden', item,  itemid=key.id, attachments=true, output=home+'/.ssh/'+item ) }}"
    - debug:
        msg: "{{ lookup('bitwarden', item+'.pub',  itemid=key.id, attachments=true, output=home+'/.ssh/'+item+'.pub' ) }}"
  when: unlocked

Basically, I use blocks to catch the error thrown when the vault is locked and set unlocked accordingly to conditionally run steps that require the vault to be unlocked. It would be nice to have a dedicated lookup parameter to fetch vault status to avoid resorting to this hacky approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant