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