Merge "Add os-collect-config data as an output"
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / 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   CinderBase:
55     type: ../../../puppet/services/cinder-volume.yaml
56     properties:
57       EndpointMap: {get_param: EndpointMap}
58       ServiceNetMap: {get_param: ServiceNetMap}
59       DefaultPasswords: {get_param: DefaultPasswords}
60       RoleName: {get_param: RoleName}
61       RoleParameters: {get_param: RoleParameters}
62
63 outputs:
64   role_data:
65     description: Role data for the Cinder Volume role.
66     value:
67       service_name: {get_attr: [CinderBase, role_data, service_name]}
68       config_settings:
69         map_merge:
70           - get_attr: [CinderBase, role_data, config_settings]
71           - tripleo::profile::pacemaker::cinder::volume_bundle::cinder_volume_docker_image: &cinder_volume_image
72               list_join:
73                 - '/'
74                 - [ {get_param: DockerNamespace}, {get_param: DockerCinderVolumeImage} ]
75             cinder::volume::manage_service: false
76             cinder::volume::enabled: false
77             cinder::host: hostgroup
78       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: {get_attr: [CinderBase, role_data, 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           permissions:
93             - path: /var/log/cinder
94               owner: cinder:cinder
95               recurse: true
96       docker_config:
97         step_3:
98           cinder_volume_init_logs:
99             start_order: 0
100             image: *cinder_volume_image
101             privileged: false
102             user: root
103             volumes:
104               - /var/log/containers/cinder:/var/log/cinder
105             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
106         step_5:
107           cinder_volume_init_bundle:
108             start_order: 0
109             detach: false
110             net: host
111             user: root
112             command:
113               - '/bin/bash'
114               - '-c'
115               - str_replace:
116                   template:
117                     list_join:
118                       - '; '
119                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 5}' > /etc/puppet/hieradata/docker.json"
120                         - "FACTER_uuid=docker puppet apply --tags file_line,concat,augeas,TAGS --debug -v -e 'CONFIG'"
121                   params:
122                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::constraint::location'
123                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::cinder::volume_bundle'
124             image: *cinder_volume_image
125             volumes:
126               - /etc/hosts:/etc/hosts:ro
127               - /etc/localtime:/etc/localtime:ro
128               - /etc/puppet:/tmp/puppet-etc:ro
129               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
130               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
131               - /dev/shm:/dev/shm:rw
132       host_prep_tasks:
133         - name: create persistent directories
134           file:
135             path: "{{ item }}"
136             state: directory
137           with_items:
138             - /var/log/containers/cinder
139             - /var/lib/cinder
140         #FIXME: all of this should be conditional on the CinderEnableIscsiBackend value being set to true
141         - name: cinder create LVM volume group dd
142           command:
143             list_join:
144             - ''
145             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
146               - str_replace:
147                   template: VALUE
148                   params:
149                     VALUE: {get_param: CinderLVMLoopDeviceSize}
150               - 'M'
151           args:
152             creates: /var/lib/cinder/cinder-volumes
153         - name: cinder create LVM volume group
154           shell: |
155             if ! losetup /dev/loop2; then
156               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
157             fi
158             if ! pvdisplay | grep cinder-volumes; then
159               pvcreate /dev/loop2
160             fi
161             if ! vgdisplay | grep cinder-volumes; then
162               vgcreate cinder-volumes /dev/loop2
163             fi
164           args:
165             executable: /bin/bash
166             creates: /dev/loop2
167       upgrade_tasks:
168         - name: Stop and disable cinder_volume service
169           tags: step2
170           service: name=openstack-cinder-volume state=stopped enabled=no