blob: 83d369741852f9985bb53c8be2eddba533a25209 [file] [log] [blame]
Richard Felkl4143a0e2017-02-01 23:24:13 +01001{%- from "glance/map.jinja" import client with context %}
2{%- if client.enabled %}
3
4glance_client_packages:
5 pkg.installed:
6 - names: {{ client.pkgs }}
7
Oleh Hryhorov6de49c92018-05-21 12:53:59 +00008{%- if client.cloud_name is defined %}
9
Vasyl Saienkoe8d0e592018-12-22 11:11:23 +000010{%- for identity_name, identity in client.get('identity', {}).items() %}
Oleh Hryhorov6de49c92018-05-21 12:53:59 +000011{%- for image_name, image in identity.image.items() %}
12
13{%- set _image_properties = {} %}
14{%- do _image_properties.update({'container_format': image.container_format}) %}
15{%- do _image_properties.update({'disk_format': image.disk_format}) %}
Vasyl Saienkof157de52019-05-16 12:46:05 +000016{%- do _image_properties.update({'protected': false}) %}
Oleh Hryhorov6de49c92018-05-21 12:53:59 +000017{%- do _image_properties.update({'tags': image.tags}) %}
18{%- do _image_properties.update({'visibility': image.visibility}) %}
19
20glance_openstack_image_{{ image_name }}:
21 glancev2.image_present:
22 - cloud_name: {{ client.cloud_name }}
23 - name: {{ image.get('name', image_name) }}
24 - image_properties: {{ _image_properties }}
25 {%- if image.import_from_format is defined %}
26 - import_from_format: {{ image.import_from_format }}
27 {%- endif %}
28 {%- if image.location is defined %}
29 - location: {{ image.location }}
30 {%- endif %}
31 {%- if image.wait_timeout is defined %}
32 - timeout: {{ image.wait_timeout }}
33 {%- endif %}
34 {%- if image.checksum is defined %}
35 - checksum: {{ image.checksum }}
36 {%- endif %}
37{%- endfor %}
38{%- endfor %}
39
40
41{%- else %}
Vasyl Saienkod7d18ed2018-12-22 18:10:24 +000042{%- for identity_name, identity in client.get('identity', {}).items() %}
Richard Felkl4143a0e2017-02-01 23:24:13 +010043
Benjamin Drung35de7642018-02-14 23:54:30 +010044{%- for image_name, image in identity.image.items() %}
Richard Felkl4143a0e2017-02-01 23:24:13 +010045
46glance_openstack_image_{{ image_name }}:
Elena Ezhova1c2ebae2017-07-03 18:29:05 +040047 glanceng.image_import:
48 - name: {{ image.get('name', image_name) }}
Richard Felkl4143a0e2017-02-01 23:24:13 +010049 - profile: {{ identity_name }}
Elena Ezhova1c2ebae2017-07-03 18:29:05 +040050 {%- if image.import_from_format is defined %}
51 - import_from_format: {{ image.import_from_format }}
52 {%- endif %}
Richard Felkl4143a0e2017-02-01 23:24:13 +010053 {%- if image.visibility is defined %}
54 - visibility: {{ image.visibility }}
55 {%- endif %}
56 {%- if image.protected is defined %}
57 - protected: {{ image.protected }}
58 {%- endif %}
59 {%- if image.location is defined %}
60 - location: {{ image.location }}
61 {%- endif %}
Elena Ezhova1c2ebae2017-07-03 18:29:05 +040062 {%- if image.tags is defined %}
63 - tags: {{ image.tags }}
64 {%- endif %}
65 {%- if image.disk_format is defined %}
66 - disk_format: {{ image.disk_format }}
67 {%- endif %}
68 {%- if image.container_format is defined %}
69 - container_format: {{ image.container_format }}
70 {%- endif %}
71 {%- if image.wait_timeout is defined %}
72 - timeout: {{ image.wait_timeout }}
73 {%- endif %}
74 {%- if image.checksum is defined %}
75 - checksum: {{ image.checksum }}
76 {%- endif %}
Richard Felkl4143a0e2017-02-01 23:24:13 +010077
78{%- endfor %}
79{%- endfor %}
80
Oleh Hryhorov6de49c92018-05-21 12:53:59 +000081{%- endif %}
82
83{%- endif %}