Skip to content

Instantly share code, notes, and snippets.

@phips
Last active March 28, 2020 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phips/1e895096ca70c85ad3c870b38d6677eb to your computer and use it in GitHub Desktop.
Save phips/1e895096ca70c85ad3c870b38d6677eb to your computer and use it in GitHub Desktop.
---
- hosts: vm_dummy_group
gather_facts: no
tasks:
- name: Test loop
debug:
msg: "Spinning up VM number {{ item }}"
with_sequence: start={{ start }} end={{ end }}
[vm_dummy_group]
host1
host2
host3
host4
host5
[hosts]
host1 ansible_connection=local start=1 end=10
host2 ansible_connection=local start=11 end=20
host3 ansible_connection=local start=21 end=30
host4 ansible_connection=local start=31 end=40
host5 ansible_connection=local start=41 end=50
@phips
Copy link
Author

phips commented Jan 3, 2017

Alternative, courtesy of @bcoca on ansible-project

# inventory

[vm_group]
host[1-50] ansible_connection=local

# play
- hosts: vm_group
  gather_facts: false
  tasks:
    - create_vm: name={{inventory_hostname} ....
      delegate_to: localhost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment