Skip to content

Instantly share code, notes, and snippets.

@boris317
Created February 18, 2015 19:40
Show Gist options
  • Save boris317/5fc7bf6d003c7df3ae74 to your computer and use it in GitHub Desktop.
Save boris317/5fc7bf6d003c7df3ae74 to your computer and use it in GitHub Desktop.
Modifying ansible's DO dynamic inventory to return more helpful groups that suite my needs
# in for loop of method 'build_inventory'
if "-" in droplet['name']:
# Create new groups for names like prod-appname-whatever
# Given the above name, 2 new groups would be created "prod"
# and "prod-appname"
parts = droplet['name'].split("-")
if len(parts) > 1:
self.push(self.inventory, "-".join(parts[0:2]), dest)
self.push(self.inventory, parts[0], dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment