Hi all,
First I would like to thank Ansible creators and its great community because this tool really simplifies my day to day life.
I have the following workflow and I want a piece of advice on Step 3:
-
Step 1: create n nodes with a cloud provider (lb, app-1, app-2, index, index-upgrader, db, db-upgrader, log-server, log-store, log-viewer) (done with any cloud module)
-
Step 2: generate an inventory with IP/hostnames gathered from my cloud provider (done with dynamic inventory modules).
-
Step 3: link nodes by alias so that they have knowledge of each other:
- log-viewer references log-store
- log-server references log-store
- index-upgrader references index
- db-upgrader references db
- app-{1,2} references index, db, log-server
- lb references app-{1,2}
- Step 4: provision and configure nodes with no hardcoded IP adress, only aliases defined in step 3 (regular ansible stuff)
Solution 1: for each node, generate (with templates and lineinfile directive) the proper hosts file on the nodes manager (the node that runs ansible and the playbook) and copy the hosts file to the node.
That solution would surely work but I was wondering if there were a more elegant way.
Solution 2: use a DNS server. It would also do the trick but it’s rather complex for my needs.
Solution 3: An elegant solution would be to “describe” the linking requirements (like it is done in terraform.io but I don’t want to use another tool, so far ansible covers all my needs) in a file and the module would look-up relevant information in the inventory, generate linking artifacts (host files, or whatever) and apply them to corresponding nodes.
Thank you for your advices.
Regards,
Louis