Greetings! I created a primitive suite of docker-machine modules:
https://github.com/jgrowl/ansible-docker-machine
You can create playbooks like:
- hosts: 127.0.0.1
connection: local
tasks:
- docker_machine_digitalocean: name={{ item.name }} region={{ item.region }} access_token=ABCDEFGHI private_networking=true state=running
with_items:
- { name: ‘test-east-00’, region: ‘nyc3’ }
- { name: ‘test-west-00’, region: ‘sfo1’}
- { name: ‘test-asia-00’, region: ‘sgp1’}
Or a more generic version without any argument_spec checks:
- docker_machine: name=test123 driver=digitalocean region=nyc1 access_token=ABCDEFGHI state=running
Currently the modules don’t do much except let you create/destroy machines. You can see the logic that all of them use in the module_util:
https://github.com/jgrowl/ansible-docker-machine/blob/master/module_utils/docker_machine.py
You will also notice that the logic in the module_util use a docker-machine-py client that I created specifically for use in these ansible modules:
https://github.com/jgrowl/docker-machine-py
The ansible-docker-machine and docker-machine-py projects are still pretty messy and not feature complete. I just wanted to put them out there if anyone would find them useful.
I am also very open to tips, suggestions, etc.
It’s not added to the repo yet, but I am also playing around with the idea of creating a docker_machine connection plugin that leverages the recent docker connection. I am thinking it would work by setting the ansible_connection in the hosts file like:
[consul_servers]
test-east-00 ansible_connection=docker_machine
Maybe an extra ‘docker_machine_name’ could be specified
Again suggestions or constructive criticism is very welcome! Thanks and cheers!