Python client for HashiCorp Consul
This code is avaliable at PyPI as consul-reborn.
Original code belongs to Andy Gayton. And fork with community patches belongs to Carlos.
I don't like how it has been written but have no time for full refactoring, so I just fix issues that I crossed by. I do not fix CI or tests, sorry for that.
I'm using some of its functions in production, so it's not a complete junk.
Original Library Documentation
import consul
c = consul.Consul()
# poll a key for updates
index = None
while True:
index, data = c.kv.get('foo', index=index)
print data['Value']
# in another process
c.kv.put('foo', 'bar')
Alternatively you can create a client from the same environment variables that the consul command line client uses. e.g. CONSUL_HTTP_ADDR, CONSUL_HTTP_TOKEN.
import consul
c = consul.Consul.from_env()
c.agent.self()
pip3 install consul-reborn