From d0f978548eb0fac2cfcb78ca054248ea15774a34 Mon Sep 17 00:00:00 2001 From: Simon Thompson Date: Wed, 5 Jul 2023 21:23:55 +0200 Subject: [PATCH 1/2] sort directory listing to make ansible plays and script order deterministic --- confluent_server/confluent/selfservice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/confluent_server/confluent/selfservice.py b/confluent_server/confluent/selfservice.py index 52cff7ab..f996620e 100644 --- a/confluent_server/confluent/selfservice.py +++ b/confluent_server/confluent/selfservice.py @@ -570,7 +570,7 @@ def get_scriptlist(scriptcat, cfg, nodename, pathtemplate): if not os.path.isdir(target) and os.path.isdir(target + '.d'): target = target + '.d' try: - slist = os.listdir(target) + slist = sorted(os.listdir(target)) except OSError: pass return slist, profile From 45f22c3e31f5cb72fb4fc45123f1e13709ee4b57 Mon Sep 17 00:00:00 2001 From: Simon Thompson Date: Wed, 5 Jul 2023 21:25:25 +0200 Subject: [PATCH 2/2] when host is not in hosts file, group_vars is not loaded, change logic to emulate host being in hosts file with no groups to ensure group_vars is loaded which permits use of dynamic grouping in plays --- confluent_server/confluent/runansible.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/runansible.py b/confluent_server/confluent/runansible.py index 2d47f0c7..299dcb00 100644 --- a/confluent_server/confluent/runansible.py +++ b/confluent_server/confluent/runansible.py @@ -162,8 +162,9 @@ if __name__ == '__main__': if os.path.exists('/etc/ansible/hosts'): aninv = InventoryManager(loader=loader, sources='/etc/ansible/hosts') anshost = aninv.get_host(sys.argv[1]) - if anshost: - invman = aninv + if not anshost: + aninv.add_host(sys.argv[1]) + invman = aninv if not invman: invlist = sys.argv[1] + ',' invman = InventoryManager(loader=loader, sources=invlist)