diff --git a/salt/pillars/tlu-harvester.sls b/salt/pillars/tlu-harvester.sls index 7a7aee7..1409e1f 100644 --- a/salt/pillars/tlu-harvester.sls +++ b/salt/pillars/tlu-harvester.sls @@ -17,6 +17,8 @@ tlu-harvester: url: https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2 checksum: da11e3ed78cdadb0c8a15e9dd82c3c2b2746ba61cb98c3c03cfb156e5b8adb10 ns: default + - name: MicroOS + url: https://download.opensuse.org/tumbleweed/appliances/openSUSE-MicroOS.x86_64-kvm-and-xen.qcow2 ubuntu: - name: ubuntu 20.04 (Focal Fossa) url: https://cloud-images.ubuntu.com/focal/20211015/focal-server-cloudimg-amd64-disk-kvm.img diff --git a/salt/states/tlu-harvester/files/manifests/images.sls b/salt/states/tlu-harvester/files/manifests/images.sls index cbbb913..b539be2 100644 --- a/salt/states/tlu-harvester/files/manifests/images.sls +++ b/salt/states/tlu-harvester/files/manifests/images.sls @@ -1,13 +1,16 @@ {% for dist, items in pillar['tlu-harvester']['images'].items() -%} {% for item in items -%} +{% set name = item['checksum'][-10:] if 'checksum' in item else salt['random.hash'](item['url'], 'md5')[-10:] -%} +{% set displayName = item['name'] if 'name' in item else item['url'].split('/')[-1] -%} +{% set ns = item['ns'] if 'ns' in item else 'default' -%} --- apiVersion: harvesterhci.io/v1beta1 kind: VirtualMachineImage metadata: - name: {{ item['checksum'][-10:] }} - namespace: {{ item['ns'] | default('default') }} + name: {{ name }} + namespace: {{ ns }} spec: - displayName: {{ item['name'] | default(item['url'].split('/')[-1]) }} + displayName: {{ displayName }} pvcName: "" pvcNamespace: "" sourceType: download diff --git a/salt/states/tlu-harvester/images.sls b/salt/states/tlu-harvester/images.sls index 494300d..9e68f96 100644 --- a/salt/states/tlu-harvester/images.sls +++ b/salt/states/tlu-harvester/images.sls @@ -5,7 +5,9 @@ Downloading image {{ filename }}: file.managed: - name: /srv/www/htdocs/images/{{ dist }}/{{ filename }} - source: {{ item['url'] }} + {% if 'checksum' in item -%} - source_hash: {{ item['checksum'] }} + {% endif %} - user: root - group: root - mode: "0644"