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