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