Skip to content

Commit adab358

Browse files
committed
tools/inventory: rename all section into default
Signed-off-by: Olivier Hoareau <olivier.hoareau@vates.tech>
1 parent 78f8233 commit adab358

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ Take a look at an example inventory file:
671671
```toml
672672
# my_inventory.toml
673673

674-
[all]
674+
[default]
675675
repositories = ["xcp-ng-base"]
676676
hosting_pool = "A"
677677

@@ -686,9 +686,10 @@ hosting_pool = "B"
686686
```
687687

688688
> [!IMPORTANT]
689-
> Config values under `hosts` override values under `all`. For instance, the above inventory would produce
689+
> * `default` is applied to all hosts
690+
> * Config values under `hosts` override values under `default`. For instance, the above inventory would produce
690691
> the following python dict:
691692
>
692693
> `{'ip_or_hostname-1': {'repositories': ['xcp-ng-base'], 'hosting_pool': 'A'}, 'ip_or_hostname-2': {'repositories': ['xcp-ng-updates'], 'hosting_pool': 'B'}}`
693694
>
694-
> Using *enablerepo flag* `-e` with inventory is still possible, it won't be used though.
695+
> * Using *enablerepo flag* `-e` with inventory is still possible, it won't be used though.

lib/tools/inventory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ def load_inventory(inventory_path: Path) -> Inventory:
2424
with open(inventory_path, "rb") as f:
2525
data = tomllib.load(f)
2626

27-
all = data.get("all", {})
27+
default = data.get("default", {})
2828
hosts = data.get("hosts", [])
2929

3030
inventory_hosts: HostConfigs = {}
3131
for h, config in hosts.items():
3232
repos = config.get("repositories", [])
3333
hosting_pool = config.get("hosting_pool", None)
3434
if hosting_pool is None:
35-
hosting_pool = all.get("hosting_pool", None)
35+
hosting_pool = default.get("hosting_pool", None)
3636
host: HostConfig = {
37-
"repositories": repos or all.get("repositories", []),
37+
"repositories": repos or default.get("repositories", []),
3838
"hosting_pool": hosting_pool,
3939
}
4040
inventory_hosts[h] = host

0 commit comments

Comments
 (0)