diff --git a/salt/states/tlu-harvester/files/suse-images.yaml.jinja b/salt/states/tlu-harvester/files/suse-images.yaml.jinja new file mode 100644 index 0000000..fc7eb1f --- /dev/null +++ b/salt/states/tlu-harvester/files/suse-images.yaml.jinja @@ -0,0 +1,14 @@ +{% for image in images -%} +--- +apiVersion: harvesterhci.io/v1beta1 +kind: VirtualMachineImage +metadata: + name: {{ salt['random.hash'](image, 'md5')[-10:] }} + namespace: default +spec: + displayName: {{ image }} + pvcName: "" + pvcNamespace: "" + sourceType: download + url: http://{{ pillar['network']['ip'] }}/images/suse/{{ image }} +{% endfor -%} diff --git a/salt/states/tlu-harvester/manifests.sls b/salt/states/tlu-harvester/manifests.sls index 99bfe6a..a9655e0 100644 --- a/salt/states/tlu-harvester/manifests.sls +++ b/salt/states/tlu-harvester/manifests.sls @@ -9,3 +9,15 @@ Add tlu-harvester manifests: - include_empty: True - makedirs: True - dir_modes: "0700" + +{%- set images = salt['file.find']('/srv/www/htdocs/images/suse',type='f',mindepth=1,maxdepth=1,print='name') %} +Adding image manifest for SUSE images: + file.managed: + - name: /home/{{ pillar['username'] }}/tlu-harvester/suse-images.yaml + - source: salt://tlu-harvester/files/suse-images.yaml.jinja + - template: jinja + - user: {{ pillar['username'] }} + - group: users + - mode: "0600" + - context: + images: {{ images }}