Merge "Create mysql user for non-ha deployments" into stable/pike
[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
49 resources:
50
51   ContainersCommon:
52     type: ./containers-common.yaml
53
54   MySQLClient:
55     type: ../../puppet/services/database/mysql-client.yaml
56
57   CinderBase:
58     type: ../../puppet/services/cinder-volume.yaml
59     properties:
60       EndpointMap: {get_param: EndpointMap}
61       ServiceData: {get_param: ServiceData}
62       ServiceNetMap: {get_param: ServiceNetMap}
63       DefaultPasswords: {get_param: DefaultPasswords}
64       RoleName: {get_param: RoleName}
65       RoleParameters: {get_param: RoleParameters}
66
67 outputs:
68   role_data:
69     description: Role data for the Cinder Volume role.
70     value:
71       service_name: {get_attr: [CinderBase, role_data, service_name]}
72       config_settings:
73         map_merge:
74           - get_attr: [CinderBase, role_data, config_settings]
75           - tripleo::profile::base::lvm::enable_udev: false
76       logging_source: {get_attr: [CinderBase, role_data, logging_source]}
77       logging_groups: {get_attr: [CinderBase, role_data, logging_groups]}
78       step_config: &step_config
79         list_join:
80           - "\n"
81           - - "include ::tripleo::profile::base::lvm"
82             - get_attr: [CinderBase, role_data, step_config]
83             - get_attr: [MySQLClient, role_data, step_config]
84       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
85       # BEGIN DOCKER SETTINGS
86       puppet_config:
87         config_volume: cinder
88         puppet_tags: cinder_config,file,concat,file_line
89         step_config: *step_config
90         config_image: {get_param: DockerCinderConfigImage}
91       kolla_config:
92         /var/lib/kolla/config_files/cinder_volume.json:
93           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
94           config_files:
95             - source: "/var/lib/kolla/config_files/src/*"
96               dest: "/"
97               merge: true
98               preserve_properties: true
99             - source: "/var/lib/kolla/config_files/src-ceph/"
100               dest: "/etc/ceph/"
101               merge: true
102               preserve_properties: true
103             - source: "/var/lib/kolla/config_files/src-iscsid/*"
104               dest: "/"
105               merge: true
106               preserve_properties: true
107           permissions:
108             - path: /var/log/cinder
109               owner: cinder:cinder
110               recurse: true
111       docker_config:
112         step_3:
113           cinder_volume_init_logs:
114             start_order: 0
115             image: &cinder_volume_image {get_param: DockerCinderVolumeImage}
116             privileged: false
117             user: root
118             volumes:
119               - /var/log/containers/cinder:/var/log/cinder
120             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
121         step_4:
122           cinder_volume:
123             image: *cinder_volume_image
124             net: host
125             privileged: true
126             restart: always
127             volumes:
128               list_concat:
129                 - {get_attr: [ContainersCommon, volumes]}
130                 -
131                   - /var/lib/kolla/config_files/cinder_volume.json:/var/lib/kolla/config_files/config.json:ro
132                   - /var/lib/config-data/puppet-generated/cinder/:/var/lib/kolla/config_files/src:ro
133                   - /var/lib/config-data/puppet-generated/iscsid/:/var/lib/kolla/config_files/src-iscsid:ro
134                   - /etc/ceph:/var/lib/kolla/config_files/src-ceph:ro
135                   - /lib/modules:/lib/modules:ro
136                   - /dev/:/dev/
137                   - /run/:/run/
138                   - /sys:/sys
139                   - /var/lib/cinder:/var/lib/cinder
140                   - /var/log/containers/cinder:/var/log/cinder
141             environment:
142               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
143       host_prep_tasks:
144         - name: create persistent directories
145           file:
146             path: "{{ item }}"
147             state: directory
148           with_items:
149             - /var/log/containers/cinder
150             - /var/lib/cinder
151         - name: ensure ceph configurations exist
152           file:
153             path: /etc/ceph
154             state: directory
155         - name: cinder_enable_iscsi_backend fact
156           set_fact:
157             cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend}
158         - name: cinder create LVM volume group dd
159           command:
160             list_join:
161             - ''
162             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
163               - str_replace:
164                   template: VALUE
165                   params:
166                     VALUE: {get_param: CinderLVMLoopDeviceSize}
167               - 'M'
168           args:
169             creates: /var/lib/cinder/cinder-volumes
170           when: cinder_enable_iscsi_backend
171         - name: cinder create LVM volume group
172           shell: |
173             if ! losetup /dev/loop2; then
174               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
175             fi
176             if ! pvdisplay | grep cinder-volumes; then
177               pvcreate /dev/loop2
178             fi
179             if ! vgdisplay | grep cinder-volumes; then
180               vgcreate cinder-volumes /dev/loop2
181             fi
182           args:
183             executable: /bin/bash
184             creates: /dev/loop2
185           when: cinder_enable_iscsi_backend
186       upgrade_tasks:
187         - name: Stop and disable cinder_volume service
188           tags: step2
189           service: name=openstack-cinder-volume state=stopped enabled=no