From 8c9f3a8e7bd9a937bcc4401a27246e258c5b4e4c Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe Date: Wed, 20 Jun 2018 23:06:38 +0900 Subject: Initial QEMU support --- library/hosts | 5 +++++ library/latest_iso.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 library/hosts create mode 100755 library/latest_iso.py (limited to 'library') diff --git a/library/hosts b/library/hosts new file mode 100644 index 0000000..5fd0150 --- /dev/null +++ b/library/hosts @@ -0,0 +1,5 @@ +[local] +localhost + +[qemu] +localhost diff --git a/library/latest_iso.py b/library/latest_iso.py new file mode 100755 index 0000000..b55ea98 --- /dev/null +++ b/library/latest_iso.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import os +import sys +from lxml import html +import requests +import json +from ansible.module_utils.basic import AnsibleModule + +BASE_URL = 'https://downloads.vyos.io/' +PAGE_URL = BASE_URL+'?dir=rolling/current/amd64' + + +def run_module(): + result = dict(changed=False) + module = AnsibleModule(argument_spec=dict()) + + page = requests.get(PAGE_URL) + tree = html.fromstring(page.content) + path = '//*[@id="directory-listing"]/li/a[1]/@href' + isos = [x for x in tree.xpath(path) if os.path.splitext(x)[1] == '.iso'] + latest_iso = os.path.join(BASE_URL, isos[-1]) + result['latest_iso'] = latest_iso + + module.exit_json(**result) + + +if __name__ == '__main__': + run_module() -- cgit v1.2.3