---
- hosts: all

  pre_tasks:

# Task creates a vm through an api. Register output with vm name
  - name: Create vm from emplate
    command:  'curl https://vm.example.nl/api/create'
    delegate_to: localhost
    register: ip

# Continue play on newly created vm 
- hosts: '{{ ip }}'

# Roles to configure newly created vm
  roles:
    - common
    - apt-updates
    - webserver
 

I'm trying to create a playbook to provision a virtual machine and apply 
some roles to that vm without knowing name or ip. When provisioning the vm 
through our API it spits out the vmname and ipadress to the stdout. When I 
register the stdout to a variable I can't pass it as you see above to: - 
hosts: '{{ ip }}'
it always says: skipping: no hosts matched

Is the above possible? Or is it possible to use delegate_to for a role. 
Maybe there a other ways? 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/77e7e794-de31-40e1-a6c7-c5badadc18df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to