opsta.docker_machine
Manage Docker Machine
=========
This Ansible role helps you to manage machines for Docker Machine. Here’s what it does:
- Installs Docker Machine
- Creates a Docker Machine on each target host listed in the inventory
- Updates the docker machine
config.json
file to change the storage directory
For examples on how to create a playbook, configure it, and run sample commands, visit: Example Repository.
Remarks
- This role will execute the
docker-machine
command locally. - The target machine's name from the inventory file will be used as the machine name in the
docker-machine ls
command. - By default, Docker Machine will store files in the
files/docker-machine
directory within the playbook. You can change this path using thedocker_machine_storage_path
variable. - This role is designed to be conditional, so you need to set specific variables in your playbook to run certain tasks. For examples, see the Example Playbook section.
- Set
docker_machine_create
totrue
to create a Docker Machine. - Set
docker_machine_manage_config
totrue
to update theconfig.json
file.
- Set
Requirements
- You need to be able to SSH into the target host using an SSH key.
Role Variables
# Default variables
docker_machine_create: false
docker_machine_manage_config: false
docker_machine_install_version: 0.7.0
docker_machine_install_url: https://github.com/docker/machine/releases/download/v{{ docker_machine_install_version }}/docker-machine-{{ ansible_system }}-{{ ansible_architecture }}
docker_machine_install_path: /usr/local/bin/docker-machine
docker_machine_install_checksum: md5:bf73bbfee97fad04d3ff20151b1847fa
docker_machine_storage_path: "{{ playbook_dir }}/files/docker-machine"
docker_machine_config_file: "{{ docker_machine_storage_path }}/machines/{{ inventory_hostname }}/config.json"
docker_machine_config_variables:
- { regexp: '"StorePath": "(.*)",$', replace: '"StorePath": "{{ docker_machine_storage_path }}",' }
- { regexp: '"StorePath": "(.*)"$', replace: '"StorePath": "{{ docker_machine_storage_path }}/machines/{{ inventory_hostname }}"' }
- { regexp: '"CertDir": "(.*)",$', replace: '"CertDir": "{{ docker_machine_storage_path }}/certs",' }
- { regexp: '"CaCertPath": "(.*)",$', replace: '"CaCertPath": "{{ docker_machine_storage_path }}/certs/ca.pem",' }
- { regexp: '"CaPrivateKeyPath": "(.*)",$', replace: '"CaPrivateKeyPath": "{{ docker_machine_storage_path }}/certs/ca-key.pem",' }
- { regexp: '"ServerCertPath": "(.*)",$', replace: '"ServerCertPath": "{{ docker_machine_storage_path }}/machines/{{ inventory_hostname }}/server.pem",' }
- { regexp: '"ServerKeyPath": "(.*)",$', replace: '"ServerKeyPath": "{{ docker_machine_storage_path }}/machines/{{ inventory_hostname }}/server-key.pem",' }
- { regexp: '"ClientKeyPath": "(.*)",$', replace: '"ClientKeyPath": "{{ docker_machine_storage_path }}/certs/key.pem",' }
- { regexp: '"ClientCertPath": "(.*)",$', replace: '"ClientCertPath": "{{ docker_machine_storage_path }}/certs/cert.pem",' }
# Optional variables
docker_machine_extra_parameters: --engine-registry-mirror https://registry-mirror.example.com
Dependencies
No dependencies.
Example Playbook
- hosts: all
connection: local
gather_facts: yes
become: false
roles:
- role: winggundamth.docker_machine
docker_machine_create: true
docker_machine_manage_config: true
vars_files:
- "{{ docker_machine_vars_file }}"
Useful Tags
Here are some useful tags for managing Docker Machine:
docker-machine-create
(setdocker_machine_create
totrue
)docker-machine-install
(setdocker_machine_create
totrue
)docker-machine-manage-config
(setdocker_machine_manage_config
totrue
)
License
MIT License
Author Information
You can check out my work at GitHub.
Informazioni sul progetto
Ansible role to manage machines for Docker Machine
Installa
ansible-galaxy install opsta.docker_machine
Licenza
mit
Download
582
Proprietario
We build scale