Generate syntactically valid Ansible group names
Starting from Ansible 2.8 or so, Ansible expects group names to follow Python naming conventions for identifiers. In practice, this means that dashes are no longer allowed, and should be replaced by underscores.
Now, dashes are perfectly valid service names - in fact, since service names are used verbatim in service discovery, underscores there are problematic as they would generate slightly incorrect DNS entries (not that anybody cares these days). So, we must unfortunately decouple Ansible groups from service names.
In practice this involves:
-
add a group_name attribute to the services dictionary, so you can look up the translated group name from the service name. This will require replacing all uses of groups[service_name] with services[service_name].hosts -
fix the documentation to prominently highlight the difference when writing playbooks
Open question: should we take this opportunity to "namespace" float-generated Ansible groups? It turns out that having all groups share the same namespace is somehow counter-intuitive: suppose you want to use scheduling_group to partition away the monitoring services, it is tempting to call that group "prometheus", which will conflict with the service you want to schedule there... We could, instead, give all float-generated groups a prefix, like float_service_group_, to avoid conflicts.