groups.py¶
This file lets you specify or dynamically build a list of groups in your environment.
Introduction¶
As with nodes.py, you define your groups as a dictionary:
groups = {
'all': {
'member_patterns': (
r".*",
),
},
'group1': {
'members': (
'node1',
),
},
}
All group attributes are optional.
Group attribute reference¶
This section is a reference for all possible attributes you can define for a group:
groups = {
'group1': {
# THIS PART IS EXPLAINED HERE
},
}
member_patterns¶
A list of regular expressions. Node names matching these expressions will be added to the group members.
Matches are determined using the search() method.
metadata¶
A dictionary of arbitrary data that will be accessible from each node’s node.metadata. For each node, BundleWrap will merge the metadata of all of the node’s groups first, then merge in the metadata from the node itself.
Warning
Be careful when defining conflicting metadata (i.e. dictionaries that have some common keys) in multiple groups. BundleWrap will consider group hierarchy when merging metadata. For example, it is possible to define a default nameserver for the “eu” group and then override it for the “eu.frankfurt” subgroup. The catch is that this only works for groups that are connected through a subgroup hierarchy. Independent groups will have their metadata merged in an undefined order.
metadata_processors¶
Note
This is an advanced feature. You should already be very familiar with BundleWrap before using this.
A list of strings formatted as module.function where module is the name of a file in the libs/ subdirectory of your repo (without the .py extension) and function is the name of a function in that file.
This function can be used to dynamically manipulate metadata after the static metadata has been generated. It looks like this:
def example1(node_name, groups, metadata, **kwargs):
if "group1" in groups and "group2" in groups:
metadata['foo'].append("bar")
return metadata
As you can see, the metadata processor function is passed the node name, a list of group names and the metadata dictionary generated so far. You can then manipulate that dictionary based on these parameters and must return the modified metadata dictionary.
password¶
SSH and sudo password to use for nodes in this group. Overrides password set on the command line.
Warning
Please do not write any passwords into your groups.py. This attribute is intended to be used with an external source of passwords and filled dynamically.
Warning
Be careful when defining passwords in groups that share one or more nodes. BundleWrap will consider group hierarchy when determining the password to use. For example, it is possible to define a default password for the “eu” group and then override it for the “eu.frankfurt” subgroup. The catch is that this only works for groups that are connected through a subgroup hierarchy. Passwords in independent groups will be chosen in an undefined way.
subgroups¶
A tuple or list of group names whose members should be recursively included in this group.