How do I pass the token to Consul?
This doesn’t appear to work, I’m not getting the value. However, if i set Consul to allow anonymous queries, it works fine.
{{ lookup(‘consul_kv’,item,“token=mysecretoken”) }}
How do I pass the token to Consul?
This doesn’t appear to work, I’m not getting the value. However, if i set Consul to allow anonymous queries, it works fine.
{{ lookup(‘consul_kv’,item,“token=mysecretoken”) }}
The lookup currently does not seem to support auth, but it should not
be hard to modify to do so.
Well according to this file (is this the right one?) I see paramters for token.
/usr/lib/python2.7/site-packages/ansible/runner/lookup_plugins/consul_kv.py
results = consul_api.kv.get(params[‘key’],
token=params[‘token’],
index=params[‘index’],
recurse=params[‘recurse’])
ah, yes, i missed that, i was looking at the env variables
self.agent_url = 'http://localhost:8500'
if os.getenv('ANSIBLE_CONSUL_URL') is not None:
self.agent_url = os.environ['ANSIBLE_CONSUL_URL']
do you get any errors when trying to use the token?
I think the problem is in that the entire kwarg is quoted in your example:
{{ lookup(‘consul_kv’,item,“token=mysecretoken”) }}
It should probably be:
{{ lookup(‘consul_kv’, item, token=“mysecretoken”) }}
Just quote the value, not the arg name.
I’ve tried that as well. I don’t think it works because I used the following and it did not throw an error. Notice, I used “token123” and it didn’t error out at all.
{{ lookup(‘consul_kv’, item, token123=“mysecretoken”) }}