1 heat_template_version: pike
4 OpenStack containerized HAproxy service for pacemaker
10 DockerHAProxyConfigImage:
11 description: The container image to use for the haproxy config_volume
15 description: Dictionary packing service data
19 description: Mapping of service_name -> network name. Typically set
20 via parameter_defaults in the resource registry. This
21 mapping overrides those in ServiceNetMapDefaults.
28 description: Mapping of service endpoint -> protocol. Typically set
29 via parameter_defaults in the resource registry.
31 DeployedSSLCertificatePath:
32 default: '/etc/pki/tls/private/overcloud_endpoint.pem'
34 The filepath of the certificate as it will be stored in the controller.
38 description: Role name on which the service is applied
42 description: Parameters specific to the role
45 default: '/etc/ipa/ca.crt'
47 description: Specifies the default CA cert to use if TLS is used for
48 services in the internal network.
49 InternalTLSCRLPEMFile:
50 default: '/etc/pki/CA/crl/overcloud-crl.pem'
52 description: Specifies the default CRL PEM file to use for revocation if
53 TLS is used for services in the internal network.
54 HAProxyInternalTLSCertsDirectory:
55 default: '/etc/pki/tls/certs/haproxy'
57 HAProxyInternalTLSKeysDirectory:
58 default: '/etc/pki/tls/private/haproxy'
64 type: ../../../puppet/services/pacemaker/haproxy.yaml
66 EndpointMap: {get_param: EndpointMap}
67 ServiceData: {get_param: ServiceData}
68 ServiceNetMap: {get_param: ServiceNetMap}
69 DefaultPasswords: {get_param: DefaultPasswords}
70 RoleName: {get_param: RoleName}
71 RoleParameters: {get_param: RoleParameters}
75 description: Role data for the HAproxy role.
77 service_name: {get_attr: [HAProxyBase, role_data, service_name]}
80 - get_attr: [HAProxyBase, role_data, config_settings]
81 - haproxy_docker: true
82 tripleo::profile::pacemaker::haproxy_bundle::haproxy_docker_image: &haproxy_image {get_param: DockerHAProxyImage}
83 # the list of directories that contain the certs to bind mount in the countainer
84 # bind-mounting the directories rather than all the cert, key and pem files ensures
85 # that docker won't create directories on the host when then pem files do not exist
86 tripleo::profile::pacemaker::haproxy_bundle::tls_mapping: &tls_mapping
87 - get_param: InternalTLSCAFile
88 - get_param: HAProxyInternalTLSKeysDirectory
89 - get_param: HAProxyInternalTLSCertsDirectory
90 - get_param: DeployedSSLCertificatePath
91 tripleo::profile::pacemaker::haproxy_bundle::internal_certs_directory: {get_param: HAProxyInternalTLSCertsDirectory}
92 tripleo::profile::pacemaker::haproxy_bundle::internal_keys_directory: {get_param: HAProxyInternalTLSKeysDirectory}
93 # disable the use CRL file until we can restart the container when the file expires
94 tripleo::haproxy::crl_file: null
95 tripleo::profile::pacemaker::haproxy_bundle::haproxy_docker_image: &haproxy_image_pcmklatest
99 data: {get_param: DockerHAProxyImage}
100 expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
102 logging_source: {get_attr: [HAProxyBase, role_data, logging_source]}
103 logging_groups: {get_attr: [HAProxyBase, role_data, logging_groups]}
105 service_config_settings: {get_attr: [HAProxyBase, role_data, service_config_settings]}
106 # BEGIN DOCKER SETTINGS
108 config_volume: haproxy
109 puppet_tags: haproxy_config
113 - - "exec {'wait-for-settle': command => '/bin/true' }"
114 - "class tripleo::firewall(){}; define tripleo::firewall::rule( $port = undef, $dport = undef, $sport = undef, $proto = undef, $action = undef, $state = undef, $source = undef, $iniface = undef, $chain = undef, $destination = undef, $extras = undef){}"
115 - "['pcmk_bundle', 'pcmk_resource', 'pcmk_property', 'pcmk_constraint', 'pcmk_resource_default'].each |String $val| { noop_resource($val) }"
116 - 'include ::tripleo::profile::pacemaker::haproxy_bundle'
117 config_image: {get_param: DockerHAProxyConfigImage}
118 volumes: &deployed_cert_mount
120 expression: $.data.select($+":"+$+":ro")
123 /var/lib/kolla/config_files/haproxy.json:
124 command: /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg
126 - source: "/var/lib/kolla/config_files/src/*"
129 preserve_properties: true
131 - source: "/var/lib/kolla/config_files/src-tls/*"
135 preserve_properties: true
140 - - {get_param: HAProxyInternalTLSCertsDirectory}
142 owner: haproxy:haproxy
148 - - {get_param: HAProxyInternalTLSKeysDirectory}
150 owner: haproxy:haproxy
165 "/usr/bin/docker tag 'HAPROXY_IMAGE' 'HAPROXY_IMAGE_PCMKLATEST'"
167 HAPROXY_IMAGE: {get_param: DockerHAProxyImage}
168 HAPROXY_IMAGE_PCMKLATEST: *haproxy_image_pcmklatest
169 image: {get_param: DockerHAProxyImage}
171 - /etc/hosts:/etc/hosts:ro
172 - /etc/localtime:/etc/localtime:ro
173 - /dev/shm:/dev/shm:rw
174 - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
175 - /usr/bin:/usr/bin:ro
176 - /var/run/docker.sock:/var/run/docker.sock:rw
177 image: {get_param: DockerHAProxyImage}
192 - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
193 - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
195 TAGS: 'tripleo::firewall::rule,pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ip,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation'
199 - - 'include ::tripleo::profile::base::pacemaker'
200 - 'include ::tripleo::profile::pacemaker::haproxy_bundle'
201 image: {get_param: DockerHAProxyImage}
204 - *deployed_cert_mount
206 # puppet saves iptables rules in /etc/sysconfig
207 - /etc/sysconfig:/etc/sysconfig:rw
208 # saving rules require accessing /usr/libexec/iptables/iptables.init, just bind-mount
209 # the necessary bit and prevent systemd to try to reload the service in the container
210 - /usr/libexec/iptables:/usr/libexec/iptables:ro
211 - /usr/libexec/initscripts/legacy-actions:/usr/libexec/initscripts/legacy-actions:ro
212 - /etc/hosts:/etc/hosts:ro
213 - /etc/localtime:/etc/localtime:ro
214 - /etc/puppet:/tmp/puppet-etc:ro
215 - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
216 - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
217 - /dev/shm:/dev/shm:rw
219 get_attr: [HAProxyBase, role_data, metadata_settings]
221 - name: get bootstrap nodeid
223 command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
224 register: bootstrap_node
225 - name: set is_bootstrap_node fact
227 set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
228 - name: Check cluster resource status
231 resource: {get_attr: [HAProxyBase, role_data, service_name]}
235 register: haproxy_res
236 - name: Disable the haproxy cluster resource.
239 resource: {get_attr: [HAProxyBase, role_data, service_name]}
241 wait_for_resource: true
244 until: output.rc == 0
245 when: is_bootstrap_node and haproxy_res|succeeded
246 - name: Delete the stopped haproxy cluster resource.
249 resource: {get_attr: [HAProxyBase, role_data, service_name]}
251 wait_for_resource: true
254 until: output.rc == 0
255 when: is_bootstrap_node and haproxy_res|succeeded
257 - name: Get docker Haproxy image
259 docker_image: {get_param: DockerHAProxyImage}
260 docker_image_latest: *haproxy_image_pcmklatest
262 - name: Get previous Haproxy image id
263 shell: "docker images | awk '/haproxy.* pcmklatest/{print $3}'"
264 register: haproxy_image_id
266 - name: Get a list of container using Haproxy image
267 shell: "docker ps -q -f 'ancestor={{haproxy_image_id.stdout}}'"
268 register: haproxy_containers_to_destroy
269 # It will be recreated with the delpoy step.
270 - name: Remove any container using the same Haproxy image
271 shell: "docker rm -fv {{item}}"
272 with_items: "{{ haproxy_containers_to_destroy.stdout_lines }}"
273 - name: Remove previous Haproxy images
274 shell: "docker rmi -f {{haproxy_image_id.stdout}}"
277 - haproxy_image_id.stdout != ''
278 - name: Pull latest Haproxy images
279 command: "docker pull {{docker_image}}"
281 - name: Retag pcmklatest to latest Haproxy image
282 shell: "docker tag {{docker_image}} {{docker_image_latest}}"
284 # Got to check that pacemaker_is_active is working fine with bundle.
285 # TODO: pacemaker_is_active resource doesn't support bundle.