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