This presentation gives an overview of Care.com's infrastructure, Ansible dynamic inventory in general, and the system we developed to standardize our AWS, Rackspace cloud and dedicated, and local dedicated inventories.
to be production - hybrid cloud) 2 AWS-based services International sites on AWS (newer than IAD, older than those 2 services) Corporate datacenter at Markley
inventory Ansible Docs - developing dynamic inventory scripts if the inventory file ("hosts") is executable, ansible assumes it is dynamic executable should return json formatted as ansible expects for multiple inventories, just pass -i <dir>
is structured, we can standardize things we can create groups based on var values (like group_by) stuff like the 'extra_groups' thing described previously we can create new groups based on existing groups and vars (metagroups)
(from rax.py) starting with czgroup_ because a group a la group_by if var == "rax_metadata": for raxvar in hostdict[hostname][var].keys(): if raxvar.startswith("czgroup_"): group = hostdict[hostname][var][raxvar] groupdict.setdefault(group,{}) groupdict[group].setdefault('hosts',set()) groupdict[group]['hosts'].add(hostname) hostdict[hostname][raxvar.replace("czgroup_","",1)] = group
(from ec2.py) starting with ec2_tag_czgroup_ becomes a group a la group_by if var.startswith("ec2_tag_czgroup_"): group = hostdict[hostname][var] groupdict.setdefault(group,{}) groupdict[group].setdefault('hosts',set()) groupdict[group]['hosts'].add(hostname) hostdict[hostname][var.replace("ec2_tag_czgroup_","",1)] = group elif var.startswith("ec2_tag_"): thisvar = var.replace("ec2_tag_","",1) # AWS requires capitalized 'Name' to show up in the console so we # use that as a tag, but other places we use this var it is called # name (lowercase) so we make that conversion here. if thisvar == 'Name': thisvar = 'name' hostdict[hostname][thisvar] = hostdict[hostname][var]
variables and existing group membership metagroups: # Create a $stack‐$systype group for all stacks and systypes, and also # one for $stack‐forkprocess. ‐ [ {variable: stack}, {variable: systype} ] ‐ [ {variable: stack}, {group: forkprocess} ]