Open hungtran84 opened 2 years ago
Files identified in the description:
lib/ansible/plugins/lookup
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
!component =plugins/lookup/hiera.py
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @jparrill click here for bot help
If your hiera
binary is located somewhere else, you should point the environment variable ANSIBLE_HIERA_BIN
to the correct position (see the plugin's documentation).
@felixfontein yes, I already set those environment variable in my sample playbook above but somehow, lookup plugins doesn't pick that up.
tasks:
- name: retrieve password from puppet
become: true
run_once: true
environment:
ANSIBLE_HIERA_BIN: '/opt/puppetlabs/bin/hiera'
ANSIBLE_HIERA_CFG: '/etc/puppetlabs/code/environments/production/hiera.yaml'
debug:
msg: "{{ lookup('community.general.hiera', 'foo') }}"
AFAIK environment:
affects only modules, but not other plugins (like lookups). You have to set a proper environment variable before calling ansible-playbook
. Especially when looking at the code of this lookup, the way it is written it picks up the environment variables on load time. I guess it should be adjusted to the Ansible config system; then it's also easy to add support for other ways of configuring it (for example by Ansible variables).
Summary
I tried to lookup for my value in puppet master with the sample playbook as below
And get this error
Issue Type
Bug Report
Component Name
hiera lookup
Ansible Version
Community.general Version
Configuration
OS / Environment
Centos 7
Steps to Reproduce
Expected Results
I expected to get the value of the key
Actual Results
Code of Conduct