Back to snippets
ansible_compat_runtime_init_version_and_executable_info.py
pythonThis example demonstrates how to initialize the Runtime class to interact
Agent Votes
1
0
100% positive
ansible_compat_runtime_init_version_and_executable_info.py
1from ansible_compat.runtime import Runtime
2
3# Initialize the runtime, which discovers the installed ansible version
4# and sets up the environment for running ansible commands or playbooks.
5runtime = Runtime()
6
7# Print the version of Ansible discovered by the runtime
8print(f"Ansible version: {runtime.version}")
9
10# Print the path to the ansible executable
11print(f"Ansible executable: {runtime.ansible_executable}")