Ansible support for Consul.

I’ve been working on support for interacting with Consul from within Ansible. Currently there is support for manipulating services, checks, acls and values in the kv store. There is also an inventory that gets built from the contents of the catalog, grouping nodes by service and availability. Its pretty close to ready for submission and I have a few questions before creating the pull request.

The modules have been added in the extras repo, but there are other files, the lookup module, inventory script and importantly the integration tests that don’t really fit there and need to be added to the project proper to work. What is the suggested way to add module submissions with tests and other project level files? Can the inventory and lookups go in the extras project? What about the tests? What should I be thinking about for v2 support?

One of the modules is named consul and this happens to have the same name as the inventory script consul.py, this can cause collisions in ‘hacking’ mode where the runtime loads the inventory script instead of the module. Where would I look to exclude the inventory plugins from the module lookup? I could rename the consul module as a workaround, but would prefer to exclude the inventory scripts if possible.

Also, the tests need a working Consul cluster to pass, I’ve put together a Vagrant project and associated roles to spin up a new cluster and add an agent to the local host. If the local agent can’t be found the tests will not run. The roles and vagrant project can be found here

https://github.com/sgargan/consul-vagrant

Vagrant has been really useful for testing, it might be something worth formalizing into the test infrastructure so that the destructive tests can be easily and cleanly run. If the tests for a module were easy to run in isolation, PRs could be automatically verified, I think this TDD/CI approach would definitely help to speed up the throughput of submissions. What are your thoughts on this? I’d be happy to help out with such an effort.

regards,

Steve

Hi Steve,

We’re also using Ansible and starting to use Consul and we’d love to contribute. Can you share a link to your code?

Thanks

I’ve not pushed it yet, should do pretty soon though once I have these issues cleared up. I’ll let you know when its available. In the meantime if you’re looking to get started you could checkout the consul role from galaxy. It’s fairly fully featured and I’ve used it extensively myself but it would be nice to get a second opinion.

thanks,

Steve.

Stephen,

Create separate PRs for each module, tests, inventory script and
lookup plugin, inventory testse, and lookup go against the main repo
github.com/ansibile/ansible. Leave the modules in the extras repo.

Since the inventory and modules go in different paths the name
collision is not important (in your setup inventory is somehow
included in module path, which should never happen).

Finally got round to making the submissions, you can find them here

https://github.com/ansible/ansible/pull/10078
https://github.com/ansible/ansible-modules-extras/pull/225

The modules are reasonably complete for the consul 0.4, and I will update once 0.5 is released.

Consul is really great kit and is very complimentary to Ansible, together they are extremely useful. I hope others will find these additions as helpful as I have.

regards,

Steve.