osism 0.20251003.0__py3-none-any.whl → 0.20251004.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
osism/tasks/__init__.py CHANGED
@@ -13,6 +13,9 @@ from loguru import logger
13
13
 
14
14
  from osism import utils
15
15
 
16
+ # Regex pattern for extracting hosts from Ansible output
17
+ HOST_PATTERN = re.compile(r"^(ok|changed|failed|skipping|unreachable):\s+\[([^\]]+)\]")
18
+
16
19
 
17
20
  class Config:
18
21
  broker_connection_retry_on_startup = True
@@ -88,7 +91,7 @@ def get_container_version(worker):
88
91
 
89
92
 
90
93
  def log_play_execution(
91
- request_id, worker, environment, role, hosts=None, result="started"
94
+ request_id, worker, environment, role, hosts=None, arguments=None, result="started"
92
95
  ):
93
96
  """Log Ansible play execution to central tracking file.
94
97
 
@@ -98,6 +101,7 @@ def log_play_execution(
98
101
  environment: The environment parameter
99
102
  role: The playbook/role that was executed
100
103
  hosts: List of hosts the play was executed against (default: empty list)
104
+ arguments: Command-line arguments passed to ansible-playbook (default: None)
101
105
  result: Execution result - "started", "success", or "failure"
102
106
  """
103
107
  log_file = Path("/share/ansible-execution-history.json")
