summaryrefslogtreecommitdiff
path: root/roles/download-iso
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2021-01-23 20:22:31 +0200
committerzsdc <taras@vyos.io>2021-01-23 20:22:31 +0200
commit430392dc3e8385567f97f56c8107130968709227 (patch)
tree43efd26359ebd9bbc107ef7e0591e14392300508 /roles/download-iso
parent5a4bb43ad7ecdfa31f6fc2d2ddec123ac57144bd (diff)
downloadvyos-vm-images-430392dc3e8385567f97f56c8107130968709227.tar.gz
vyos-vm-images-430392dc3e8385567f97f56c8107130968709227.zip
Fixed ISO download task
The current listing of the https://downloads.vyos.io/?dir=rolling/current/amd64 is not compatible with the old parser. Also, now it is not necessary to search for the latest image anymore - it has always the same static URL. Therefore, the download page parser was removed and the download task was modified to download an ISO from a permanent URL.
Diffstat (limited to 'roles/download-iso')
-rwxr-xr-xroles/download-iso/library/latest_iso.py29
-rw-r--r--roles/download-iso/tasks/main.yml33
2 files changed, 15 insertions, 47 deletions
diff --git a/roles/download-iso/library/latest_iso.py b/roles/download-iso/library/latest_iso.py
deleted file mode 100755
index b55ea98..0000000
--- a/roles/download-iso/library/latest_iso.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/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()
diff --git a/roles/download-iso/tasks/main.yml b/roles/download-iso/tasks/main.yml
index dc71771..198a86b 100644
--- a/roles/download-iso/tasks/main.yml
+++ b/roles/download-iso/tasks/main.yml
@@ -1,12 +1,8 @@
-- name: get latest_iso if iso is not defined
- latest_iso:
- when: vyos_iso_url == ""
- register: latest_iso_result
-
-- name: set latest_iso as vyos_iso_url
- set_fact:
- vyos_iso_url: "{{ latest_iso_result.latest_iso }}"
- when: latest_iso_result is defined
+- name: Download VyOS ISO release
+ get_url:
+ url: "{{ vyos_iso_url }}"
+ dest: "{{ vyos_iso_local }}"
+ force: no
- name: Fetch VyOS ISO GPG signature
uri:
@@ -14,25 +10,26 @@
dest: "{{ vyos_iso_local }}.asc"
status_code: 200,404,403
tags: verify
- register: gpg_uri
-
-- name: Download VyOS ISO release
- get_url:
- url: "{{ vyos_iso_url }}"
- dest: "{{ vyos_iso_local }}"
+ register: gpg_uri_iso
- name: Fetch the VyOS release GPG key
- get_url:
+ uri:
url: "{{ vyos_key_url}}"
dest: "{{ vyos_key_local }}"
+ status_code: 200,404,403
tags: verify
+ register: gpg_uri_release_key
- name: Install the VyOS release GPG key
command: gpg --import {{ vyos_key_local }}
- when: gpg_uri.status == 200
+ when:
+ - gpg_uri_iso.status == 200
+ - gpg_uri_release_key.status == 200
tags: verify
- name: Validate ISO GPG signature
command: gpg --verify {{ vyos_iso_local }}.asc {{ vyos_iso_local }}
- when: gpg_uri.status == 200
+ when:
+ - gpg_uri_iso.status == 200
+ - gpg_uri_release_key.status == 200
tags: verify