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