Open nickdibari opened 4 years ago
NOTE
Script for dynamically generating DigitalOcean inventory can be found here: https://github.com/ansible/ansible/blob/stable-2.9/contrib/inventory/digital_ocean.py
Will need to generate an API key from DigitalOcean to use this script
NOTE
Need to figure out how to set up group hierarchy with dynamic inventory. Currently the dynamic inventory script does not add the mtdj_prod
and prod
groups to the host, resulting in missing variables when provisioning the host.
NOTE
Useful guide for dumping ansible variables to a file on host: https://coderwall.com/p/13lh6w/dump-all-variables
Can be used to compare outputs of static and dynamic inventories variables. They should be equal once all is said and done.
NOTE
Got groups figured out, still need to figure out host variables. The variables defined in host_vars/moodytunes
aren't getting picked up by ansible.
Currently we have a static inventory definition for our production hosts. This works currently, but if we want to get to a point where we can spin up hosts at will we'll need to switch to a dynamic inventory pattern for ansible. This requires using a script that calls out to the DigitalOcean API to find droplets for the account and use those results for compiling the production hosts inventory. For immediate benefit, this prevents us needing to change the production inventory if we end up spinning up a new droplet for the production environment, as the host will automatically be found from the inventory script.
Essentially, we'll want to use the ansible provided DigitalOcean script for finding production hosts. We'll use this when deploying moodytunes to production to find hosts on DigitalOcean and run ansible against them. We should be sure to keep our group hierarchy (
mtdj_prod
andprod
) in place as our variable loading logic depends on this.See the following docs for instructions on implementing this:
https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#using-multiple-inventory-sources
Deliverables