210ab4c9db926c5b25d53d16efb92a70dbfc8fea
[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   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerCinderVolumeImage:
12     description: image
13     default: 'centos-binary-cinder-volume:latest'
14     type: string
15   DockerCinderConfigImage:
16     description: The container image to use for the cinder config_volume
17     default: 'centos-binary-cinder-api:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceData:
25     default: {}
26     description: Dictionary packing service data
27     type: json
28   ServiceNetMap:
29     default: {}
30     description: Mapping of service_name -> network name. Typically set
31                  via parameter_defaults in the resource registry.  This
32                  mapping overrides those in ServiceNetMapDefaults.
33     type: json
34   DefaultPasswords:
35     default: {}
36     type: json
37   RoleName:
38     default: ''
39     description: Role name on which the service is applied
40     type: string
41   RoleParameters:
42     default: {}
43     description: Parameters specific to the role
44     type: json
45   # custom parameters for the Cinder volume role
46   CinderEnableIscsiBackend:
47     default: true
48     description: Whether to enable or not the Iscsi backend for Cinder
49     type: boolean
50   CinderLVMLoopDeviceSize:
51     default: 10280
52     description: The size of the loopback file used by the cinder LVM driver.
53     type: number
54
55 resources:
56
57   ContainersCommon:
58     type: ./containers-common.yaml
59
60   CinderBase:
61     type: ../../puppet/services/cinder-volume.yaml
62     properties:
63       EndpointMap: {get_param: EndpointMap}
64       ServiceData: {get_param: ServiceData}
65       ServiceNetMap: {get_param: ServiceNetMap}
66       DefaultPasswords: {get_param: DefaultPasswords}
67       RoleName: {get_param: RoleName}
68       RoleParameters: {get_param: RoleParameters}
69
70 outputs:
71   role_data:
72     description: Role data for the Cinder Volume role.
73     value:
74       service_name: {get_attr: [CinderBase, role_data, service_name]}
75       config_settings: {get_attr: [CinderBase, role_data, config_settings]}
76       step_config: &step_config
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:
85           list_join:
86             - '/'
87             - [ {get_param: DockerNamespace}, {get_param: DockerCinderConfigImage} ]
88       kolla_config:
89         /var/lib/kolla/config_files/cinder_volume.json:
90           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
91           config_files:
92             # NOTE(mandre): the copy of ceph conf will need to go once we
93             # generate a ceph.conf for cinder in puppet
94             # Copy ceph config files before cinder ones as a precaution, for
95             # the later one to take precendence in case of duplicate files.
96             - source: "/var/lib/kolla/config_files/src-ceph/*"
97               dest: "/"
98               merge: true
99               preserve_properties: true
100             - source: "/var/lib/kolla/config_files/src/*"
101               dest: "/"
102               merge: true
103               preserve_properties: true
104           permissions:
105             - path: /var/log/cinder
106               owner: cinder:cinder
107               recurse: true
108       docker_config:
109         step_3:
110           cinder_volume_init_logs:
111             start_order: 0
112             image: &cinder_volume_image
113               list_join:
114                 - '/'
115                 - [ {get_param: DockerNamespace}, {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                   # FIXME: we need to generate a ceph.conf with puppet for this
134                   - /var/lib/config-data/puppet-generated/ceph/:/var/lib/kolla/config_files/src-ceph:ro
135                   - /dev/:/dev/
136                   - /run/:/run/
137                   - /sys:/sys
138                   - /etc/iscsi:/etc/iscsi
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: cinder_enable_iscsi_backend fact
152           set_fact:
153             cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend}
154         - name: cinder create LVM volume group dd
155           command:
156             list_join:
157             - ''
158             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
159               - str_replace:
160                   template: VALUE
161                   params:
162                     VALUE: {get_param: CinderLVMLoopDeviceSize}
163               - 'M'
164           args:
165             creates: /var/lib/cinder/cinder-volumes
166           when: cinder_enable_iscsi_backend
167         - name: cinder create LVM volume group
168           shell: |
169             if ! losetup /dev/loop2; then
170               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
171             fi
172             if ! pvdisplay | grep cinder-volumes; then
173               pvcreate /dev/loop2
174             fi
175             if ! vgdisplay | grep cinder-volumes; then
176               vgcreate cinder-volumes /dev/loop2
177             fi
178           args:
179             executable: /bin/bash
180             creates: /dev/loop2
181           when: cinder_enable_iscsi_backend
182       upgrade_tasks:
183         - name: Stop and disable cinder_volume service
184           tags: step2
185           service: name=openstack-cinder-volume state=stopped enabled=no