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
- Host: GitHub
- URL: https://github.com/j7mbo/ansible_docker_machine
- Owner: J7mbo
- Created: 2020-04-27T14:09:35.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-27T15:32:56.000Z (about 5 years ago)
- Last Synced: 2025-01-30T21:29:34.533Z (4 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.