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