opsta.docker_machine

Gérer Docker Machine

Rôle Ansible pour gérer des machines pour Docker Machine.

  • Installer Docker Machine
  • Créer des machines Docker pour chaque hôte cible dans l'inventaire
  • Rechercher et remplacer le fichier config.json de Docker Machine pour changer le répertoire de stockage

Vous pouvez voir un exemple de manière de créer un playbook, une configuration et des commandes d'exemple ici : https://github.com/winggundamth/ansible-wing-playbook

Remarques

  • Ce rôle exécutera la commande docker-machine sur la machine locale
  • Le nom de la machine cible dans le fichier d'inventaire sera le nom de la machine dans docker-machine ls
  • Le chemin de stockage par défaut de Docker Machine sera dans files/docker-machine du playbook. Vous pouvez le changer via la variable docker_machine_storage_path
  • Ce rôle est destiné à être conditionnel, donc dans le playbook, vous devez configurer la variable pour des tâches spécifiques à exécuter. Vous pouvez voir un exemple dans la section Exemple de Playbook
    • Définissez la variable docker_machine_create sur true pour exécuter la création de Docker Machine
    • Définissez la variable docker_machine_manage_config sur true pour rechercher et remplacer le config.json de Docker Machine

Conditions requises

  • Vous devez pouvoir vous connecter en SSH à l'hôte cible avec une clé SSH

Variables de rôle

# Ce sont les variables par défaut
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",' }

# Ce sont des variables optionnelles
docker_machine_extra_parameters: --engine-registry-mirror https://registry-mirror.example.com

Dépendances

NA

Exemple de 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 }}"

Liste de balises utiles

Il existe certaines balises utiles que vous pouvez utiliser pour gérer Docker Machine

  • docker-machine-create (cela nécessite de configurer la variable docker_machine_create sur true)
  • docker-machine-install (cela nécessite de configurer la variable docker_machine_create sur true)
  • docker-machine-manage-config (cela nécessite de configurer la variable docker_machine_manage_config sur true)

Licence

MIT

Informations sur l'auteur

Vous pouvez voir mes travaux sur https://github.com/winggundamth

À propos du projet

Ansible role to manage machines for Docker Machine

Installer
ansible-galaxy install opsta.docker_machine
Licence
mit
Téléchargements
582
Propriétaire
We build scale