# consul\_kv usage

**URL:** <https://forum.ansible.com/t/consul-kv-usage/18308>\
**Category:** Ansible Project\
**Created:** [May 26, 2015, 11:46am UTC](https://forum.ansible.com/t/consul-kv-usage/18308 "2015-05-26T11:46:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [May 26, 2015, 11:46am UTC](https://forum.ansible.com/t/consul-kv-usage/18308/1 "2015-05-26T11:46:43Z")

</div>

Just started to play with the new consul goodness.

Is it planned that the only way to specify a consul-agent is via an environment variable ANSIBLE\_CONSUL\_URL?

In any case I cannot seem to get with\_consul\_kv to work:

`  
$ curl -X GET localhost:8500/v1/kv/foo/bar  
[{“CreateIndex”:6760,“ModifyIndex”:6760,“LockIndex”:0,“Key”:“foo/bar”,“Flags”:0,“Value”:“YmF6”}]%

$ consulkv get foo/bar  
baz  
`

So my key exists on the localhost agent, but

`

- shell: “echo {{item}}”  
with\_consul\_kv:
- ‘foo/bar’  
`

yields connection refused (where 10.0.136.87 is the same host as above)

`  
ASK: [shell echo {{item}}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [10.0.136.87] =\> Error locating ‘foo/bar’ in kv store. Error was (‘Connection aborted.’, error(61, ‘Connection refused’))

`

Anybody else play with this yet?

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [May 26, 2015, 11:54am UTC](https://forum.ansible.com/t/consul-kv-usage/18308/2 "2015-05-26T11:54:12Z")

</div>

Now I’m wondering if my install might be screwed up. When I try

`

- name: add a kv pair to the kv store  
consul\_kv: key=baz value=bar  
register: new\_key  
`

I get ‘ERROR: consul\_kv is not a legal parameter in an Ansible task or handler’

I am running 1.9.1, and am looking at the source from the ‘stable-1.9’ branch.

---

<div class="post-metadata">

**Author:** ![Barry\_Kaplan](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Barry\_Kaplan](https://forum.ansible.com/u/Barry_Kaplan)\
**Post date:** [May 26, 2015, 12:35pm UTC](https://forum.ansible.com/t/consul-kv-usage/18308/3 "2015-05-26T12:35:39Z")

</div>

Ok, went to using ansible from source, now consul\_kv works – I can insert kv’s. But with\_consul\_kv always fails in the same way. I even copied tasks from the tests and they too fail. So maybe this is not quite ready…, or maybe I am missing something…
