opsta.docker_machine

管理 Docker Machine

Ansible 角色用于管理 Docker Machine 的机器。

  • 安装 Docker Machine
  • 在库存中的每个目标主机上创建 Docker Machine
  • 搜索并替换 Docker Machine 的 config.json 文件,以更改存储目录

您可以查看如何制作剧本、配置和示例命令的示例,链接在这里 https://github.com/winggundamth/ansible-wing-playbook

注意事项

  • 此角色将在本地机器上运行 docker-machine 命令
  • 库存文件中的目标机器名称将是 docker-machine ls 中机器的名称
  • 默认的 Docker Machine 存储路径为剧本的 files/docker-machine。您可以通过 docker_machine_storage_path 变量更改它
  • 此角色旨在成为条件角色,因此在剧本中您需要为特定任务配置变量。您可以在 示例剧本 部分查看示例
    • docker_machine_create 变量设置为 true 以运行 docker-machine create
    • docker_machine_manage_config 变量设置为 true 以搜索并替换 Docker Machine 的 config.json

需求

  • 您必须能够通过 SSH 密钥 SSH 到目标主机

角色变量

# 默认变量
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",' }

# 可选变量
docker_machine_extra_parameters: --engine-registry-mirror https://registry-mirror.example.com

依赖

示例剧本

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

有用的标签列表

您可以使用一些有用的标签来维护 Docker Machine

  • docker-machine-create(需要将 docker_machine_create 变量设置为 true
  • docker-machine-install(需要将 docker_machine_create 变量设置为 true
  • docker-machine-manage-config(需要将 docker_machine_manage_config 变量设置为 true

许可证

MIT

作者信息

您可以在 https://github.com/winggundamth 查看我的作品

关于项目

Ansible role to manage machines for Docker Machine

安装
ansible-galaxy install opsta.docker_machine
许可证
mit
下载
582
拥有者
We build scale