Merge "Modify PreNetworkConfig config inline with role-specific parameters"
[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   # we configure all cinder services in the same cinder base container
16   DockerCinderConfigImage:
17     description: image
18     default: 'centos-binary-cinder-api:latest'
19     type: string
20   EndpointMap:
21     default: {}
22     description: Mapping of service endpoint -> protocol. Typically set
23                  via parameter_defaults in the resource registry.
24     type: json
25   ServiceNetMap:
26     default: {}
27     description: Mapping of service_name -> network name. Typically set
28                  via parameter_defaults in the resource registry.  This
29                  mapping overrides those in ServiceNetMapDefaults.
30     type: json
31   DefaultPasswords:
32     default: {}
33     type: json
34   RoleName:
35     default: ''
36     description: Role name on which the service is applied
37     type: string
38   RoleParameters:
39     default: {}
40     description: Parameters specific to the role
41     type: json
42   # custom parameters for the Cinder volume role
43   CinderEnableIscsiBackend:
44     default: true
45     description: Whether to enable or not the Iscsi backend for Cinder
46     type: boolean
47   CinderLVMLoopDeviceSize:
48     default: 10280
49     description: The size of the loopback file used by the cinder LVM driver.
50     type: number
51
52 resources:
53
54   ContainersCommon:
55     type: ./containers-common.yaml
56
57   CinderBase:
58     type: ../../puppet/services/cinder-volume.yaml
59     properties:
60       EndpointMap: {get_param: EndpointMap}
61       ServiceNetMap: {get_param: ServiceNetMap}
62       DefaultPasswords: {get_param: DefaultPasswords}
63       RoleName: {get_param: RoleName}
64       RoleParameters: {get_param: RoleParameters}
65
66 outputs:
67   role_data:
68     description: Role data for the Cinder Volume role.
69     value:
70       service_name: {get_attr: [CinderBase, role_data, service_name]}
71       config_settings: {get_attr: [CinderBase, role_data, config_settings]}
72       step_config: &step_config
73         get_attr: [CinderBase, role_data, step_config]
74       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
75       # BEGIN DOCKER SETTINGS
76       puppet_config:
77         config_volume: cinder
78         puppet_tags: cinder_config,file,concat,file_line
79         step_config: *step_config
80         config_image:
81           list_join:
82             - '/'
83             - [ {get_param: DockerNamespace}, {get_param: DockerCinderConfigImage} ]
84       kolla_config:
85         /var/lib/kolla/config_files/cinder_volume.json:
86           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
87           permissions:
88             - path: /var/log/cinder
89               owner: cinder:cinder
90               recurse: true
91       docker_config:
92         step_3:
93           cinder_volume_init_logs:
94             start_order: 0
95             image: &cinder_volume_image
96               list_join:
97                 - '/'
98                 - [ {get_param: DockerNamespace}, {get_param: DockerCinderVolumeImage} ]
99             privileged: false
100             user: root
101             volumes:
102               - /var/log/containers/cinder:/var/log/cinder
103             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
104         step_4:
105           cinder_volume:
106             image: *cinder_volume_image
107             net: host
108             privileged: true
109             restart: always
110             volumes:
111               list_concat:
112                 - {get_attr: [ContainersCommon, volumes]}
113                 -
114                   - /var/lib/kolla/config_files/cinder_volume.json:/var/lib/kolla/config_files/config.json:ro
115                   - /var/lib/config-data/cinder/etc/cinder/:/etc/cinder/:ro
116                   - /var/lib/config-data/ceph/etc/ceph/:/etc/ceph/:ro #FIXME: we need to generate a ceph.conf with puppet for this
117                   - /dev/:/dev/
118                   - /run/:/run/
119                   - /sys:/sys
120                   - /etc/iscsi:/etc/iscsi
121                   - /var/lib/cinder:/var/lib/cinder
122                   - /var/log/containers/cinder:/var/log/cinder
123             environment:
124               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
125       host_prep_tasks:
126         - name: create persistent directories
127           file:
128             path: "{{ item }}"
129             state: directory
130           with_items:
131             - /var/log/containers/cinder
132             - /var/lib/cinder
133         #FIXME: all of this should be conditional on the CinderEnableIscsiBackend value being set to true
134         - name: cinder create LVM volume group dd
135           command:
136             list_join: 
137             - ''
138             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
139               - str_replace:
140                   template: VALUE
141                   params:
142                     VALUE: {get_param: CinderLVMLoopDeviceSize}
143               - 'M'
144           args:
145             creates: /var/lib/cinder/cinder-volumes
146         - name: cinder create LVM volume group
147           shell: |
148             if ! losetup /dev/loop2; then
149               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
150             fi
151             if ! pvdisplay | grep cinder-volumes; then
152               pvcreate /dev/loop2
153             fi
154             if ! vgdisplay | grep cinder-volumes; then
155               vgcreate cinder-volumes /dev/loop2
156             fi
157           args:
158             executable: /bin/bash
159             creates: /dev/loop2
160       upgrade_tasks:
161         - name: Stop and disable cinder_volume service
162           tags: step2
163           service: name=openstack-cinder-volume state=stopped enabled=no