Skip to content

Commit f38689a

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

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
@@ -13,9 +13,11 @@
1313
def update_pools(inventory: dict) -> None:
1414
"""Updates hosts in pool(s).
1515
16-
.. note:: Host must be a master
16+
.. note::
1717
18-
Every non-master hosts will be ignored
18+
Every non-master hosts in inventory will be ignored
19+
20+
*Update master hosts declared in inventory first, then, update secondary hosts attached to each master.*
1921
2022
:param dict inventory:
2123
Each host (key) holds its own config data (values, eg: `enablerepos`).
@@ -33,3 +35,12 @@ def update_pools(inventory: dict) -> None:
3335
with ThreadPoolExecutor() as executor:
3436
for p in pools:
3537
executor.submit(p.master.update, inventory[p.master.hostname_or_ip]["enablerepos"])
38+
39+
# secondary hosts
40+
with ThreadPoolExecutor() as executor:
41+
for p in pools:
42+
# omit first item because it is a primary (master)
43+
for h in p.hosts[1:]:
44+
# repos are the same as the primary (master)
45+
repos = inventory[p.master.hostname_or_ip]["enablerepos"]
46+
executor.submit(h.update, repos)

0 commit comments

Comments
 (0)