- name: spin/ensure vm with nova_compute 
  local_action:
    module: nova_compute
    auth_url: "{{OS_AUTH_URL}}"
    login_username: "{{OS_USERNAME}}"
    login_password: "{{OS_PASSWORD}}"
    login_tenant_name: "{{OS_TENANT_NAME}}"
    name: "{{ vm_name }}"
    # image_id: 86422ca2-6eeb-435c-87e8-402b3c7c3b7b
    image_id: "{{ image_name|image_name_to_id(OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME, OS_AUTH_URL) }}"
    wait_for: "{{ max_spawn_time }}"
    flavor_id: "{{ flavor_name|flavor_name_to_id(OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME, OS_AUTH_URL) }}"
    security_groups: "{{ security_groups }}" #,ssh-internal-persistent
    key_name: "{{ key_name }}"
    nics:
      - net-id: "{{ network_name|network_name_to_id(OS_USERNAME, OS_PASSWORD, OS_TENANT_NAME, OS_AUTH_URL) }}"
  register: nova

# - debug: msg="{{ nova.info }}"


- set_fact: builder_ip="{{ nova.info|nova_result_to_builder_ip(network_name) }}"

- name: add builder ip to the special group
  local_action: add_host hostname={{ builder_ip }} groupname=builder_temp_group
  

