Last active
January 12, 2019 06:05
-
-
Save mrlesmithjr/f8a18d7e5eb26ad5390f927e183b5dbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
gather_facts: false | |
connection: local | |
vars: | |
# Defines number of VMs to create | |
vm_count: 10 | |
# Defines VM naming | |
vm_naming: vm | |
# Defines VM number to start with | |
vm_start: 0 | |
# Defines VM number stepping | |
vm_step: 1 | |
tasks: | |
- name: VM Loop Sequence | |
debug: | |
msg: "{{ vm_naming + ('0' + item|string if item < 10 else item|string) }}" | |
loop: "{{ range(vm_start, vm_count, vm_step)|list }}" | |
- name: Create VM Group | |
add_host: | |
group: VMS | |
host: "{{ vm_naming + ('0' + item|string if item < 10 else item|string) }}" | |
loop: "{{ range(vm_start, vm_count, vm_step)|list }}" | |
- debug: var=groups['VMS'] |
Author
mrlesmithjr
commented
Jan 12, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment