Skip to content

Commit f25db0f

Browse files
committed
tools/update: update secondary hosts too
Signed-off-by: Olivier Hoareau <olivier.hoareau@vates.tech>
1 parent 1ed5e52 commit f25db0f

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

lib/tools/tasks/update.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
def update_pools(inventory: dict) -> None:
1313
"""Updates hosts in pool(s).
1414
15-
.. note:: Host must be a master
15+
.. note::
1616
17-
Every non-master hosts will be ignored
17+
Every non-master hosts in inventory will be ignored
18+
19+
*Update master hosts declared in inventory first, then, update secondary hosts attached to each master.*
1820
1921
:param dict inventory:
2022
Each host (key) holds its own config data (values, eg: `enablerepos`).
@@ -33,6 +35,15 @@ def update_pools(inventory: dict) -> None:
3335
for p in pools:
3436
executor.submit(update_host, p.master, inventory[p.master.hostname_or_ip]["enablerepos"])
3537

38+
# secondary hosts
39+
with ThreadPoolExecutor() as executor:
40+
for p in pools:
41+
# omit first item because it is a primary (master)
42+
for h in p.hosts[1:]:
43+
# repos are the same as the primary (master)
44+
repos = inventory[p.master.hostname_or_ip]["enablerepos"]
45+
executor.submit(update_host, h, repos)
46+
3647

3748
def update_host(host: Host, enablerepos: list[str] = []):
3849
"""Updates the target host.

0 commit comments

Comments
 (0)