34 lines
1.1 KiB
Plaintext
34 lines
1.1 KiB
Plaintext
|
import os
|
||
|
import subprocess
|
||
|
from ansible.module_utils.basic import AnsibleModule
|
||
|
|
||
|
def get_virtualbox_extpack_version():
|
||
|
import xml.etree.ElementTree as ET
|
||
|
if os.path.exists('/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/ExtPack.xml'):
|
||
|
root = ET.parse('/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/ExtPack.xml').getroot()
|
||
|
version = root.find('{http://www.virtualbox.org/VirtualBoxExtensionPack}Version').text
|
||
|
return version
|
||
|
|
||
|
def main():
|
||
|
module = AnsibleModule(
|
||
|
argument_spec=dict(),
|
||
|
supports_check_mode=True,
|
||
|
)
|
||
|
|
||
|
facts = {}
|
||
|
|
||
|
try:
|
||
|
output = subprocess.check_output(['vboxmanage', '-version'])
|
||
|
version, build = output.strip().split('r')
|
||
|
facts['virtualbox_version'] = version
|
||
|
facts['virtualbox_release'] = '.'.join(version.split('.')[0:2])
|
||
|
facts['virtualbox_build'] = build
|
||
|
facts['virtualbox_extpack_version'] = get_virtualbox_extpack_version()
|
||
|
except OSError:
|
||
|
pass
|
||
|
|
||
|
module.exit_json(msg="", ansible_facts=facts)
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|