jhaals / ansible-vault

ansible lookup plugin for secrets stored in Vault(by HashiCorp)
BSD 3-Clause "New" or "Revised" License
347 stars 65 forks source link

Integration with molecule test 'object has no attribute 'code' #72

Closed snoby closed 6 years ago

snoby commented 6 years ago

Hi, I'm certain that I'm doing something wrong... I'm using Molecule V2 to run on one of my roles inside my playbook. This particular role calls into vault to obtain a value. My issue is that I'm getting a cryptic python error and I'm stuck on where to debug the issue.
In molecule you can create a config file where you can customize certain configs such as a mock up ansible.cfg for example my molecule.yml file looks like this:

---
dependency:
  name: galaxy
driver:
  name: docker
lint:
  name: yamllint
platforms:
  - name: instance
    image: centos:7
provisioner:
  name: ansible
  config_options:
    defaults:
      lookup_plugins : ../../../../../lookup_plugins
  lint:
    name: ansible-lint
scenario:
  name: default
verifier:
  name: testinfra
  lint:
    name: flake8

Now if I do not set the lookup_plugin line above then I get an error that the playbook can't find vault... so I know ansible is able to find the plugin, however I'm getting this error when I run the converge command which is equivalent to running the playbook on just this role:

  TASK [common : Obtain from vault the private ssh key for user ansible] *********
    task path: /Users/snoby/work/Official/tropo-ops-proxy-ansible/roles/common/tasks/main.yml:36
    fatal: [instance]: FAILED! => {
        "msg": "An unhandled exception occurred while running the lookup plugin 'vault'. Error was a <type 'exceptions.AttributeError'>, original message: 'exceptions.AttributeError' object has no attribute 'code'"
    }

It seems like something can't dereference in the path where the code is for the plugin. Any suggestions?

snoby commented 6 years ago

One additional factoid which may simplify the test here as well. I tried to just run the whole playbook with the vault lookup plugin and I was returned with the same result of:

TASK [common : Obtain from vault the private ssh key for user ansible] *********************************************************************
fatal: [proxy1b.int.tropo.com]: FAILED! => {"msg": "An unhandled exception occurred while running the lookup plugin 'vault'. Error was a <type 'exceptions.AttributeError'>, original message: 'exceptions.AttributeError' object has no attribute 'code'"}

PLAY RECAP *********************************************************************************************************************************

So this has nothing to do with molecule. I install the plugin by making it a git submodule.

snoby commented 6 years ago

decided to go with hashivault as it works right out of the box...