Fix rights to local_settings.d for dockerized Horizon
[apex-tripleo-heat-templates.git] / docker / services / cinder-volume.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Cinder Volume service
5
6 parameters:
7   DockerCinderVolumeImage:
8     description: image
9     type: string
10   DockerCinderConfigImage:
11     description: The container image to use for the cinder config_volume
12     type: string
13   EndpointMap:
14     default: {}
15     description: Mapping of service endpoint -> protocol. Typically set
16                  via parameter_defaults in the resource registry.
17     type: json
18   ServiceData:
19     default: {}
20     description: Dictionary packing service data
21     type: json
22   ServiceNetMap:
23     default: {}
24     description: Mapping of service_name -> network name. Typically set
25                  via parameter_defaults in the resource registry.  This
26                  mapping overrides those in ServiceNetMapDefaults.
27     type: json
28   DefaultPasswords:
29     default: {}
30     type: json
31   RoleName:
32     default: ''
33     description: Role name on which the service is applied
34     type: string
35   RoleParameters:
36     default: {}
37     description: Parameters specific to the role
38     type: json
39   # custom parameters for the Cinder volume role
40   CinderEnableIscsiBackend:
41     default: true
42     description: Whether to enable or not the Iscsi backend for Cinder
43     type: boolean
44   CinderLVMLoopDeviceSize:
45     default: 10280
46     description: The size of the loopback file used by the cinder LVM driver.
47     type: number
48   UpgradeRemoveUnusedPackages:
49     default: false
50     description: Remove package if the service is being disabled during upgrade
51     type: boolean
52
53 resources:
54
55   ContainersCommon:
56     type: ./containers-common.yaml
57
58   MySQLClient:
59     type: ../../puppet/services/database/mysql-client.yaml
60
61   CinderBase:
62     type: ../../puppet/services/cinder-volume.yaml
63     properties:
64       EndpointMap: {get_param: EndpointMap}
65       ServiceData: {get_param: ServiceData}
66       ServiceNetMap: {get_param: ServiceNetMap}
67       DefaultPasswords: {get_param: DefaultPasswords}
68       RoleName: {get_param: RoleName}
69       RoleParameters: {get_param: RoleParameters}
70
71 outputs:
72   role_data:
73     description: Role data for the Cinder Volume role.
74     value:
75       service_name: {get_attr: [CinderBase, role_data, service_name]}
76       config_settings:
77         map_merge:
78           - get_attr: [CinderBase, role_data, config_settings]
79           - tripleo::profile::base::lvm::enable_udev: false
80       logging_source: {get_attr: [CinderBase, role_data, logging_source]}
81       logging_groups: {get_attr: [CinderBase, role_data, logging_groups]}
82       step_config: &step_config
83         list_join:
84           - "\n"
85           - - "include ::tripleo::profile::base::lvm"
86             - get_attr: [CinderBase, role_data, step_config]
87             - get_attr: [MySQLClient, role_data, step_config]
88       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
89       # BEGIN DOCKER SETTINGS
90       puppet_config:
91         config_volume: cinder
92         puppet_tags: cinder_config,file,concat,file_line
93         step_config: *step_config
94         config_image: {get_param: DockerCinderConfigImage}
95       kolla_config:
96         /var/lib/kolla/config_files/cinder_volume.json:
97           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
98           config_files:
99             - source: "/var/lib/kolla/config_files/src/*"
100               dest: "/"
101               merge: true
102               preserve_properties: true
103             - source: "/var/lib/kolla/config_files/src-ceph/"
104               dest: "/etc/ceph/"
105               merge: true
106               preserve_properties: true
107             - source: "/var/lib/kolla/config_files/src-iscsid/*"
108               dest: "/"
109               merge: true
110               preserve_properties: true
111           permissions:
112             - path: /var/log/cinder
113               owner: cinder:cinder
114               recurse: true
115       docker_config:
116         step_3:
117           cinder_volume_init_logs:
118             start_order: 0
119             image: &cinder_volume_image {get_param: DockerCinderVolumeImage}
120             privileged: false
121             user: root
122             volumes:
123               - /var/log/containers/cinder:/var/log/cinder
124             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
125         step_4:
126           cinder_volume:
127             image: *cinder_volume_image
128             net: host
129             privileged: true
130             restart: always
131             volumes:
132               list_concat:
133                 - {get_attr: [ContainersCommon, volumes]}
134                 -
135                   - /var/lib/kolla/config_files/cinder_volume.json:/var/lib/kolla/config_files/config.json:ro
136                   - /var/lib/config-data/puppet-generated/cinder/:/var/lib/kolla/config_files/src:ro
137                   - /var/lib/config-data/puppet-generated/iscsid/:/var/lib/kolla/config_files/src-iscsid:ro
138                   - /etc/ceph:/var/lib/kolla/config_files/src-ceph:ro
139                   - /lib/modules:/lib/modules:ro
140                   - /dev/:/dev/
141                   - /run/:/run/
142                   - /sys:/sys
143                   - /var/lib/cinder:/var/lib/cinder
144                   - /var/log/containers/cinder:/var/log/cinder
145             environment:
146               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
147       host_prep_tasks:
148         - name: create persistent directories
149           file:
150             path: "{{ item }}"
151             state: directory
152           with_items:
153             - /var/log/containers/cinder
154             - /var/lib/cinder
155         - name: ensure ceph configurations exist
156           file:
157             path: /etc/ceph
158             state: directory
159         - name: cinder_enable_iscsi_backend fact
160           set_fact:
161             cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend}
162         - name: cinder create LVM volume group dd
163           command:
164             list_join:
165             - ''
166             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
167               - str_replace:
168                   template: VALUE
169                   params:
170                     VALUE: {get_param: CinderLVMLoopDeviceSize}
171               - 'M'
172           args:
173             creates: /var/lib/cinder/cinder-volumes
174           when: cinder_enable_iscsi_backend
175         - name: cinder create LVM volume group
176           shell: |
177             if ! losetup /dev/loop2; then
178               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
179             fi
180             if ! pvdisplay | grep cinder-volumes; then
181               pvcreate /dev/loop2
182             fi
183             if ! vgdisplay | grep cinder-volumes; then
184               vgcreate cinder-volumes /dev/loop2
185             fi
186           args:
187             executable: /bin/bash
188             creates: /dev/loop2
189           when: cinder_enable_iscsi_backend
190       upgrade_tasks:
191         - name: Stop and disable cinder_volume service
192           tags: step2
193           service: name=openstack-cinder-volume state=stopped enabled=no
194         - name: Remove openstack-cinder package if operator requests it
195           yum: name=openstack-cinder state=removed
196           tags: step2
197           ignore_errors: True
198           when: {get_param: UpgradeRemoveUnusedPackages}