Merge "Replace hardcoded 'br-ex' with NeutronPhysicalBridge parameter."
[apex-tripleo-heat-templates.git] / puppet / services / nova-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack Nova 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   RoleName:
17     default: ''
18     description: Role name on which the service is applied
19     type: string
20   RoleParameters:
21     default: {}
22     description: Parameters specific to the role
23     type: json
24   EndpointMap:
25     default: {}
26     description: Mapping of service endpoint -> protocol. Typically set
27                  via parameter_defaults in the resource registry.
28     type: json
29   NovaWorkers:
30     default: 0
31     description: Number of workers for Nova API service.
32     type: number
33   NovaPassword:
34     description: The password for the nova service and db account, used by nova-api.
35     type: string
36     hidden: true
37   KeystoneRegion:
38     type: string
39     default: 'regionOne'
40     description: Keystone region for endpoint
41   NeutronMetadataProxySharedSecret:
42     description: Shared secret to prevent spoofing
43     type: string
44     hidden: true
45   InstanceNameTemplate:
46     default: 'instance-%08x'
47     description: Template string to be used to generate instance names
48     type: string
49   NovaEnableDBPurge:
50     default: true
51     description: |
52         Whether to create cron job for purging soft deleted rows in Nova database.
53     type: boolean
54   MonitoringSubscriptionNovaApi:
55     default: 'overcloud-nova-api'
56     type: string
57   NovaApiLoggingSource:
58     type: json
59     default:
60       tag: openstack.nova.api
61       path: /var/log/nova/nova-api.log
62   EnableInternalTLS:
63     type: boolean
64     default: false
65   NovaDefaultFloatingPool:
66     default: 'public'
67     description: Default pool for floating IP addresses
68     type: string
69   NovaDbSyncTimeout:
70     default: 300
71     description: Timeout for Nova db sync
72     type: number
73   NovaApiPolicies:
74     description: |
75       A hash of policies to configure for Nova API.
76       e.g. { nova-context_is_admin: { key: context_is_admin, value: 'role:admin' } }
77     default: {}
78     type: json
79
80 conditions:
81   nova_workers_zero: {equals : [{get_param: NovaWorkers}, 0]}
82
83 resources:
84   # Temporarily disable Nova API deployed in WSGI
85   # https://bugs.launchpad.net/nova/+bug/1661360
86   # ApacheServiceBase:
87   #   type: ./apache.yaml
88   #   properties:
89   #     ServiceNetMap: {get_param: ServiceNetMap}
90   #     DefaultPasswords: {get_param: DefaultPasswords}
91   #     EndpointMap: {get_param: EndpointMap}
92   #     RoleName: {get_param: RoleName}
93   #     RoleParameters: {get_param: RoleParameters}
94   #     EnableInternalTLS: {get_param: EnableInternalTLS}
95
96   NovaBase:
97     type: ./nova-base.yaml
98     properties:
99       ServiceNetMap: {get_param: ServiceNetMap}
100       DefaultPasswords: {get_param: DefaultPasswords}
101       EndpointMap: {get_param: EndpointMap}
102       RoleName: {get_param: RoleName}
103       RoleParameters: {get_param: RoleParameters}
104
105 outputs:
106   role_data:
107     description: Role data for the Nova API service.
108     value:
109       service_name: nova_api
110       monitoring_subscription: {get_param: MonitoringSubscriptionNovaApi}
111       logging_source: {get_param: NovaApiLoggingSource}
112       logging_groups:
113         - nova
114       config_settings:
115         map_merge:
116         - get_attr: [NovaBase, role_data, config_settings]
117         # Temporarily disable Nova API deployed in WSGI
118         # https://bugs.launchpad.net/nova/+bug/1661360
119         # - get_attr: [ApacheServiceBase, role_data, config_settings]
120         - nova::cron::archive_deleted_rows::hour: '*/12'
121           nova::cron::archive_deleted_rows::destination: '/dev/null'
122           tripleo.nova_api.firewall_rules:
123             '113 nova_api':
124               dport:
125                 - 8773
126                 - 3773
127                 - 8774
128                 - 13774
129                 - 8775
130           nova::keystone::authtoken::project_name: 'service'
131           nova::keystone::authtoken::user_domain_name: 'Default'
132           nova::keystone::authtoken::project_domain_name: 'Default'
133           nova::keystone::authtoken::password: {get_param: NovaPassword}
134           nova::keystone::authtoken::auth_uri: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
135           nova::keystone::authtoken::auth_url: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix]}
136           nova::api::enabled: true
137           nova::api::default_floating_pool: {get_param: NovaDefaultFloatingPool}
138           nova::api::sync_db_api: true
139           nova::api::enable_proxy_headers_parsing: true
140           nova::api::api_bind_address:
141             str_replace:
142               template:
143                 "%{hiera('fqdn_$NETWORK')}"
144               params:
145                 $NETWORK: {get_param: [ServiceNetMap, NovaApiNetwork]}
146           # Temporarily disable Nova API deployed in WSGI
147           # https://bugs.launchpad.net/nova/+bug/1661360
148           nova_wsgi_enabled: false
149           # nova::api::service_name: 'httpd'
150           # nova::wsgi::apache_api::ssl: {get_param: EnableInternalTLS}
151           # NOTE: bind IP is found in Heat replacing the network name with the local node IP
152           # for the given network; replacement examples (eg. for internal_api):
153           # internal_api -> IP
154           # internal_api_uri -> [IP]
155           # internal_api_subnet - > IP/CIDR
156           # nova::wsgi::apache_api::bind_host: {get_param: [ServiceNetMap, NovaApiNetwork]}
157           # nova::wsgi::apache_api::servername:
158           #   str_replace:
159           #     template:
160           #       "%{hiera('fqdn_$NETWORK')}"
161           #     params:
162           #       $NETWORK: {get_param: [ServiceNetMap, NovaApiNetwork]}
163           nova::api::neutron_metadata_proxy_shared_secret: {get_param: NeutronMetadataProxySharedSecret}
164           nova::api::instance_name_template: {get_param: InstanceNameTemplate}
165           nova_enable_db_purge: {get_param: NovaEnableDBPurge}
166           nova::policy::policies: {get_param: NovaApiPolicies}
167         -
168           if:
169           - nova_workers_zero
170           - {}
171           - nova::api::osapi_compute_workers: {get_param: NovaWorkers}
172           # Temporarily disable Nova API deployed in WSGI
173           # https://bugs.launchpad.net/nova/+bug/1661360
174           # nova::wsgi::apache_api::workers: {get_param: NovaWorkers}
175       step_config: |
176         include tripleo::profile::base::nova::api
177       service_config_settings:
178         mysql:
179           map_merge:
180           - {get_attr: [NovaBase, role_data, service_config_settings, mysql]}
181           - nova::db::mysql::password: {get_param: NovaPassword}
182             nova::db::mysql::user: nova
183             nova::db::mysql::host: {get_param: [EndpointMap, MysqlInternal, host_nobrackets]}
184             nova::db::mysql::dbname: nova
185             nova::db::mysql::allowed_hosts:
186               - '%'
187               - "%{hiera('mysql_bind_host')}"
188             nova::db::mysql_api::password: {get_param: NovaPassword}
189             nova::db::mysql_api::user: nova_api
190             nova::db::mysql_api::host: {get_param: [EndpointMap, MysqlInternal, host_nobrackets]}
191             nova::db::mysql_api::dbname: nova_api
192             nova::db::mysql_api::allowed_hosts:
193               - '%'
194               - "%{hiera('mysql_bind_host')}"
195         keystone:
196           nova::keystone::auth::tenant: 'service'
197           nova::keystone::auth::public_url: {get_param: [EndpointMap, NovaPublic, uri]}
198           nova::keystone::auth::internal_url: {get_param: [EndpointMap, NovaInternal, uri]}
199           nova::keystone::auth::admin_url: {get_param: [EndpointMap, NovaAdmin, uri]}
200           nova::keystone::auth::password: {get_param: NovaPassword}
201           nova::keystone::auth::region: {get_param: KeystoneRegion}
202       # Temporarily disable Nova API deployed in WSGI
203       # https://bugs.launchpad.net/nova/+bug/1661360
204       # metadata_settings:
205       #   get_attr: [ApacheServiceBase, role_data, metadata_settings]
206       upgrade_tasks:
207         - name: get bootstrap nodeid
208           tags: common
209           command: hiera bootstrap_nodeid
210           register: bootstrap_node
211         - name: set is_bootstrap_node fact
212           tags: common
213           set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
214         - name: Extra migration for nova tripleo/+bug/1656791
215           tags: step0,pre-upgrade
216           when: is_bootstrap_node
217           command: nova-manage db online_data_migrations
218         - name: Stop and disable nova_api service (pre-upgrade not under httpd)
219           tags: step2
220           service: name=openstack-nova-api state=stopped enabled=no
221         - name: Create puppet manifest to set transport_url in nova.conf
222           tags: step5
223           when: is_bootstrap_node
224           copy:
225             dest: /root/nova-api_upgrade_manifest.pp
226             mode: 0600
227             content: >
228               $transport_url = os_transport_url({
229                 'transport' => hiera('messaging_service_name', 'rabbit'),
230                 'hosts'     => any2array(hiera('rabbitmq_node_names', undef)),
231                 'port'      => sprintf('%s',hiera('nova::rabbit_port', '5672') ),
232                 'username'  => hiera('nova::rabbit_userid', 'guest'),
233                 'password'  => hiera('nova::rabbit_password'),
234                 'ssl'       => sprintf('%s', bool2num(str2bool(hiera('nova::rabbit_use_ssl', '0'))))
235               })
236               oslo::messaging::default { 'nova_config':
237                 transport_url => $transport_url
238               }
239         - name: Run puppet apply to set tranport_url in nova.conf
240           tags: step5
241           when: is_bootstrap_node
242           command: puppet apply --modulepath /etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules --detailed-exitcodes /root/nova-api_upgrade_manifest.pp
243           register: puppet_apply_nova_api_upgrade
244           failed_when: puppet_apply_nova_api_upgrade.rc not in [0,2]
245           changed_when: puppet_apply_nova_api_upgrade.rc == 2
246         - name: Setup cell_v2 (map cell0)
247           tags: step5
248           when: is_bootstrap_node
249           shell: nova-manage cell_v2 map_cell0 --database_connection=$(hiera nova::cell0_database_connection)
250         - name: Setup cell_v2 (create default cell)
251           tags: step5
252           when: is_bootstrap_node
253           # (owalsh) puppet-nova expects the cell name 'default'
254           # (owalsh) pass the db uri explicitly to avoid https://bugs.launchpad.net/tripleo/+bug/1662344
255           shell: nova-manage cell_v2 create_cell --name='default' --database_connection=$(hiera nova::database_connection)
256           register: nova_api_create_cell
257           failed_when: nova_api_create_cell.rc not in [0,2]
258           changed_when: nova_api_create_cell.rc == 0
259         - name: Setup cell_v2 (sync nova/cell DB)
260           tags: step5
261           when: is_bootstrap_node
262           command: nova-manage db sync
263           async: {get_param: NovaDbSyncTimeout}
264           poll: 10
265         - name: Setup cell_v2 (get cell uuid)
266           tags: step5
267           when: is_bootstrap_node
268           shell: nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}'
269           register: nova_api_cell_uuid
270         - name: Setup cell_v2 (migrate hosts)
271           tags: step5
272           when: is_bootstrap_node
273           command: nova-manage cell_v2 discover_hosts --cell_uuid {{nova_api_cell_uuid.stdout}} --verbose
274         - name: Setup cell_v2 (migrate instances)
275           tags: step5
276           when: is_bootstrap_node
277           command: nova-manage cell_v2 map_instances --cell_uuid {{nova_api_cell_uuid.stdout}}
278         - name: Sync nova_api DB
279           tags: step5
280           command: nova-manage api_db sync
281           when: is_bootstrap_node
282         - name: Online data migration for nova
283           tags: step5
284           when: is_bootstrap_node
285           command: nova-manage db online_data_migrations