community.general.bitwarden (8.5.0) — lookup

Retrieve secrets from Bitwarden

| "added in version" 5.4.0 of community.general"

Authors: Jonathan Lung (@lungj) <lungj@heresjono.com>

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Retrieve secrets from Bitwarden.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get 'password' from all Bitwarden records named 'a_test'"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', 'a_test', field='password') }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get 'password' from Bitwarden record with ID 'bafba515-af11-47e6-abe3-af1200cd18b2'"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', 'bafba515-af11-47e6-abe3-af1200cd18b2', search='id', field='password') | first }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get 'password' from all Bitwarden records named 'a_test' from collection"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', 'a_test', field='password', collection_id='bafba515-af11-47e6-abe3-af1200cd18b2') }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get list of all full Bitwarden records named 'a_test'"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', 'a_test') }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get custom field 'api_key' from all Bitwarden records named 'a_test'"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', 'a_test', field='api_key') }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get 'password' from all Bitwarden records named 'a_test', using given session key"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', 'a_test', field='password', bw_session='bXZ9B5TXi6...') }}
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Get all Bitwarden records from collection"
  ansible.builtin.debug:
    msg: >-
      {{ lookup('community.general.bitwarden', None, collection_id='bafba515-af11-47e6-abe3-af1200cd18b2') }}

Inputs

    
field:
    description: Field to fetch. Leave unset to fetch whole response.
    type: str

_terms:
    description: Key(s) to fetch values for from login info.
    elements: str
    required: true
    type: list

search:
    default: name
    description:
    - Field to retrieve, for example V(name) or V(id).
    - If set to V(id), only zero or one element can be returned. Use the Jinja C(first)
      filter to get the only list element.
    - When O(collection_id) is set, this field can be undefined to retrieve the whole
      collection records.
    type: str
    version_added: 5.7.0
    version_added_collection: community.general

bw_session:
    description: Pass session key instead of reading from env.
    type: str
    version_added: 8.4.0
    version_added_collection: community.general

collection_id:
    description: Collection ID to filter results by collection. Leave unset to skip filtering.
    type: str
    version_added: 6.3.0
    version_added_collection: community.general

Outputs

_raw:
  description:
  - A one-element list that contains a list of requested fields or JSON objects of
    matches.
  - If you use C(query), you get a list of lists. If you use C(lookup) without C(wantlist=true),
    this always gets reduced to a list of field values or JSON objects.
  elements: list
  type: list