Use a single configuration file for specifying docker containers.
[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   ServiceNetMap:
19     default: {}
20     description: Mapping of service_name -> network name. Typically set
21                  via parameter_defaults in the resource registry.  This
22                  mapping overrides those in ServiceNetMapDefaults.
23     type: json
24   DefaultPasswords:
25     default: {}
26     type: json
27   RoleName:
28     default: ''
29     description: Role name on which the service is applied
30     type: string
31   RoleParameters:
32     default: {}
33     description: Parameters specific to the role
34     type: json
35   # custom parameters for the Cinder volume role
36   CinderEnableIscsiBackend:
37     default: true
38     description: Whether to enable or not the Iscsi backend for Cinder
39     type: boolean
40   CinderLVMLoopDeviceSize:
41     default: 10280
42     description: The size of the loopback file used by the cinder LVM driver.
43     type: number
44
45 resources:
46
47   ContainersCommon:
48     type: ./containers-common.yaml
49
50   CinderBase:
51     type: ../../puppet/services/cinder-volume.yaml
52     properties:
53       EndpointMap: {get_param: EndpointMap}
54       ServiceNetMap: {get_param: ServiceNetMap}
55       DefaultPasswords: {get_param: DefaultPasswords}
56       RoleName: {get_param: RoleName}
57       RoleParameters: {get_param: RoleParameters}
58
59 outputs:
60   role_data:
61     description: Role data for the Cinder Volume role.
62     value:
63       service_name: {get_attr: [CinderBase, role_data, service_name]}
64       config_settings: {get_attr: [CinderBase, role_data, config_settings]}
65       step_config: &step_config
66         get_attr: [CinderBase, role_data, step_config]
67       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
68       # BEGIN DOCKER SETTINGS
69       puppet_config:
70         config_volume: cinder
71         puppet_tags: cinder_config,file,concat,file_line
72         step_config: *step_config
73         config_image: {get_param: DockerCinderConfigImage}
74       kolla_config:
75         /var/lib/kolla/config_files/cinder_volume.json:
76           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
77           config_files:
78             # NOTE(mandre): the copy of ceph conf will need to go once we
79             # generate a ceph.conf for cinder in puppet
80             # Copy ceph config files before cinder ones as a precaution, for
81             # the later one to take precendence in case of duplicate files.
82             - source: "/var/lib/kolla/config_files/src-ceph/*"
83               dest: "/"
84               merge: true
85               preserve_properties: true
86             - source: "/var/lib/kolla/config_files/src/*"
87               dest: "/"
88               merge: true
89               preserve_properties: true
90           permissions:
91             - path: /var/log/cinder
92               owner: cinder:cinder
93               recurse: true
94       docker_config:
95         step_3:
96           cinder_volume_init_logs:
97             start_order: 0
98             image: &cinder_volume_image {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/puppet-generated/cinder/:/var/lib/kolla/config_files/src:ro
116                   # FIXME: we need to generate a ceph.conf with puppet for this
117                   - /var/lib/config-data/puppet-generated/ceph/:/var/lib/kolla/config_files/src-ceph:ro
118                   - /dev/:/dev/
119                   - /run/:/run/
120                   - /sys:/sys
121                   - /etc/iscsi:/etc/iscsi
122                   - /var/lib/cinder:/var/lib/cinder
123                   - /var/log/containers/cinder:/var/log/cinder
124             environment:
125               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
126       host_prep_tasks:
127         - name: create persistent directories
128           file:
129             path: "{{ item }}"
130             state: directory
131           with_items:
132             - /var/log/containers/cinder
133             - /var/lib/cinder
134         - name: cinder_enable_iscsi_backend fact
135           set_fact:
136             cinder_enable_iscsi_backend: {get_param: CinderEnableIscsiBackend}
137         - name: cinder create LVM volume group dd
138           command:
139             list_join:
140             - ''
141             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
142               - str_replace:
143                   template: VALUE
144                   params:
145                     VALUE: {get_param: CinderLVMLoopDeviceSize}
146               - 'M'
147           args:
148             creates: /var/lib/cinder/cinder-volumes
149           when: cinder_enable_iscsi_backend
150         - name: cinder create LVM volume group
151           shell: |
152             if ! losetup /dev/loop2; then
153               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
154             fi
155             if ! pvdisplay | grep cinder-volumes; then
156               pvcreate /dev/loop2
157             fi
158             if ! vgdisplay | grep cinder-volumes; then
159               vgcreate cinder-volumes /dev/loop2
160             fi
161           args:
162             executable: /bin/bash
163             creates: /dev/loop2
164           when: cinder_enable_iscsi_backend
165       upgrade_tasks:
166         - name: Stop and disable cinder_volume service
167           tags: step2
168           service: name=openstack-cinder-volume state=stopped enabled=no