#
# Create docker machine
#
---
- hosts: all
  gather_facts: false

  vars:
    docker_machine_options: ""

  tasks:
    - name: Check docker machine existence
      become: false
      local_action:
        shell docker-machine config {{ inventory_hostname }}
      register: dm_present
      failed_when: "'Error' in dm_present.stderr"
      ignore_errors: yes

    - name: Create generic docker machine
      become: false
      local_action:
        shell docker-machine create -d generic
          --generic-ssh-user {{ ansible_ssh_user }}
          --generic-ssh-key  {{ ansible_ssh_private_key_file }}
          --generic-ip-address {{ hostvars[inventory_hostname]['ansible_ssh_host'] }}
          {{ docker_machine_options }}
            {{ inventory_hostname }}
      when: dm_present|failed

    - name: Debug docker machine creation
      debug:
        msg: |
          docker-machine create -d generic
            --generic-ssh-user {{ ansible_ssh_user }}
            --generic-ssh-key  {{ ansible_ssh_private_key_file }}
            --generic-ip-address {{ hostvars[inventory_hostname]['ansible_ssh_host'] }}
            {{ docker_machine_options }}
              {{ inventory_hostname }}
      tags: debug

Add playbook to create docker machine
Add playbook to create docker machine
