Filip Pytloun | da2a079 | 2015-10-06 16:28:31 +0200 | [diff] [blame] | 1 | {%- from "cinder/map.jinja" import controller with context %} |
Simon Pasquier | 479462d | 2016-11-28 13:09:44 +0100 | [diff] [blame] | 2 | {%- if controller.get('enabled', False) %} |
Filip Pytloun | da2a079 | 2015-10-06 16:28:31 +0200 | [diff] [blame] | 3 | |
| 4 | include: |
| 5 | - cinder.user |
| 6 | |
| 7 | cinder_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 Pavlik | 681ffcd | 2016-05-26 15:19:53 +0200 | [diff] [blame] | 25 | {%- if grains.get('virtual_subtype', None) == "Docker" %} |
| 26 | |
| 27 | cinder_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 Pytloun | da2a079 | 2015-10-06 16:28:31 +0200 | [diff] [blame] | 38 | cinder_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 | |
| 46 | cinder_syncdb: |
| 47 | cmd.run: |
| 48 | - name: cinder-manage db sync |
| 49 | - require: |
| 50 | - service: cinder_controller_services |
| 51 | |
Ales Komarek | fe9bbc6 | 2016-01-05 21:38:48 +0100 | [diff] [blame] | 52 | {# new way #} |
| 53 | |
| 54 | {%- for backend_name, backend in controller.get('backend', {}).iteritems() %} |
| 55 | |
Jiri Broulik | 88548db | 2017-03-31 12:21:37 +0200 | [diff] [blame] | 56 | {%- if backend.engine is defined and backend.engine == 'nfs' %} |
Jiri Broulik | 9e3788d | 2017-04-06 18:52:54 +0200 | [diff] [blame^] | 57 | /etc/cinder/nfs_shares_{{ backend_name }}: |
Jiri Broulik | 88548db | 2017-03-31 12:21:37 +0200 | [diff] [blame] | 58 | 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 Komarek | fe9bbc6 | 2016-01-05 21:38:48 +0100 | [diff] [blame] | 68 | cinder_type_create_{{ backend_name }}: |
| 69 | cmd.run: |
Jakub Pavlik | edd4610 | 2016-01-08 16:20:38 +0100 | [diff] [blame] | 70 | - name: "source /root/keystonerc; cinder type-create {{ backend.type_name }}" |
| 71 | - unless: "source /root/keystonerc; cinder type-list | grep {{ backend.type_name }}" |
Simon Pasquier | 822bb4d | 2016-11-28 13:26:12 +0100 | [diff] [blame] | 72 | - shell: /bin/bash |
Ales Komarek | fe9bbc6 | 2016-01-05 21:38:48 +0100 | [diff] [blame] | 73 | - require: |
| 74 | - service: cinder_controller_services |
| 75 | |
| 76 | cinder_type_update_{{ backend_name }}: |
| 77 | cmd.run: |
Jakub Pavlik | edd4610 | 2016-01-08 16:20:38 +0100 | [diff] [blame] | 78 | - 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 Pasquier | 822bb4d | 2016-11-28 13:26:12 +0100 | [diff] [blame] | 80 | - shell: /bin/bash |
Ales Komarek | fe9bbc6 | 2016-01-05 21:38:48 +0100 | [diff] [blame] | 81 | - require: |
| 82 | - cmd: cinder_type_create_{{ backend_name }} |
| 83 | |
| 84 | {%- endfor %} |
| 85 | |
Jakub Pavlik | 681ffcd | 2016-05-26 15:19:53 +0200 | [diff] [blame] | 86 | {%- endif %} |
| 87 | |
Ales Komarek | fe9bbc6 | 2016-01-05 21:38:48 +0100 | [diff] [blame] | 88 | {# old way #} |
| 89 | |
Filip Pytloun | da2a079 | 2015-10-06 16:28:31 +0200 | [diff] [blame] | 90 | {% for type in controller.get('types', []) %} |
| 91 | |
| 92 | cinder_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 Pasquier | 822bb4d | 2016-11-28 13:26:12 +0100 | [diff] [blame] | 96 | - shell: /bin/bash |
Filip Pytloun | da2a079 | 2015-10-06 16:28:31 +0200 | [diff] [blame] | 97 | - require: |
| 98 | - service: cinder_controller_services |
| 99 | |
| 100 | cinder_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 Pasquier | 822bb4d | 2016-11-28 13:26:12 +0100 | [diff] [blame] | 104 | - shell: /bin/bash |
Filip Pytloun | da2a079 | 2015-10-06 16:28:31 +0200 | [diff] [blame] | 105 | - require: |
| 106 | - cmd: cinder_type_create_{{ type.name }} |
| 107 | |
| 108 | {% endfor %} |
| 109 | |
Jiri Broulik | 88548db | 2017-03-31 12:21:37 +0200 | [diff] [blame] | 110 | {%- endif %} |