Any interest in docker-machine modules?

63 views
Skip to first unread message

Jonathan Rowlands

unread,
Jan 3, 2016, 5:27:55 PM1/3/16
to Ansible Project
Greetings! I created a primitive suite of docker-machine modules:


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:

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:

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!


Greg DeKoenigsberg

unread,
Jan 4, 2016, 9:53:21 AM1/4/16
to Ansible Project
I'd be interested in seeing something like this. Right now I'm using
docker-machine for some projects, and the way I'm orchestrating
multiple containers on my laptop is Ansible with local raw commands.

I'm sure the Docker folks would tell you that docker-compose is the
way to go here, but for people who are more comfortable with Ansible,
it would be nice to have an alternative.

Of course, if Docker would just put Python in their docker-machine
image, it wouldn't be an issue, but ¯\_(ツ)_/¯

--g
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f805f87d-2802-49a8-8b15-a89196358717%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Greg DeKoenigsberg
Ansible Community Guy
Reply all
Reply to author
Forward
0 new messages