Use haproxy-systemd-wrapper as pid1 in containerized Haproxy
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / cinder-backup.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Cinder Backup service
5
6 parameters:
7   DockerCinderBackupImage:
8     description: image
9     type: string
10   DockerCinderConfigImage:
11     description: The container image to use for the cinder config_volume
12     type: string
13   CinderBackupBackend:
14     default: swift
15     description: The short name of the Cinder Backup backend to use.
16     type: string
17     constraints:
18     - allowed_values: ['swift', 'ceph']
19   CinderBackupRbdPoolName:
20     default: backups
21     type: string
22   CephClientUserName:
23     default: openstack
24     type: string
25   EndpointMap:
26     default: {}
27     description: Mapping of service endpoint -> protocol. Typically set
28                  via parameter_defaults in the resource registry.
29     type: json
30   ServiceData:
31     default: {}
32     description: Dictionary packing service data
33     type: json
34   ServiceNetMap:
35     default: {}
36     description: Mapping of service_name -> network name. Typically set
37                  via parameter_defaults in the resource registry.  This
38                  mapping overrides those in ServiceNetMapDefaults.
39     type: json
40   DefaultPasswords:
41     default: {}
42     type: json
43   RoleName:
44     default: ''
45     description: Role name on which the service is applied
46     type: string
47   RoleParameters:
48     default: {}
49     description: Parameters specific to the role
50     type: json
51
52
53 resources:
54
55   MySQLClient:
56     type: ../../../puppet/services/database/mysql-client.yaml
57
58   CinderBackupBase:
59     type: ../../../puppet/services/cinder-backup.yaml
60     properties:
61       EndpointMap: {get_param: EndpointMap}
62       ServiceData: {get_param: ServiceData}
63       ServiceNetMap: {get_param: ServiceNetMap}
64       DefaultPasswords: {get_param: DefaultPasswords}
65       RoleName: {get_param: RoleName}
66       RoleParameters: {get_param: RoleParameters}
67       CinderBackupBackend: {get_param: CinderBackupBackend}
68       CinderBackupRbdPoolName: {get_param: CinderBackupRbdPoolName}
69       CephClientUserName: {get_param: CephClientUserName}
70
71 outputs:
72   role_data:
73     description: Role data for the Cinder Backup role.
74     value:
75       service_name: {get_attr: [CinderBackupBase, role_data, service_name]}
76       config_settings:
77         map_merge:
78           - get_attr: [CinderBackupBase, role_data, config_settings]
79           - tripleo::profile::pacemaker::cinder::backup_bundle::cinder_backup_docker_image: &cinder_backup_image_pcmklatest
80               list_join:
81                 - ':'
82                 - - yaql:
83                       data: {get_param: DockerCinderBackupImage}
84                       expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
85                   - 'pcmklatest'
86             cinder::backup::manage_service: false
87             cinder::backup::enabled: false
88       step_config: ""
89       service_config_settings: {get_attr: [CinderBackupBase, role_data, service_config_settings]}
90       # BEGIN DOCKER SETTINGS
91       puppet_config:
92         config_volume: cinder
93         puppet_tags: cinder_config,file,concat,file_line
94         step_config:
95           list_join:
96             - "\n"
97             - - {get_attr: [CinderBackupBase, role_data, step_config]}
98               - {get_attr: [MySQLClient, role_data, step_config]}
99         config_image: {get_param: DockerCinderConfigImage}
100       kolla_config:
101         /var/lib/kolla/config_files/cinder_backup.json:
102           command: /usr/bin/cinder-backup --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
103           permissions:
104             - path: /var/lib/cinder
105               owner: cinder:cinder
106               recurse: true
107             - path: /var/log/cinder
108               owner: cinder:cinder
109               recurse: true
110       docker_config:
111         step_1:
112           cinder_backup_image_tag:
113             start_order: 1
114             detach: false
115             net: host
116             user: root
117             command:
118               - '/bin/bash'
119               - '-c'
120               - str_replace:
121                   template:
122                     "/usr/bin/docker tag 'CINDERBACKUP_IMAGE' 'CINDERBACKUP_IMAGE_PCMKLATEST'"
123                   params:
124                     CINDERBACKUP_IMAGE: {get_param: DockerCinderBackupImage}
125                     CINDERBACKUP_IMAGE_PCMKLATEST: *cinder_backup_image_pcmklatest
126             image: {get_param: DockerCinderBackupImage}
127             volumes:
128               - /etc/hosts:/etc/hosts:ro
129               - /etc/localtime:/etc/localtime:ro
130               - /dev/shm:/dev/shm:rw
131               - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
132               - /usr/bin:/usr/bin:ro
133               - /var/run/docker.sock:/var/run/docker.sock:rw
134         step_3:
135           cinder_backup_init_logs:
136             start_order: 0
137             image: {get_param: DockerCinderBackupImage}
138             privileged: false
139             user: root
140             volumes:
141               - /var/log/containers/cinder:/var/log/cinder
142             command: ['/bin/bash', '-c', 'chown -R cinder:cinder /var/log/cinder']
143         step_5:
144           cinder_backup_init_bundle:
145             start_order: 1
146             detach: false
147             net: host
148             user: root
149             command:
150               - '/bin/bash'
151               - '-c'
152               - str_replace:
153                   template:
154                     list_join:
155                       - '; '
156                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 5}' > /etc/puppet/hieradata/docker.json"
157                         - "FACTER_uuid=docker puppet apply --tags file_line,concat,augeas,TAGS --debug -v -e 'CONFIG'"
158                   params:
159                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::constraint::location'
160                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::cinder::backup_bundle'
161             image: {get_param: DockerCinderBackupImage}
162             volumes:
163               - /etc/hosts:/etc/hosts:ro
164               - /etc/localtime:/etc/localtime:ro
165               - /etc/puppet:/tmp/puppet-etc:ro
166               - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
167               - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
168               - /dev/shm:/dev/shm:rw
169       host_prep_tasks:
170         - name: create persistent directories
171           file:
172             path: "{{ item }}"
173             state: directory
174           with_items:
175             - /var/lib/cinder
176             - /var/log/containers/cinder
177       upgrade_tasks:
178         - name: get bootstrap nodeid
179           tags: common
180           command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
181           register: bootstrap_node
182         - name: set is_bootstrap_node fact
183           tags: common
184           set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
185         - name: Disable the openstack-cinder-backup cluster resource
186           tags: step2
187           pacemaker_resource:
188             resource: openstack-cinder-backup
189             state: disable
190             wait_for_resource: true
191           register: output
192           retries: 5
193           until: output.rc == 0
194           when: is_bootstrap_node
195         - name: Delete the stopped openstack-cinder-backup cluster resource.
196           tags: step2
197           pacemaker_resource:
198             resource: openstack-cinder-backup
199             state: delete
200             wait_for_resource: true
201           register: output
202           retries: 5
203           until: output.rc == 0
204           when: is_bootstrap_node
205         - name: Disable cinder_backup service
206           tags: step2
207           service: name=openstack-cinder-backup enabled=no