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