Search code examples
amazon-web-servicesansiblecredentialsaws-secrets-manager

Using aws_secret in ansible


I'm trying to retrieve password from aws secret manager using ansible 2.8 using lookup.

Below things are not working for me:

  1. In .bashrc, I have exported region
  2. Ansible Environment Variables in task
  3. Setting up ansible variables in pre_tasks
- hosts: StagingApps
  remote_user: staging
  gather_facts: false

  tasks:
  - debug:
      var: "{{ lookup('aws_secret', 'staging_mongodb_pass', region='us-east-1') }}"
      msg: "{{ query('aws_secret', 'staging_mongodb_pass', region='us-east-1') }}"
      environment:
        region: 'us-east-1'

Error Message:

FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'aws_secret'. Error was a , original message: 'Requested entry (plugin_type: lookup plugin: aws_secret setting: region ) was not defined in configuration.'"}


Solution

  • It looks like Ansible released this lookup plugin in a broken state. They have an issue and a PR open to fix it:

    Very disappointing, as I've been waiting for this plugin for many months.