All articles

Managing Secrets in Ansible using passbolt

7 min. read

Jean-Christophe Vassort

Jean-Christophe Vassort

7 April, 2022

Managing secrets in Ansible

Using Ansible Vault

$ ansible-vault encrypt
New Vault password: ****
Confirm New Vault password: ****
Reading plaintext input from stdin
password
Encryption successful
$ANSIBLE_VAULT;1.1;AES256
353030646433386461373032366165…1646330333236663632656338373231636631
$ ansible-vault decrypt
Vault password: ****
Reading ciphertext input from stdin
$ANSIBLE_VAULT;1.1;AES256
353030646433386461373032366165…1646330333236663632656338373231636631
Decryption successful
password

Using Ansible lookup plugins

- name: Create RDS instance with aws_secret lookup for password param  rds:
    command: create
    instance_name: app-db
    db_engine: MySQL
    size: 10
    instance_type: db.m1.small
    username: dbadmin
    password: "{{ lookup('amazon.aws.aws_secret', 'DbSecret') }}"

Managing Ansible secrets using passbolt

What are the benefits of using passbolt?

Security considerations

Passbolt ansible lookup plugin usage

Setup

$ ansible-galaxy collection install anatomicjc.passbolt
$ python -m pip install py-passbolt

Authentication

environment:
  PASSBOLT_BASE_URL: "https://passbolt.domain"
  PASSBOLT_PRIVATE_KEY: "{{ private_key_vault }}"
  PASSBOLT_PASSPHRASE: "{{ passphrase_vault }}"
environment:
  PASSBOLT_BASE_URL: "https://passbolt.domain"
  PASSBOLT_GPG_LIBRARY: "gnupg"
  PASSBOLT_FINGERPRINT: "1321159AE7BEE9EF9C4BBC7ECBAD2FB0C22FE70C"

How to use passbolt lookup plugin

We will use below a passbolt variable for convenience. The full plugin name to be used is ‘anatomicjc.passbolt.passbolt’ .
You can have a look at our ansible playbook example.
lookup(passbolt, 'OVH')
lookup(passbolt, 'OVH', username='[email protected]')
lookup(passbolt, 'OVH', username='[email protected]', uri='https://api.ovh.com')
lookup(passbolt, 'a294b8d6–5dae-4db6–9e49-f790781cec30', per_uuid='true')
vars:
  aws:
    access_key: "{{ lookup(passbolt, 'AWS').password }}"
    secret_key: "{{ lookup(passbolt, 'AWS').description }}"
- name: Generate AWS credentials profile
  ansible.builtin.copy:
    dest: ${HOME}/.aws/credentials
    owner: "{{ lookup('env', 'USER') }}"
    mode: "0600"
    content: |
      [default]
      aws_access_key_id={{ aws.access_key }}
      aws_secret_access_key={{ aws.secret_key }}

Full example Ansible playground

git clone [email protected]:passbolt/lab-passbolt-ansible-poc.git
cd lab-passbolt-ansible-poc
docker-compose up -d
docker-compose run ansible
ansible-playbook playbooks/example-playbook.yml

Resources to go further

Conclusion

Continue reading

5 browser extensions to protect your privacy online.

3 min. read

5 browser extensions to protect your privacy online.

We could also have devised a list of all the things we hate about click bait articles, but the number 3 would have been too shocking for…

Vivien Muller

Vivien Muller

12 April, 2022

How to configure Passbolt with Postgresql (experimental)

7 min. read

How to configure Passbolt with Postgresql (experimental)

Since the latest v3.5.0 passbolt version, it is possible to use PostgreSQL as a database backend (experimental) for passbolt. Let’s see how…

Jean-Christophe Vassort

Jean-Christophe Vassort

28 February, 2022

Flag of European UnionMade in Europe. Privacy by default.