1

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?

1

What cloud service are you using? Depending on what cloud you are using you should look at Ansible dynamic inventory.

The Ansible inventory supports IP addresses and FQDN addresses, not just arbitrary addresses, so if you create DNS entries when creating hosts, you can reference those.

If you need a host to be added to inventory in the middle of a playbook you can use the add_host module. This will add the host to the inventory in memory, put will not persist it to a file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.