Merge "Enable Neutron LBaaS Integration"
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / haproxy.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized HAproxy service for pacemaker
5
6 parameters:
7   DockerHAProxyImage:
8     description: image
9     type: string
10   DockerHAProxyConfigImage:
11     description: The container image to use for the haproxy config_volume
12     type: string
13   ServiceData:
14     default: {}
15     description: Dictionary packing service data
16     type: json
17   ServiceNetMap:
18     default: {}
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.
22     type: json
23   DefaultPasswords:
24     default: {}
25     type: json
26   EndpointMap:
27     default: {}
28     description: Mapping of service endpoint -> protocol. Typically set
29                  via parameter_defaults in the resource registry.
30     type: json
31   DeployedSSLCertificatePath:
32     default: '/etc/pki/tls/private/overcloud_endpoint.pem'
33     description: >
34         The filepath of the certificate as it will be stored in the controller.
35     type: string
36   RoleName:
37     default: ''
38     description: Role name on which the service is applied
39     type: string
40   RoleParameters:
41     default: {}
42     description: Parameters specific to the role
43     type: json
44
45 resources:
46
47   HAProxyBase:
48     type: ../../../puppet/services/pacemaker/haproxy.yaml
49     properties:
50       EndpointMap: {get_param: EndpointMap}
51       ServiceData: {get_param: ServiceData}
52       ServiceNetMap: {get_param: ServiceNetMap}
53       DefaultPasswords: {get_param: DefaultPasswords}
54       RoleName: {get_param: RoleName}
55       RoleParameters: {get_param: RoleParameters}
56
57 outputs:
58   role_data:
59     description: Role data for the HAproxy role.
60     value:
61       service_name: {get_attr: [HAProxyBase, role_data, service_name]}
62       config_settings:
63         map_merge:
64           - get_attr: [HAProxyBase, role_data, config_settings]
65           - tripleo::haproxy::haproxy_daemon: false
66             haproxy_docker: true
67             tripleo::profile::pacemaker::haproxy_bundle::haproxy_docker_image: &haproxy_image {get_param: DockerHAProxyImage}
68       step_config: ""
69       service_config_settings: {get_attr: [HAProxyBase, role_data, service_config_settings]}
70       # BEGIN DOCKER SETTINGS
71       puppet_config:
72         config_volume: haproxy
73         puppet_tags: haproxy_config
74         step_config:
75           list_join:
76             - "\n"
77             - - "exec {'wait-for-settle': command => '/bin/true' }"
78               - "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){}"
79               - "['pcmk_bundle', 'pcmk_resource', 'pcmk_property', 'pcmk_constraint', 'pcmk_resource_default'].each |String $val| { noop_resource($val) }"
80               - 'include ::tripleo::profile::pacemaker::haproxy_bundle'
81         config_image: {get_param: DockerHAProxyConfigImage}
82         volumes: &deployed_cert_mount
83           - list_join:
84             - ':'
85             - - {get_param: DeployedSSLCertificatePath}
86               - {get_param: DeployedSSLCertificatePath}
87               - 'ro'
88       kolla_config:
89         /var/lib/kolla/config_files/haproxy.json:
90           command: haproxy -f /etc/haproxy/haproxy.cfg
91           config_files:
92             - source: "/var/lib/kolla/config_files/src/*"
93               dest: "/"
94               merge: true
95               preserve_properties: true
96               optional: true
97       docker_config:
98         step_2:
99           haproxy_init_bundle:
100             start_order: 3
101             detach: false
102             net: host
103             user: root
104             privileged: true
105             command:
106               - '/bin/bash'
107               - '-c'
108               - str_replace:
109                   template:
110                     list_join:
111                       - '; '
112                       - - "cp -a /tmp/puppet-etc/* /etc/puppet; echo '{\"step\": 2}' > /etc/puppet/hieradata/docker.json"
113                         - "FACTER_uuid=docker puppet apply --tags file,file_line,concat,augeas,TAGS -v -e 'CONFIG'"
114                   params:
115                     TAGS: 'tripleo::firewall::rule,pacemaker::resource::bundle,pacemaker::property,pacemaker::resource::ip,pacemaker::resource::ocf,pacemaker::constraint::order,pacemaker::constraint::colocation'
116                     CONFIG:
117                       list_join:
118                         - ';'
119                         - - 'include ::tripleo::profile::base::pacemaker'
120                           - 'include ::tripleo::profile::pacemaker::haproxy_bundle'
121             image: *haproxy_image
122             volumes:
123               list_concat:
124                 - *deployed_cert_mount
125                 -
126                   # puppet saves iptables rules in /etc/sysconfig
127                   - /etc/sysconfig:/etc/sysconfig:rw
128                   # saving rules require accessing /usr/libexec/iptables/iptables.init, just bind-mount
129                   # the necessary bit and prevent systemd to try to reload the service in the container
130                   - /usr/libexec/iptables:/usr/libexec/iptables:ro
131                   - /usr/libexec/initscripts/legacy-actions:/usr/libexec/initscripts/legacy-actions:ro
132                   - /etc/hosts:/etc/hosts:ro
133                   - /etc/localtime:/etc/localtime:ro
134                   - /etc/puppet:/tmp/puppet-etc:ro
135                   - /usr/share/openstack-puppet/modules:/usr/share/openstack-puppet/modules:ro
136                   - /etc/corosync/corosync.conf:/etc/corosync/corosync.conf:ro
137                   - /dev/shm:/dev/shm:rw
138       metadata_settings:
139         get_attr: [HAProxyBase, role_data, metadata_settings]