How can I run a command before the playbook when using ansible ee?

26 Views Asked by At

I am trying to use community.general.bitwarden within an Ansible Execution Environment. To do this, I need to run the following command within the EE before starting the playbook.

export BW_SESSION=$(bw login <mail> --raw --passwordenv BW_PASSWORD)

I tried running it by configuring ansible-navigator.yml as follows:

ansible-navigator:
  exec:
    command: "export BW_SESSION=$(bw login <mail> --raw --passwordenv BW_PASSWORD)"
  execution-environment:
    container-engine: docker
    image: <image>:latest
    environment-variables:
      pass:
        - BW_PASSWORD

But when I run my playbook which among others includes this lookup

password: "{{ lookup('community.general.bitwarden', <title>, field='password') }}"

I get the following error:

Bitwarden Vault locked. Run 'bw unlock'.

My understanding of exec: command was that it would run this command before executing the playbook. But that does not seem to happen. I don't even see any error message about the login being incorrect if I don't set the BW_PASSWORD variable.

How can I configure ansible-navigator or my ansible ee to unlock the vault before running the playbook?

0

There are 0 best solutions below