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