Closed ldemers777 closed 8 months ago
Can you do it? It is excruciating, I even noted that in some contexts it can take almost 20 minutes. This is madness.
From AWX (the target host is obfuscated because of sensitivity reasons):
I am not likely to fork and create a merge request but at least I provide you with a code snippet that you could easily test and use.
# Here is one close to what you expect as output:
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName,DisplayVersion,PSChildName -unique | Where-Object {$_.DisplayName -clike 'Datadog Agent'} | Format-List
# Output
DisplayName : Datadog Agent
DisplayVersion : 7.46.0.1
PSChildName : {9E3023E6-5C8C-4284-86FC-ECCD68AB07A3}
Thanks.
Hello,
Thanks for the issue. We did not realise using this function was that inefficient. We already use Get-ItemProperty
elsewhere in the code, the change is quite simple. Just opened this PR to do the change you proposed.
https://github.com/DataDog/ansible-datadog/pull/536
https://github.com/DataDog/ansible-datadog/blob/f53b1ab1d63c99410b832f22208470d23b30d71a/tasks/parse-version-windows.yml#L7
Maybe I missed something but I think a command like:
is far more efficient and complete than the actual implementation:
On a general note, consider identifying and optimizing slow Ansible steps in an idempotency context (where the target host is already properly installed/configured) because this role is not efficient in that matter (e.g. when this role is declared as a dependency of other roles often called).