@@ -105,6 +109,10 @@ def log_play_execution(
105
109
  # Get runtime version from YAML version file
106
110
  runtime_version = get_container_version(worker)
107
111
 
112
+ # Use provided hosts or empty list
113
+ if hosts is None:
114
+ hosts = []
115
+
108
116
  execution_record = {
109
117
  "timestamp": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z"),
110
118
  "request_id": request_id,
@@ -112,7 +120,8 @@ def log_play_execution(
112
120
  "worker_version": runtime_version,
113
121
  "environment": environment,
114
122
  "role": role,
115
- "hosts": hosts if isinstance(hosts, list) else [],
123
+ "hosts": hosts,
124
+ "arguments": arguments if arguments else "",
116
125
  "result": result,
117
126
  }
118
127
 
@@ -143,6 +152,7 @@ def run_ansible_in_environment(
143
152
  auto_release_time=3600,
144
153
  ):
145
154
  result = ""
155
+ extracted_hosts = set() # Local set for host deduplication
146
156
 
147
157
  if type(arguments) == list:
148
158
  joined_arguments = " ".join(arguments)
@@ -181,7 +191,8 @@ def run_ansible_in_environment(
181
191
  worker=worker,
182
192
  environment=environment,
183
193
  role=role,
184
- hosts=None, # Host extraction would require inventory parsing
194
+ hosts=None, # Hosts will be empty at start, filled at completion
195
+ arguments=joined_arguments,
185
196
  result="started",
186
197
  )
187
198
 
@@ -269,6 +280,13 @@ def run_ansible_in_environment(
269
280
 
270
281
  while p.poll() is None:
271
282
  line = p.stdout.readline().decode("utf-8")
283
+
284
+ # Extract hosts from Ansible output
285
+ match = HOST_PATTERN.match(line.strip())
286
+ if match:
287
+ hostname = match.group(2)
288
+ extracted_hosts.add(hostname) # Local set (automatic deduplication)
289
+
272
290
  if publish:
273
291
  utils.push_task_output(request_id, line)
274
292
  result += line
@@ -281,7 +299,8 @@ def run_ansible_in_environment(
281
299
  worker=worker,
282
300
  environment=environment,
283
301
  role=role,
284
- hosts=None, # Host extraction would require inventory parsing
302
+ hosts=sorted(list(extracted_hosts)), # Direct pass of extracted hosts
303
+ arguments=joined_arguments,
285
304
  result="success" if rc == 0 else "failure",
286
305
  )
287
306
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osism
3
- Version: 0.20251003.0
3
+ Version: 0.20251004.0
4
4
  Summary: OSISM manager interface
5
5
  Home-page: https://github.com/osism/python-osism
6
6
  Author: OSISM GmbH
@@ -38,7 +38,7 @@ osism/services/__init__.py,sha256=bG7Ffen4LvQtgnYPFEpFccsWs81t4zqqeqn9ZeirH6E,38
38
38
  osism/services/event_bridge.py,sha256=roV90o9UgTnwoVbXnPR3muBk04IriVYCO_fewZ46Mq8,12016
39
39
  osism/services/listener.py,sha256=O8Xq5fEEVoNFIgFPE7GqfVqx6C4QkdWhUPUGzODFnws,14211
40
40
  osism/services/websocket_manager.py,sha256=F147kWOg8PAvbVG4aVYQVtK4mFMfPVtHxxYJXaqiAjg,11051
41
- osism/tasks/__init__.py,sha256=l-tzKk4QxRCD8PxNhHS6SdNgDa2Ilr10HZc3FN5HZH4,13089
41
+ osism/tasks/__init__.py,sha256=l_a7IfYm_NUn6XOokfJBYjTuMZGyvGHcvDUOMWSeYGo,13814
42
42
  osism/tasks/ansible.py,sha256=wAeFqyY8EavySpOIBSgWwK3HcGXWPZCIVOaSss5irCM,1387
43
43
  osism/tasks/ceph.py,sha256=Zo-92rzbJ9NDH9dbKi_JPWwekO3cYTdbmwAGSwr5l0w,726
44
44
  osism/tasks/conductor.py,sha256=WBLsoPtr0iGUzRGERs0Xt7CMYrnHQVEwNV9qXBssI3s,274
@@ -65,11 +65,11 @@ osism/tasks/conductor/sonic/interface.py,sha256=M876LHdFqGxUfTizzDusdzvCkDI0vCgq
65
65
  osism/tasks/conductor/sonic/sync.py,sha256=fpgsQVwq6Hb7eeDHhLkAqx5BkaK3Ce_m_WvmWEsJyOo,9182
66
66
  osism/utils/__init__.py,sha256=IEr0sR1HKg-QI_u84fs4gMldC6-EPSxvMBh2zMGu5dU,9939
67
67
  osism/utils/ssh.py,sha256=nxeEgwjJWvQCybKDp-NelMeWyODCYpaXFCBchAv4-bg,8691
68
- osism-0.20251003.0.dist-info/licenses/AUTHORS,sha256=oWotd63qsnNR945QLJP9mEXaXNtCMaesfo8ZNuLjwpU,39
69
- osism-0.20251003.0.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
70
- osism-0.20251003.0.dist-info/METADATA,sha256=Km5pxS6evxg2a_I6MBDbX5PA8BZbRweyt4fWtSgP85M,2971
71
- osism-0.20251003.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
72
- osism-0.20251003.0.dist-info/entry_points.txt,sha256=W45YQ7MJ7BCAPZXl3F6d2FSi6An0moZQbzLn_BwGnRE,4618
73
- osism-0.20251003.0.dist-info/pbr.json,sha256=OKB9yQU8MRrWVMUvBfcaJlhCTJLe5o6nxgVl2sh5qxQ,47
74
- osism-0.20251003.0.dist-info/top_level.txt,sha256=8L8dsI9hcaGHsdnR4k_LN9EM78EhwrXRFHyAryPXZtY,6
75
- osism-0.20251003.0.dist-info/RECORD,,
68
+ osism-0.20251004.0.dist-info/licenses/AUTHORS,sha256=oWotd63qsnNR945QLJP9mEXaXNtCMaesfo8ZNuLjwpU,39
69
+ osism-0.20251004.0.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
70
+ osism-0.20251004.0.dist-info/METADATA,sha256=AyzRodVxbpGRzpJZM9nl7_8BBf-iAjb25mOWR8sl3UM,2971
71
+ osism-0.20251004.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
72
+ osism-0.20251004.0.dist-info/entry_points.txt,sha256=W45YQ7MJ7BCAPZXl3F6d2FSi6An0moZQbzLn_BwGnRE,4618
73
+ osism-0.20251004.0.dist-info/pbr.json,sha256=O4D8iZGKdlEwIsuOJIdJnESPh6JYeG__nO6RBvorNPU,47
74
+ osism-0.20251004.0.dist-info/top_level.txt,sha256=8L8dsI9hcaGHsdnR4k_LN9EM78EhwrXRFHyAryPXZtY,6
75
+ osism-0.20251004.0.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ {"git_version": "e546bf8", "is_release": false}
@@ -1 +0,0 @@
1
- {"git_version": "fc7b5e0", "is_release": false}