Update uptime.py (#1524) (#1580)

With one of the recent ansible upgrade (2.14 to 2.15) there is an error: No module named \ "Ansible_collections. Ansible. builtin " when executing the script.

The added code initializes the plugin loader to solve this issue

(cherry picked from commit 952d5f6614)

Co-authored-by: Alexander <Alexander-lex@outlook.de>
This commit is contained in:
patchback[bot]
2024-06-06 14:23:27 -04:00
committed by GitHub
parent a27153d139
commit fe43f4e533

View File

@@ -13,6 +13,7 @@ from ansible.inventory.manager import InventoryManager
from ansible.parsing.dataloader import DataLoader
from ansible.playbook.play import Play
from ansible.plugins.callback import CallbackBase
from ansible.plugins.loader import init_plugin_loader
from ansible.vars.manager import VariableManager
from ansible import context
@@ -51,6 +52,7 @@ class ResultsCollectorJSONCallback(CallbackBase):
def main():
init_plugin_loader()
host_list = ['localhost', 'www.example.com', 'www.google.com']
# since the API is constructed for CLI it expects certain options to always be set in the context object
context.CLIARGS = ImmutableDict(module_path=['/to/mymodules', '/usr/share/ansible'], forks=10, become=None,