File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212def 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
3748def update_host (host : Host , enablerepos : list [str ] = []):
3849 """Updates the target host.
You can’t perform that action at this time.
0 commit comments