upgrades/validation: only run validation when services exist
[apex-tripleo-heat-templates.git] / puppet / services / horizon.yaml
1 heat_template_version: ocata
2
3 description: >
4   Horizon 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   Debug:
14     default: ''
15     description: Set to True to enable debugging on all services.
16     type: string
17   DefaultPasswords:
18     default: {}
19     type: json
20   EndpointMap:
21     default: {}
22     description: Mapping of service endpoint -> protocol. Typically set
23                  via parameter_defaults in the resource registry.
24     type: json
25   HorizonAllowedHosts:
26     default: '*'
27     description: A list of IP/Hostname for the server Horizon is running on.
28                  Used for header checks.
29     type: comma_delimited_list
30   HorizonPasswordValidator:
31     description: Regex for password validation
32     type: string
33     default: ''
34   HorizonPasswordValidatorHelp:
35     description: Help text for password validation
36     type: string
37     default: ''
38   HorizonSecret:
39     description: Secret key for Django
40     type: string
41     hidden: true
42     default: ''
43   MemcachedIPv6:
44     default: false
45     description: Enable IPv6 features in Memcached.
46     type: boolean
47   MonitoringSubscriptionHorizon:
48     default: 'overcloud-horizon'
49     type: string
50
51 conditions:
52
53   debug_empty: {equals : [{get_param: Debug}, '']}
54
55 outputs:
56   role_data:
57     description: Role data for the Horizon role.
58     value:
59       service_name: horizon
60       monitoring_subscription: {get_param: MonitoringSubscriptionHorizon}
61       config_settings:
62         map_merge:
63         - horizon::allowed_hosts: {get_param: HorizonAllowedHosts}
64           tripleo.horizon.firewall_rules:
65             '126 horizon':
66               dport:
67                 - 80
68                 - 443
69           horizon::enable_secure_proxy_ssl_header: true
70           horizon::disable_password_reveal: true
71           horizon::enforce_password_check: true
72           horizon::disallow_iframe_embed: true
73           horizon::cache_backend: django.core.cache.backends.memcached.MemcachedCache
74           horizon::django_session_engine: 'django.contrib.sessions.backends.cache'
75           horizon::vhost_extra_params:
76             add_listen: false
77             priority: 10
78             access_log_format: '%a %l %u %t \"%r\" %>s %b \"%%{}{Referer}i\" \"%%{}{User-Agent}i\"'
79             options: ['FollowSymLinks','MultiViews']
80           horizon::bind_address: {get_param: [ServiceNetMap, HorizonNetwork]}
81           horizon::keystone_url: {get_param: [EndpointMap, KeystoneInternal, uri]}
82           horizon::password_validator: {get_param: [HorizonPasswordValidator]}
83           horizon::password_validator_help: {get_param: [HorizonPasswordValidatorHelp]}
84           horizon::secret_key:
85             yaql:
86               expression: $.data.passwords.where($ != '').first()
87               data:
88                 passwords:
89                   - {get_param: HorizonSecret}
90                   - {get_param: [DefaultPasswords, horizon_secret]}
91           memcached_ipv6: {get_param: MemcachedIPv6}
92         -
93           if:
94           - debug_empty
95           - {}
96           - horizon::django_debug: {get_param: Debug}
97       step_config: |
98         include ::tripleo::profile::base::horizon
99       # Ansible tasks to handle upgrade
100       upgrade_tasks:
101         - name: Check if httpd is deployed
102           command: systemctl is-enabled httpd
103           tags: common
104           ignore_errors: True
105           register: httpd_enabled
106         - name: "PreUpgrade step0,validation: Check if httpd is running"
107           shell: >
108             /usr/bin/systemctl show 'httpd' --property ActiveState |
109             grep '\bactive\b'
110           when: httpd_enabled.rc == 0
111           tags: step0,validation
112         - name: Stop Horizon (under httpd)
113           tags: step1
114           when: httpd_enabled.rc == 0
115           service: name=httpd state=stopped