Skip to content

Commit

Permalink
The synthetic 'all' environment branches are now the same length as a…
Browse files Browse the repository at this point in the history
…ctual environment branches
  • Loading branch information
NeonSludge committed Aug 5, 2024
1 parent 154b93d commit cf0493d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ In general, if you have a single TXT record for a `HOST` and this record has all
@all:
|--@all_<ROLE>:
| |--@all_<ROLE>_<SRV[1]>:
| | |--<HOST>
| | |--@all_<ROLE>_<SRV[1]>_<SRV[2]>:
| | | |--@all_<ROLE>_<SRV[1]>_<SRV[2]>_..._<SRV[n]>:
| | | | |--<HOST>
|--@all_host:
| |--@all_host_<OS>:
| | |--<HOST>
Expand Down Expand Up @@ -205,9 +207,12 @@ These will produce the following Ansible inventory tree:
@all:
|--@all_app:
| |--@all_app_tomcat:
| | |--app01.infra.local
| | |--app02.infra.local
| | |--app03.infra.local
| | |--@all_app_tomcat_backend:
| | | |--@all_app_tomcat_backend_auth:
| | | | |--app01.infra.local
| | | | |--app02.infra.local
| | | |--@all_app_tomcat_backend_media:
| | | | |--app03.infra.local
|--@all_host:
| |--@all_host_linux:
| | |--app01.infra.local
Expand Down
4 changes: 2 additions & 2 deletions pkg/inventory/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func (n *Node) ImportHosts(hosts map[string][]*HostAttributes, sep string) {
groupNode := envNode.AddChild(groupName)

// Service: root>environment>role>service[1]>...>service[N].
for i, srv := range strings.Split(attr.Srv, sep) {
if len(srv) > 0 && (i == 0 || env != ansibleRootGroup || attr.Env == ansibleRootGroup) {
for _, srv := range strings.Split(attr.Srv, sep) {
if len(srv) > 0 {
groupName = groupName + sep + srv
groupNode = groupNode.AddChild(groupName)
}
Expand Down

0 comments on commit cf0493d

Please sign in to comment.