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