35dcc19661b701c70cbf7c28867ac2c2b81e0be8
[apex-tripleo-heat-templates.git] / puppet / services / haproxy.yaml
1 heat_template_version: pike
2
3 description: >
4   HAproxy service configured with Puppet
5
6 parameters:
7   ServiceNetMap:
8     default: {}
9     description: Mapping of service_name -> network name. Typically set
10                  via parameter_defaults in the resource registry.  This
11                  mapping overrides those in ServiceNetMapDefaults.
12     type: json
13   DefaultPasswords:
14     default: {}
15     type: json
16   RoleName:
17     default: ''
18     description: Role name on which the service is applied
19     type: string
20   RoleParameters:
21     default: {}
22     description: Parameters specific to the role
23     type: json
24   EndpointMap:
25     default: {}
26     description: Mapping of service endpoint -> protocol. Typically set
27                  via parameter_defaults in the resource registry.
28     type: json
29   EnableLoadBalancer:
30     default: true
31     description: Whether to deploy a LoadBalancer, set to false when an external load balancer is used.
32     type: boolean
33   HAProxyStatsPassword:
34     description: Password for HAProxy stats endpoint
35     hidden: true
36     type: string
37   HAProxyStatsUser:
38     description: User for HAProxy stats endpoint
39     default: admin
40     type: string
41   HAProxySyslogAddress:
42     default: /dev/log
43     description: Syslog address where HAproxy will send its log
44     type: string
45   HAProxyStatsEnabled:
46     default: true
47     description: Whether or not to enable the HAProxy stats interface.
48     type: boolean
49   RedisPassword:
50     description: The password for Redis
51     type: string
52     hidden: true
53   MonitoringSubscriptionHaproxy:
54     default: 'overcloud-haproxy'
55     type: string
56   InternalTLSCAFile:
57     default: '/etc/ipa/ca.crt'
58     type: string
59     description: Specifies the default CA cert to use if TLS is used for
60                  services in the internal network.
61   InternalTLSCRLPEMFile:
62     default: '/etc/pki/CA/crl/overcloud-crl.pem'
63     type: string
64     description: Specifies the default CRL PEM file to use for revocation if
65                  TLS is used for services in the internal network.
66
67 resources:
68
69   HAProxyPublicTLS:
70     type: OS::TripleO::Services::HAProxyPublicTLS
71     properties:
72       ServiceNetMap: {get_param: ServiceNetMap}
73       DefaultPasswords: {get_param: DefaultPasswords}
74       EndpointMap: {get_param: EndpointMap}
75       RoleName: {get_param: RoleName}
76       RoleParameters: {get_param: RoleParameters}
77
78   HAProxyInternalTLS:
79     type: OS::TripleO::Services::HAProxyInternalTLS
80     properties:
81       ServiceNetMap: {get_param: ServiceNetMap}
82       DefaultPasswords: {get_param: DefaultPasswords}
83       EndpointMap: {get_param: EndpointMap}
84       RoleName: {get_param: RoleName}
85       RoleParameters: {get_param: RoleParameters}
86
87 outputs:
88   role_data:
89     description: Role data for the HAproxy role.
90     value:
91       service_name: haproxy
92       monitoring_subscription: {get_param: MonitoringSubscriptionHaproxy}
93       config_settings:
94         map_merge:
95           - get_attr: [HAProxyPublicTLS, role_data, config_settings]
96           - get_attr: [HAProxyInternalTLS, role_data, config_settings]
97           - tripleo.haproxy.firewall_rules:
98               '107 haproxy stats':
99                 dport: 1993
100             tripleo::haproxy::haproxy_log_address: {get_param: HAProxySyslogAddress}
101             tripleo::haproxy::haproxy_stats_user: {get_param: HAProxyStatsUser}
102             tripleo::haproxy::haproxy_stats_password: {get_param: HAProxyStatsPassword}
103             tripleo::haproxy::redis_password: {get_param: RedisPassword}
104             tripleo::haproxy::ca_bundle: {get_param: InternalTLSCAFile}
105             tripleo::haproxy::crl_file: {get_param: InternalTLSCRLPEMFile}
106             tripleo::haproxy::haproxy_stats: {get_param: HAProxyStatsEnabled}
107             enable_load_balancer: {get_param: EnableLoadBalancer}
108             tripleo::profile::base::haproxy::certificates_specs:
109               map_merge:
110                 - get_attr: [HAProxyPublicTLS, role_data, certificates_specs]
111                 - get_attr: [HAProxyInternalTLS, role_data, certificates_specs]
112       step_config: |
113         include ::tripleo::profile::base::haproxy
114       upgrade_tasks:
115         - name: Check if haproxy is deployed
116           command: systemctl is-enabled haproxy
117           tags: common
118           ignore_errors: True
119           register: haproxy_enabled
120         - name: "PreUpgrade step0,validation: Check service haproxy is running"
121           shell: /usr/bin/systemctl show 'haproxy' --property ActiveState | grep '\bactive\b'
122           when: haproxy_enabled.rc == 0
123           tags: step0,validation
124         - name: Stop haproxy service
125           tags: step2
126           when: haproxy_enabled.rc == 0
127           service: name=haproxy state=stopped
128         - name: Start haproxy service
129           tags: step4 # Needed at step 4 for mysql
130           when: haproxy_enabled.rc == 0
131           service: name=haproxy state=started
132       metadata_settings:
133         list_concat:
134           - {get_attr: [HAProxyPublicTLS, role_data, metadata_settings]}
135           - {get_attr: [HAProxyInternalTLS, role_data, metadata_settings]}