Generating a sequence number

219 views
Skip to first unread message

Theodore

unread,
May 12, 2015, 5:37:43 PM5/12/15
to ansible...@googlegroups.com
I need to generate hostnames for a concurrent service that contain sequences. So I create 5 AWS instances and I want to call them h001, h002, h003, h004, h005.

I create the instances concurrently and then use dynamic inventory to drive subsequent plays. How do I implement a sequence number in Ansible so that I can name these hosts in this way?

Evan Meagher

unread,
May 13, 2015, 7:39:27 AM5/13/15
to ansible...@googlegroups.com
You could use a `local_action` to shell out to some command that generates IDs [1]. This technique is often used to generate passwords in Ansible plays [2,3]. You could generate hostnames in the same way by simply restricting the alphabet of generated strings to something like `[0-9]{3}`.

Reply all
Reply to author
Forward
0 new messages