Skip to content

Commit 93d0316

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

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

0 commit comments

Comments
 (0)