I've been playing with server configuration management tool Ansible, whose use often depends on reference to a local inventory file containing arbitrary host names. For example,
# file: my_hosts
[webservers]
web1
web2
Using something like the above, I can do a lot: I can spin up new instances and configure them. However, unless I write the ip's of the newly-created instances to /etc/hosts or similar, I cannot reference new instances solely relying on something like my_hosts.
Is there a way I can supply stable names in my_hosts -- maybe some dynamic DNS service -- such that I can just name my new servers in advance, and subsequently enjoy direct reference to them?
In other words, on the assumption that one is indifferent to the public names of servers that may be created or deleted quite often, what's the best way to refer to them while they live?