summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Boucher <fboucher@redhat.com>2019-10-17 10:21:47 +0200
committerTristan de Cacqueray <tdecacqu@redhat.com>2019-10-25 13:57:12 +0000
commit16cf8900c03e27e39b60d9fea0ec3fbfe6b88587 (patch)
tree5ade740b03b13cb39b01d73f3e090652c1680fa2
parentbbdf04d912047e723e12e3b290e99d9834df862d (diff)
Add discover rawhide role for the rawhide image
The rawhide image is published often and its name evolve over the date (it includes the date). So the role discover the image url and image checksum. Change-Id: Ia28eb0d8aca5d8600a49c9422d8c1101acf77a7f
-rw-r--r--nodepool/elements/virt-customize/fedora-rawhide-cloud.yaml9
-rw-r--r--nodepool/elements/virt-customize/roles/discover-rawhide/defaults/main.yaml1
-rw-r--r--nodepool/elements/virt-customize/roles/discover-rawhide/tasks/main.yaml45
3 files changed, 52 insertions, 3 deletions
diff --git a/nodepool/elements/virt-customize/fedora-rawhide-cloud.yaml b/nodepool/elements/virt-customize/fedora-rawhide-cloud.yaml
index ca350977..fbcb63b1 100644
--- a/nodepool/elements/virt-customize/fedora-rawhide-cloud.yaml
+++ b/nodepool/elements/virt-customize/fedora-rawhide-cloud.yaml
@@ -2,9 +2,10 @@
- name: Build a fedora cloud image suitable for Zuul
hosts: localhost
vars:
- image_url: https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Cloud/x86_64/images/Fedora-Cloud-Base-Rawhide-20191014.n.0.x86_64.qcow2
- image_checksum: "sha256:913d8d3e12678d1907c27526bb9266b3d7505ba74c71359d240b4dc1e8512d31"
- image: Fedora-Cloud-Base-Rawhide-20191013.n.0.x86_64.qcow2
+ # Both url and checksum are going to be discovered thanks to the discover_rawhide role
+ # image_url:
+ # image_checksum:
+ image: Fedora-Cloud-Base-Rawhide.x86_64.qcow2
extra_packages:
# Extra system tools
- pigz
@@ -45,6 +46,8 @@
tasks:
- block:
- import_role:
+ name: discover-rawhide
+ - import_role:
name: base
- import_role:
name: sshd-config
diff --git a/nodepool/elements/virt-customize/roles/discover-rawhide/defaults/main.yaml b/nodepool/elements/virt-customize/roles/discover-rawhide/defaults/main.yaml
new file mode 100644
index 00000000..e87cb9c6
--- /dev/null
+++ b/nodepool/elements/virt-customize/roles/discover-rawhide/defaults/main.yaml
@@ -0,0 +1 @@
+base_url: https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Cloud/x86_64/images/
diff --git a/nodepool/elements/virt-customize/roles/discover-rawhide/tasks/main.yaml b/nodepool/elements/virt-customize/roles/discover-rawhide/tasks/main.yaml
new file mode 100644
index 00000000..51e47c84
--- /dev/null
+++ b/nodepool/elements/virt-customize/roles/discover-rawhide/tasks/main.yaml
@@ -0,0 +1,45 @@
+- tempfile:
+ state: file
+ register: tempfile
+
+- file:
+ path: "{{ tempfile.path }}"
+ state: absent
+
+- name: Fetch publication page
+ get_url:
+ url: "{{ base_url }}"
+ dest: "{{ tempfile.path }}"
+
+- name: Find rawhide qcow2 url
+ command: sed -n "/qcow2/ s/.*\(Fedora-Cloud-Base-Rawhide-.*\)<\/a>.*/\1/p" {{ tempfile.path }}
+ register: get_qcow_image_name
+
+- name: Find checksum file url
+ command: sed -n "/CHECKSUM/ s/.*\(Fedora-Cloud-Rawhide-.*\)<\/a>.*/\1/p" {{ tempfile.path }}
+ register: get_checksum_name
+
+- set_fact:
+ checksums_url: "{{ base_url }}{{ get_checksum_name.stdout }}"
+
+- file:
+ path: "{{ tempfile.path }}"
+ state: absent
+
+- name: Fetch checksum file
+ get_url:
+ url: "{{ checksums_url }}"
+ dest: "{{ tempfile.path }}"
+
+- name: Find checksum
+ command: sed -n "/SHA256 ({{ get_qcow_image_name.stdout }}) = / s/.* = \(.*\)/\1/p" {{ tempfile.path }}
+ register: get_checksum
+
+- set_fact:
+ image_url: "{{ base_url }}{{ get_qcow_image_name.stdout }}"
+ image_checksum: "sha256:{{ get_checksum.stdout }}"
+
+- debug:
+ msg: |
+ Discovered image_url: {{ image_url }}
+ Discovered image_checksum: {{ image_checksum }}