Merge "Updates ControlPlaneSubnetCidr to be a string"
[apex-tripleo-heat-templates.git] / puppet / extraconfig / tls / tls-cert-inject.yaml
1 heat_template_version: 2015-04-30
2
3 description: >
4   This is a template which will build the TLS Certificates necessary
5   for the load balancer using the given parameters.
6
7 parameters:
8   # Can be overridden via parameter_defaults in the environment
9   SSLCertificate:
10     description: >
11       The content of the SSL certificate (without Key) in PEM format.
12     type: string
13   SSLIntermediateCertificate:
14     default: ''
15     description: >
16       The content of an SSL intermediate CA certificate in PEM format.
17     type: string
18   SSLKey:
19     description: >
20       The content of the SSL Key in PEM format.
21     type: string
22     hidden: true
23
24   # Can be overridden by parameter_defaults if the user wants to try deploying
25   # this in a distro that doesn't support this path.
26   DeployedSSLCertificatePath:
27     default: '/etc/pki/tls/private/overcloud_endpoint.pem'
28     description: >
29         The filepath of the certificate as it will be stored in the controller.
30     type: string
31
32   # Passed in by the controller
33   NodeIndex:
34     default: 0
35     type: number
36   server:
37     description: ID of the controller node to apply this config to
38     type: string
39
40 resources:
41   ControllerTLSConfig:
42     type: OS::Heat::SoftwareConfig
43     properties:
44       group: script
45       inputs:
46         - name: cert_path
47         - name: cert_chain_content
48       outputs:
49         - name: chain_md5sum
50         - name: cert_modulus
51         - name: key_modulus
52       config: |
53         #!/bin/sh
54         cat > ${cert_path} << EOF
55         ${cert_chain_content}
56         EOF
57         chmod 0440 ${cert_path}
58         chown root:haproxy ${cert_path}
59         md5sum ${cert_path} > ${heat_outputs_path}.chain_md5sum
60         openssl x509 -noout -modulus -in ${cert_path} \
61           | openssl md5 | cut -c 10- \
62           > ${heat_outputs_path}.cert_modulus
63         openssl rsa -noout -modulus -in ${cert_path} \
64           | openssl md5 | cut -c 10- \
65           > ${heat_outputs_path}.key_modulus
66         # We need to reload haproxy in case the certificate changed because
67         # puppet doesn't know the contents of the cert file.  The pacemaker
68         # case is handled separately in a pacemaker-specific resource.
69         pacemaker_status=$(systemctl is-active pacemaker)
70         haproxy_status=$(systemctl is-active haproxy)
71         if [ "$pacemaker_status" != "active" -a "$haproxy_status" = "active"]; then
72             systemctl reload haproxy
73         fi
74
75   ControllerTLSDeployment:
76     type: OS::Heat::SoftwareDeployment
77     properties:
78       name: ControllerTLSDeployment
79       config: {get_resource: ControllerTLSConfig}
80       server: {get_param: server}
81       input_values:
82         cert_path: {get_param: DeployedSSLCertificatePath}
83         cert_chain_content:
84           list_join:
85             - ''
86             - - {get_param: SSLCertificate}
87               - {get_param: SSLIntermediateCertificate}
88               - {get_param: SSLKey}
89
90 outputs:
91   deploy_stdout:
92     description: Deployment reference
93     value: {get_attr: [ControllerTLSDeployment, chain_md5sum]}
94   deployed_ssl_certificate_path:
95     description: The location that the TLS certificate was deployed to.
96     value: {get_param: DeployedSSLCertificatePath}
97   key_modulus_md5:
98     description: MD5 checksum of the Key SSL Modulus
99     value: {get_attr: [ControllerTLSDeployment, key_modulus]}
100   cert_modulus_md5:
101     description: MD5 checksum of the Certificate SSL Modulus
102     value: {get_attr: [ControllerTLSDeployment, cert_modulus]}