docker: add logging(source & groups)
[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   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   MySQLClient:
52     type: ../../../puppet/services/database/mysql-client.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:
70         map_merge:
71           - get_attr: [CinderBase, role_data, config_settings]
72           - tripleo::profile::pacemaker::cinder::volume_bundle::cinder_volume_docker_image: &cinder_volume_image_pcmklatest
73               list_join:
74                 - ':'
75                 - - yaql:
76                       data: {get_param: DockerCinderVolumeImage}
77                       expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
78                   - 'pcmklatest'
79             cinder::volume::manage_service: false
80             cinder::volume::enabled: false
81             cinder::host: hostgroup
82       logging_source: {get_attr: [CinderBase, role_data, logging_source]}
83       logging_groups: {get_attr: [CinderBase, role_data, logging_groups]}
84       step_config: ""
85       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
86       # BEGIN DOCKER SETTINGS
87       puppet_config:
88         config_volume: cinder
89         puppet_tags: cinder_config,file,concat,file_line
90         step_config:
91           list_join:
92             - "\n"
93             - - {get_attr: [CinderBase, role_data, step_config]}
94               - {get_attr: [MySQLClient, role_data, step_config]}
95         config_image: {get_param: DockerCinderConfigImage}
96       kolla_config:
97         /var/lib/kolla/config_files/cinder_volume.json:
98           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
99           permissions:
100             - path: /var/log/cinder
101               owner: cinder:cinder
102               recurse: true
103       docker_config:
104         step_1:
105           cinder_volume_image_tag:
106             start_order: 1
107             detach: false
108             net: host
109             user: root
110             command:
111               - '/bin/bash'
112               - '-c'
113               - str_replace:
114                   template:
115                     "/usr/bin/docker tag 'CINDERVOLUME_IMAGE' 'CINDERVOLUME_IMAGE_PCMKLATEST'"
116                   params:
117                     CINDERVOLUME_IMAGE: {get_param: DockerCinderVolumeImage}
118                     CINDERVOLUME_IMAGE_PCMKLATEST: *cinder_volume_image_pcmklatest
119             image: {get_param: DockerCinderVolumeImage}
120             volumes:
121               - /etc/hosts:/etc/hosts:ro
122               - /etc/localtime:/etc/localtime:ro
123               - /dev/shm:/dev/shm:rw
124               - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
125               - /usr/bin:/usr/bin:ro
126               - /var/run/docker.sock:/var/run/docker.sock:rw
127         step_3:
128           cinder_volume_init_logs:
129             start_order: 0
130             image: {get_param: DockerCinderVolumeImage}
131             privileged: false
132             user: root
133             volumes:
134               - /var/log/containers/cinder:/var/log/cinder
135             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
136         step_5:
137           cinder_volume_init_bundle:
138             start_order: 0
139             detach: false
140             net: host
141             user: root
142             command:
143               - '/bin/bash'
144               - '-c'
145               - str_replace:
146                   template:
147                     list_join:
148                       - '; '
149                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 5}' > /etc/puppet/hieradata/docker.json"
150                         - "FACTER_uuid=docker puppet apply --tags file_line,concat,augeas,TAGS --debug -v -e 'CONFIG'"
151                   params:
152                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::constraint::location'
153                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::cinder::volume_bundle'
154             image: {get_param: DockerCinderVolumeImage}
155             volumes:
156               - /etc/hosts:/etc/hosts:ro
157               - /etc/localtime:/etc/localtime:ro
158               - /etc/puppet:/tmp/puppet-etc:ro
159               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
160               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
161               - /dev/shm:/dev/shm:rw
162       host_prep_tasks:
163         - name: create persistent directories
164           file:
165             path: "{{ item }}"
166             state: directory
167           with_items:
168             - /var/log/containers/cinder
169             - /var/lib/cinder
170         #FIXME: all of this should be conditional on the CinderEnableIscsiBackend value being set to true
171         - name: cinder create LVM volume group dd
172           command:
173             list_join:
174             - ''
175             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
176               - str_replace:
177                   template: VALUE
178                   params:
179                     VALUE: {get_param: CinderLVMLoopDeviceSize}
180               - 'M'
181           args:
182             creates: /var/lib/cinder/cinder-volumes
183         - name: cinder create LVM volume group
184           shell: |
185             if ! losetup /dev/loop2; then
186               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
187             fi
188             if ! pvdisplay | grep cinder-volumes; then
189               pvcreate /dev/loop2
190             fi
191             if ! vgdisplay | grep cinder-volumes; then
192               vgcreate cinder-volumes /dev/loop2
193             fi
194           args:
195             executable: /bin/bash
196             creates: /dev/loop2
197       upgrade_tasks:
198         - name: get bootstrap nodeid
199           tags: common
200           command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
201           register: bootstrap_node
202         - name: set is_bootstrap_node fact
203           tags: common
204           set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
205         - name: Disable the openstack-cinder-volume cluster resource
206           tags: step2
207           pacemaker_resource:
208             resource: openstack-cinder-volume
209             state: disable
210             wait_for_resource: true
211           register: output
212           retries: 5
213           until: output.rc == 0
214           when: is_bootstrap_node
215         - name: Delete the stopped openstack-cinder-volume cluster resource.
216           tags: step2
217           pacemaker_resource:
218             resource: openstack-cinder-volume
219             state: delete
220             wait_for_resource: true
221           register: output
222           retries: 5
223           until: output.rc == 0
224           when: is_bootstrap_node
225         - name: Disable cinder_volume service from boot
226           tags: step2
227           service: name=openstack-cinder-volume enabled=no
228
229
230