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