Last active
December 20, 2017 03:56
-
-
Save pavelanni/fad353d2b19c572cf5131bc0d99743d8 to your computer and use it in GitHub Desktop.
Create sequential file names or EC2 instance tags with Ansible
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
--- | |
- name: naming sequence | |
connection: local | |
hosts: localhost | |
vars: | |
- names: ['cs','cs','cs','cs','cs',] | |
- numbers: [] | |
- n_instances: 5 | |
tasks: | |
- name: create a list of numbers | |
set_fact: | |
numbers: "{{numbers}} + ['{{item}}']" | |
with_sequence: start=1 end={{ n_instances }} format=%03d | |
- name: parallel loop | |
debug: | |
msg: "instance name is {{ item.0 }}-{{ item.1 }}" | |
with_together: | |
- "{{ names }}" | |
- "{{ numbers }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment