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