diff options
Diffstat (limited to 'roles/download-iso')
-rwxr-xr-x | roles/download-iso/library/latest_iso.py | 29 | ||||
-rw-r--r-- | roles/download-iso/tasks/main.yml | 33 |
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 |