Created
February 18, 2015 19:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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