with_inventory_hostnames and Ansible Vault

I am trying to use the with_inventory_hostnames lookup plugin, but it keeps failing with the folllowing error: “A vault password must be specified to decrypt /opt/ansible/group_vars/secure_vault”

A workaround was to modify the LookupModule to provide the vault_password to the inventory. Is this the correct approach?

`

class LookupModule(object):

def init(self, basedir=None, **kwargs):
self.basedir = basedir
if ‘runner’ in kwargs:
self.host_list = kwargs[‘runner’].inventory.host_list
self.vault_pass = kwargs[‘runner’].vault_pass
else:
raise errors.AnsibleError(“inventory_hostnames must be used as a loop. Example: "with_inventory_hostnames: 'all'"”)

def run(self, terms, inject=None, **kwargs):
terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject)

if not isinstance(terms, list):
raise errors.AnsibleError(“with_inventory_hostnames expects a list”)
return flatten(inventory.Inventory(self.host_list, vault_password=self.vault_pass).list_hosts(terms))

`

I think you would have a better shot at an answer if you’d ask here: https://groups.google.com/forum/#!forum/ansible-devel