blob: 9349a349fa954bef150e6a242ee79ab7fe66cce3 [file] [log] [blame]
Filip Pytlounda2a0792015-10-06 16:28:31 +02001{%- from "cinder/map.jinja" import controller with context %}
Simon Pasquier479462d2016-11-28 13:09:44 +01002{%- if controller.get('enabled', False) %}
Filip Pytlounda2a0792015-10-06 16:28:31 +02003
4include:
5- cinder.user
6
7cinder_controller_packages:
8 pkg.installed:
9 - names: {{ controller.pkgs }}
10
11/etc/cinder/cinder.conf:
12 file.managed:
13 - source: salt://cinder/files/{{ controller.version }}/cinder.conf.controller.{{ grains.os_family }}
14 - template: jinja
15 - require:
16 - pkg: cinder_controller_packages
17
18/etc/cinder/api-paste.ini:
19 file.managed:
20 - source: salt://cinder/files/{{ controller.version }}/api-paste.ini.controller.{{ grains.os_family }}
21 - template: jinja
22 - require:
23 - pkg: cinder_controller_packages
24
Jakub Pavlik681ffcd2016-05-26 15:19:53 +020025{%- if grains.get('virtual_subtype', None) == "Docker" %}
26
27cinder_entrypoint:
28 file.managed:
29 - name: /entrypoint.sh
30 - template: jinja
31 - source: salt://cinder/files/entrypoint.sh
32 - mode: 755
33
34{%- endif %}
35
36{%- if not grains.get('noservices', False) %}
37
Filip Pytlounda2a0792015-10-06 16:28:31 +020038cinder_controller_services:
39 service.running:
40 - names: {{ controller.services }}
41 - enable: true
42 - watch:
43 - file: /etc/cinder/cinder.conf
44 - file: /etc/cinder/api-paste.ini
45
46cinder_syncdb:
47 cmd.run:
48 - name: cinder-manage db sync
49 - require:
50 - service: cinder_controller_services
51
Ales Komarekfe9bbc62016-01-05 21:38:48 +010052{# new way #}
53
54{%- for backend_name, backend in controller.get('backend', {}).iteritems() %}
55
Jiri Broulik88548db2017-03-31 12:21:37 +020056{%- if backend.engine is defined and backend.engine == 'nfs' %}
Jiri Broulik9e3788d2017-04-06 18:52:54 +020057/etc/cinder/nfs_shares_{{ backend_name }}:
Jiri Broulik88548db2017-03-31 12:21:37 +020058 file.managed:
59 - source: salt://cinder/files/{{ controller.version }}/nfs_shares
60 - defaults:
61 backend: {{ backend|yaml }}
62 - template: jinja
63 - require:
64 - pkg: cinder_controller_packages
65
66{%- endif %}
67
Ales Komarekfe9bbc62016-01-05 21:38:48 +010068cinder_type_create_{{ backend_name }}:
69 cmd.run:
Jakub Pavlikedd46102016-01-08 16:20:38 +010070 - name: "source /root/keystonerc; cinder type-create {{ backend.type_name }}"
71 - unless: "source /root/keystonerc; cinder type-list | grep {{ backend.type_name }}"
Simon Pasquier822bb4d2016-11-28 13:26:12 +010072 - shell: /bin/bash
Ales Komarekfe9bbc62016-01-05 21:38:48 +010073 - require:
74 - service: cinder_controller_services
75
76cinder_type_update_{{ backend_name }}:
77 cmd.run:
Jakub Pavlikedd46102016-01-08 16:20:38 +010078 - name: "source /root/keystonerc; cinder type-key {{ backend.type_name }} set volume_backend_name={{ backend_name }}"
79 - unless: "source /root/keystonerc; cinder extra-specs-list | grep \"{u'volume_backend_name': u'{{ backend_name }}'}\""
Simon Pasquier822bb4d2016-11-28 13:26:12 +010080 - shell: /bin/bash
Ales Komarekfe9bbc62016-01-05 21:38:48 +010081 - require:
82 - cmd: cinder_type_create_{{ backend_name }}
83
84{%- endfor %}
85
Jakub Pavlik681ffcd2016-05-26 15:19:53 +020086{%- endif %}
87
Ales Komarekfe9bbc62016-01-05 21:38:48 +010088{# old way #}
89
Filip Pytlounda2a0792015-10-06 16:28:31 +020090{% for type in controller.get('types', []) %}
91
92cinder_type_create_{{ type.name }}:
93 cmd.run:
94 - name: "source /root/keystonerc; cinder type-create {{ type.name }}"
95 - unless: "source /root/keystonerc; cinder type-list | grep {{ type.name }}"
Simon Pasquier822bb4d2016-11-28 13:26:12 +010096 - shell: /bin/bash
Filip Pytlounda2a0792015-10-06 16:28:31 +020097 - require:
98 - service: cinder_controller_services
99
100cinder_type_update_{{ type.name }}:
101 cmd.run:
102 - name: "source /root/keystonerc; cinder type-key {{ type.name }} set volume_backend_name={{ type.get('backend', type.name) }}"
103 - unless: "source /root/keystonerc; cinder extra-specs-list | grep \"{u'volume_backend_name': u'{{ type.get('backend', type.name) }}'}\""
Simon Pasquier822bb4d2016-11-28 13:26:12 +0100104 - shell: /bin/bash
Filip Pytlounda2a0792015-10-06 16:28:31 +0200105 - require:
106 - cmd: cinder_type_create_{{ type.name }}
107
108{% endfor %}
109
Jiri Broulik88548db2017-03-31 12:21:37 +0200110{%- endif %}