Merge "FQDN validation"
[apex-tripleo-heat-templates.git] / puppet / services / glance-api.yaml
1 heat_template_version: ocata
2
3 description: >
4   OpenStack Glance API 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   EndpointMap:
17     default: {}
18     description: Mapping of service endpoint -> protocol. Typically set
19                  via parameter_defaults in the resource registry.
20     type: json
21   Debug:
22     default: ''
23     description: Set to True to enable debugging on all services.
24     type: string
25   GlancePassword:
26     description: The password for the glance service and db account, used by the glance services.
27     type: string
28     hidden: true
29   GlanceWorkers:
30     default: ''
31     description: |
32       Number of API worker processes for Glance. If left unset (empty string), the
33       default value will result in the configuration being left unset and a
34       system-dependent default value will be chosen (e.g.: number of
35       processors). Please note that this will create a large number of
36       processes on systems with a large number of CPUs resulting in excess
37       memory consumption. It is recommended that a suitable non-default value
38       be selected on such systems.
39     type: string
40   MonitoringSubscriptionGlanceApi:
41     default: 'overcloud-glance-api'
42     type: string
43   GlanceApiLoggingSource:
44     type: json
45     default:
46       tag: openstack.glance.api
47       path: /var/log/glance/api.log
48   EnableInternalTLS:
49     type: boolean
50     default: false
51
52 conditions:
53   use_tls_proxy: {equals : [{get_param: EnableInternalTLS}, true]}
54
55 resources:
56
57   TLSProxyBase:
58     type: OS::TripleO::Services::TLSProxyBase
59     properties:
60       ServiceNetMap: {get_param: ServiceNetMap}
61       DefaultPasswords: {get_param: DefaultPasswords}
62       EndpointMap: {get_param: EndpointMap}
63       EnableInternalTLS: {get_param: EnableInternalTLS}
64
65   GlanceBase:
66     type: ./glance-base.yaml
67     properties:
68       ServiceNetMap: {get_param: ServiceNetMap}
69       DefaultPasswords: {get_param: DefaultPasswords}
70       EndpointMap: {get_param: EndpointMap}
71
72 outputs:
73   role_data:
74     description: Role data for the Glance API role.
75     value:
76       service_name: glance_api
77       monitoring_subscription: {get_param: MonitoringSubscriptionGlanceApi}
78       logging_source: {get_param: GlanceApiLoggingSource}
79       logging_groups:
80         - glance
81       config_settings:
82         map_merge:
83           - get_attr: [GlanceBase, role_data, config_settings]
84           - get_attr: [TLSProxyBase, role_data, config_settings]
85           - glance::api::database_connection:
86               list_join:
87                 - ''
88                 - - {get_param: [EndpointMap, MysqlInternal, protocol]}
89                   - '://glance:'
90                   - {get_param: GlancePassword}
91                   - '@'
92                   - {get_param: [EndpointMap, MysqlInternal, host]}
93                   - '/glance'
94                   - '?read_default_file=/etc/my.cnf.d/tripleo.cnf&read_default_group=tripleo'
95             glance::api::bind_port: {get_param: [EndpointMap, GlanceInternal, port]}
96             glance::api::authtoken::auth_uri: {get_param: [EndpointMap, KeystoneInternal, uri] }
97             glance::api::authtoken::auth_url: { get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
98             glance::api::enable_v1_api: false
99             glance::api::enable_v2_api: true
100             glance::api::authtoken::password: {get_param: GlancePassword}
101             glance::api::enable_proxy_headers_parsing: true
102             glance::api::debug: {get_param: Debug}
103             glance::api::workers: {get_param: GlanceWorkers}
104             tripleo.glance_api.firewall_rules:
105               '112 glance_api':
106                 dport:
107                   - 9292
108                   - 13292
109             glance::api::authtoken::project_name: 'service'
110             glance::api::pipeline: 'keystone'
111             glance::api::show_image_direct_url: true
112             # NOTE: bind IP is found in Heat replacing the network name with the
113             # local node IP for the given network; replacement examples
114             # (eg. for internal_api):
115             # internal_api -> IP
116             # internal_api_uri -> [IP]
117             # internal_api_subnet - > IP/CIDR
118             tripleo::profile::base::glance::api::tls_proxy_bind_ip:
119               get_param: [ServiceNetMap, GlanceApiNetwork]
120             tripleo::profile::base::glance::api::tls_proxy_fqdn:
121               str_replace:
122                 template:
123                   "%{hiera('fqdn_$NETWORK')}"
124                 params:
125                   $NETWORK: {get_param: [ServiceNetMap, GlanceApiNetwork]}
126             tripleo::profile::base::glance::api::tls_proxy_port:
127               get_param: [EndpointMap, GlanceInternal, port]
128             # Bind to localhost if internal TLS is enabled, since we put a TLs
129             # proxy in front.
130             glance::api::bind_host:
131               if:
132               - use_tls_proxy
133               - 'localhost'
134               - {get_param: [ServiceNetMap, GlanceApiNetwork]}
135       step_config: |
136         include ::tripleo::profile::base::glance::api
137       service_config_settings:
138         get_attr: [GlanceBase, role_data, service_config_settings]
139       upgrade_tasks:
140         - name: Check if glance_api is deployed
141           command: systemctl is-enabled openstack-glance-api
142           tags: common
143           ignore_errors: True
144           register: glance_api_enabled
145         #(TODO) Remove all glance-registry bits in Pike.
146         - name: Check if glance_registry is deployed
147           command: systemctl is-enabled openstack-glance-registry
148           tags: common
149           ignore_errors: True
150           register: glance_registry_enabled
151         - name: "PreUpgrade step0,validation: Check service openstack-glance-api is running"
152           shell: /usr/bin/systemctl show 'openstack-glance-api' --property ActiveState | grep '\bactive\b'
153           tags: step0,validation
154           when: glance_api_enabled.rc == 0
155         - name: Stop glance_api service
156           tags: step1
157           when: glance_api_enabled.rc == 0
158           service: name=openstack-glance-api state=stopped
159         - name: Stop and disable glance registry (removed for Ocata)
160           tags: step1
161           when: glance_registry_enabled.rc == 0
162           service: name=openstack-glance-registry state=stopped enabled=no