Merge "Only set apache certificates if TLS everywhere is enabled"
[apex-tripleo-heat-templates.git] / puppet / services / apache.yaml
1 heat_template_version: ocata
2
3 description: >
4   Apache service configured with Puppet. Note this is typically included
5   automatically via other services which run via Apache.
6
7 parameters:
8   ApacheMaxRequestWorkers:
9     default: 256
10     description: Maximum number of simultaneously processed requests.
11     type: number
12   ApacheServerLimit:
13     default: 256
14     description: Maximum number of Apache processes.
15     type: number
16   ServiceNetMap:
17     default: {}
18     description: Mapping of service_name -> network name. Typically set
19                  via parameter_defaults in the resource registry.  This
20                  mapping overrides those in ServiceNetMapDefaults.
21     type: json
22   DefaultPasswords:
23     default: {}
24     type: json
25   RoleName:
26     default: ''
27     description: Role name on which the service is applied
28     type: string
29   RoleParameters:
30     default: {}
31     description: Parameters specific to the role
32     type: json
33   EndpointMap:
34     default: {}
35     description: Mapping of service endpoint -> protocol. Typically set
36                  via parameter_defaults in the resource registry.
37     type: json
38   EnableInternalTLS:
39     type: boolean
40     default: false
41
42 conditions:
43
44   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
45
46 resources:
47
48   ApacheNetworks:
49     type: OS::Heat::Value
50     properties:
51       value:
52         # NOTE(jaosorior) Get unique network names to create
53         # certificates for those. We skip the tenant network since
54         # we don't need a certificate for that, and the external
55         # is for HAProxy so it isn't used for apache either.
56         yaql:
57           expression: list($.data.map.items().map($1[1])).distinct().where($ != external and $ != tenant)
58           data:
59             map:
60               get_param: ServiceNetMap
61
62 outputs:
63   role_data:
64     description: Role data for the Apache role.
65     value:
66       service_name: apache
67       config_settings:
68         map_merge:
69           -
70             # for the given network; replacement examples (eg. for internal_api):
71             # internal_api -> IP
72             # internal_api_uri -> [IP]
73             # internal_api_subnet - > IP/CIDR
74             apache::ip: {get_param: [ServiceNetMap, ApacheNetwork]}
75             apache::default_vhost: false
76             apache::server_signature: 'Off'
77             apache::server_tokens: 'Prod'
78             apache_remote_proxy_ips_network:
79               str_replace:
80                 template: "NETWORK_subnet"
81                 params:
82                   NETWORK: {get_param: [ServiceNetMap, ApacheNetwork]}
83             apache::mod::prefork::maxclients: { get_param: ApacheMaxRequestWorkers }
84             apache::mod::prefork::serverlimit: { get_param: ApacheServerLimit }
85             apache::mod::remoteip::proxy_ips:
86               - "%{hiera('apache_remote_proxy_ips_network')}"
87           - if:
88             - internal_tls_enabled
89             -
90               generate_service_certificates: true
91               tripleo::certmonger::apache_dirs::certificate_dir: '/etc/pki/tls/certs/httpd'
92               tripleo::certmonger::apache_dirs::key_dir: '/etc/pki/tls/private/httpd'
93               apache_certificates_specs:
94                 map_merge:
95                   repeat:
96                     template:
97                       httpd-NETWORK:
98                         service_certificate: '/etc/pki/tls/certs/httpd/httpd-NETWORK.crt'
99                         service_key: '/etc/pki/tls/private/httpd/httpd-NETWORK.key'
100                         hostname: "%{hiera('fqdn_NETWORK')}"
101                         principal: "HTTP/%{hiera('fqdn_NETWORK')}"
102                     for_each:
103                       NETWORK: {get_attr: [ApacheNetworks, value]}
104             - {}
105       metadata_settings:
106         if:
107           - internal_tls_enabled
108           -
109             repeat:
110               template:
111                 - service: HTTP
112                   network: $NETWORK
113                   type: node
114               for_each:
115                 $NETWORK: {get_attr: [ApacheNetworks, value]}
116           - null
117       upgrade_tasks:
118         - name: Check if httpd is deployed
119           command: systemctl is-enabled httpd
120           tags: common
121           ignore_errors: True
122           register: httpd_enabled
123         - name: "PreUpgrade step0,validation: Check service httpd is running"
124           shell: /usr/bin/systemctl show 'httpd' --property ActiveState | grep '\bactive\b'
125           when: httpd_enabled.rc == 0
126           tags: step0,validation
127         - name: Ensure mod_ssl package is installed
128           tags: step3
129           yum: name=mod_ssl state=latest