Use a single configuration file for specifying docker containers.
[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   ServiceNetMap:
19     default: {}
20     description: Mapping of service_name -> network name. Typically set
21                  via parameter_defaults in the resource registry.  This
22                  mapping overrides those in ServiceNetMapDefaults.
23     type: json
24   DefaultPasswords:
25     default: {}
26     type: json
27   RoleName:
28     default: ''
29     description: Role name on which the service is applied
30     type: string
31   RoleParameters:
32     default: {}
33     description: Parameters specific to the role
34     type: json
35   # custom parameters for the Cinder volume role
36   CinderEnableIscsiBackend:
37     default: true
38     description: Whether to enable or not the Iscsi backend for Cinder
39     type: boolean
40   CinderLVMLoopDeviceSize:
41     default: 10280
42     description: The size of the loopback file used by the cinder LVM driver.
43     type: number
44
45 resources:
46
47   CinderBase:
48     type: ../../../puppet/services/cinder-volume.yaml
49     properties:
50       EndpointMap: {get_param: EndpointMap}
51       ServiceNetMap: {get_param: ServiceNetMap}
52       DefaultPasswords: {get_param: DefaultPasswords}
53       RoleName: {get_param: RoleName}
54       RoleParameters: {get_param: RoleParameters}
55
56 outputs:
57   role_data:
58     description: Role data for the Cinder Volume role.
59     value:
60       service_name: {get_attr: [CinderBase, role_data, service_name]}
61       config_settings:
62         map_merge:
63           - get_attr: [CinderBase, role_data, config_settings]
64           - tripleo::profile::pacemaker::cinder::volume_bundle::cinder_volume_docker_image: &cinder_volume_image {get_param: DockerCinderVolumeImage}
65             cinder::volume::manage_service: false
66             cinder::volume::enabled: false
67             cinder::host: hostgroup
68       step_config: ""
69       service_config_settings: {get_attr: [CinderBase, role_data, service_config_settings]}
70       # BEGIN DOCKER SETTINGS
71       puppet_config:
72         config_volume: cinder
73         puppet_tags: cinder_config,file,concat,file_line
74         step_config: {get_attr: [CinderBase, role_data, step_config]}
75         config_image: {get_param: DockerCinderConfigImage}
76       kolla_config:
77         /var/lib/kolla/config_files/cinder_volume.json:
78           command: /usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
79           permissions:
80             - path: /var/log/cinder
81               owner: cinder:cinder
82               recurse: true
83       docker_config:
84         step_3:
85           cinder_volume_init_logs:
86             start_order: 0
87             image: *cinder_volume_image
88             privileged: false
89             user: root
90             volumes:
91               - /var/log/containers/cinder:/var/log/cinder
92             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
93         step_5:
94           cinder_volume_init_bundle:
95             start_order: 0
96             detach: false
97             net: host
98             user: root
99             command:
100               - '/bin/bash'
101               - '-c'
102               - str_replace:
103                   template:
104                     list_join:
105                       - '; '
106                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 5}' > /etc/puppet/hieradata/docker.json"
107                         - "FACTER_uuid=docker puppet apply --tags file_line,concat,augeas,TAGS --debug -v -e 'CONFIG'"
108                   params:
109                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::constraint::location'
110                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::cinder::volume_bundle'
111             image: *cinder_volume_image
112             volumes:
113               - /etc/hosts:/etc/hosts:ro
114               - /etc/localtime:/etc/localtime:ro
115               - /etc/puppet:/tmp/puppet-etc:ro
116               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
117               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
118               - /dev/shm:/dev/shm:rw
119       host_prep_tasks:
120         - name: create persistent directories
121           file:
122             path: "{{ item }}"
123             state: directory
124           with_items:
125             - /var/log/containers/cinder
126             - /var/lib/cinder
127         #FIXME: all of this should be conditional on the CinderEnableIscsiBackend value being set to true
128         - name: cinder create LVM volume group dd
129           command:
130             list_join:
131             - ''
132             - - 'dd if=/dev/zero of=/var/lib/cinder/cinder-volumes bs=1 count=0 seek='
133               - str_replace:
134                   template: VALUE
135                   params:
136                     VALUE: {get_param: CinderLVMLoopDeviceSize}
137               - 'M'
138           args:
139             creates: /var/lib/cinder/cinder-volumes
140         - name: cinder create LVM volume group
141           shell: |
142             if ! losetup /dev/loop2; then
143               losetup /dev/loop2 /var/lib/cinder/cinder-volumes
144             fi
145             if ! pvdisplay | grep cinder-volumes; then
146               pvcreate /dev/loop2
147             fi
148             if ! vgdisplay | grep cinder-volumes; then
149               vgcreate cinder-volumes /dev/loop2
150             fi
151           args:
152             executable: /bin/bash
153             creates: /dev/loop2
154       upgrade_tasks:
155         - name: Stop and disable cinder_volume service
156           tags: step2
157           service: name=openstack-cinder-volume state=stopped enabled=no