/ README.md
README.md
  1  # ansible-modules-bitwarden
  2  
  3  Bitwarden integration for Ansible.
  4  
  5  ## Installation
  6  
  7  The easiest way to install this lookup plugin is to use the
  8  `ansible-galaxy` command:
  9  
 10      ansible-galaxy install git+https://github.com/c0sco/ansible-modules-bitwarden
 11  
 12  This will place the `ansible-modules-bitwarden` role into
 13  `$HOME/.ansible/roles`, where it will be available to all playbooks
 14  you run on your system.
 15  
 16  ## Lookup plugin
 17  
 18  To use this plugin, you will need to activate it by including the role
 19  in your play.  For example:
 20  
 21      - hosts: localhost
 22        roles:
 23          - ansible-modules-bitwarden
 24  
 25  Use Ansible's `lookup()` function with the `bitwarden` argument,
 26  followed by the items you want to retrieve. The default field is
 27  `password`, but any other field can be specified using the `field`
 28  named argument. If you need to specify the path to the Bitwarden CLI
 29  binary, use the `path` named argument.
 30  
 31  ## Examples
 32  
 33  ### Get a single password
 34  
 35  ```yaml
 36  # Get password for Google
 37  - debug:
 38      msg: {{ lookup('bitwarden', 'Google') }}
 39  ```
 40  
 41  The above might result in:
 42  
 43  ```
 44  TASK [debug] *********************************************************
 45  ok: [localhost] => {
 46      "msg": "mysecret"
 47      }
 48  ```
 49  
 50  ### Get a single username
 51  
 52  ```yaml
 53  # Get username for Google
 54  - debug:
 55      msg: {{ lookup('bitwarden', 'Google', field='username') }}
 56  ```
 57  
 58  The above might result in:
 59  
 60  ```
 61  TASK [debug] *********************************************************
 62  ok: [localhost] => {
 63      "msg": "alice"
 64      }
 65  ```
 66  
 67  ### See all available fields
 68  
 69  ```yaml
 70  # Get all available fields for an entry
 71  - debug:
 72      msg: {{ lookup('bitwarden', 'Google', field='item') }}
 73  ```
 74  
 75  The above might result in:
 76  
 77  ```
 78  TASK [debug] *********************************************************
 79  ok: [localhost] => {
 80      "msg": {
 81          "favorite": false,
 82          "fields": [
 83              {
 84                  "name": "mycustomfield",
 85                  "type": 0,
 86                  "value": "the value of my custom field"
 87              }
 88          ],
 89          "folderId": null,
 90          "id": "12345678-0123-4321-0000-a97001342c31",
 91          "login": {
 92              "password": "mysecret",
 93              "passwordRevisionDate": null,
 94              "totp": null,
 95              "username": "alice"
 96          },
 97          "name": "Google",
 98          "notes": null,
 99          "object": "item",
100          "organizationId": "87654321-1234-9876-0000-a96800ed2b47",
101          "revisionDate": "2018-10-19T19:20:17.923Z",
102          "type": 1
103      }
104  }
105  ```
106  
107  ### Get the value of a custom field
108  
109  ```yaml
110  # Get the value of a custom field
111  - debug:
112      msg: {{ lookup('bitwarden', 'Google', field='mycustomfield', custom_field=true) }}
113  ```
114  
115  The above might result in:
116  
117  ```
118  TASK [debug] *********************************************************
119  ok: [localhost] => {
120      "msg": "the value of my custom field"
121      }
122  ```
123  
124  ### download attachments files
125  
126  ```yaml
127  # Get the value of a custom field
128  - debug:
129      msg: {{ lookup('bitwarden', 'privateKey.pem',  itemid='123456-1234-1234-abbf-60c345aaa3e', attachments=true ) }}
130  ```
131  Optional parameters - output='/ansible/publicKey.pem'
132  
133  The above might result in:
134  
135  ```
136  TASK [debug] *********************************************************
137  ok: [localhost] => {
138      "msg": "Saved /publicKey.pem"
139      }
140  ```