opsta.docker_machine
Docker Machine を管理する
Docker Machine のためのマシンを管理する Ansible ロールです。
- 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
変数を介して変更できます - このロールは条件付きロールを意図しているため、プレイブック内で特定のタスクを実行するために変数を設定する必要があります。Example Playbook セクションで例を参照できます
docker_machine_create
変数をtrue
に設定して Docker Machine を作成します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