An open API service indexing awesome lists of open source software.

https://github.com/j7mbo/ansible_docker_machine

Run docker-machine create in ansible
https://github.com/j7mbo/ansible_docker_machine

Last synced: 2 months ago
JSON representation

Run docker-machine create in ansible

Awesome Lists containing this project

README

        

docker_machine_create
--

Overview
--

This is a very simple ansible module to run `docker-machine create` idempotently for you for infrastructure you have
already provisioned.

Description
--

Require the ability to install docker on some node you've provisioned with, say, terraform? You can do this with docker-machine create which not only installs and configures docker for you but sets up an ssh configuration so you can run `docker-machine ssh` to connect to those machines.

By default, it's doing a `--driver generic` as that's all I needed. If you need `digitalocean` for example with other configuration settings, open an issue. Shouldn't take long to add.

Let's say you want to do this with ansible. You could use `shell` in ansible, or you could use this, which does it for you. Nothing complex.

The actual command executed looks like this:

```
docker-machine create --driver generic --generic-ip-address {ip} --generic-ssh-key {ssh_key} {name}
```

How to use
--

Here is the **task**, which goes in your playbook:

```
- name: "Create docker-machine"
docker_machine_create:
name: "{{ name }}"
ip: "{{ machine_ip }}"
ssh_key: "{{ machine_ssh_key }}"
```

To use this module locally, you can follow the instructions [here](https://docs.ansible.com/ansible/latest/dev_guide/developing_locally.html).
Just create a directory called `library/` where your playbook is and check out this python file in it or just copy and paste it.

--dry-run
--

If you run ansible with `--dry-run`, it'll just print out the output from `docker-machine ls` for you without effecting any changes.