Merge "Re-enable default for RoleParameters"
[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 services.
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   ApacheServiceBase:
85     type: ./apache.yaml
86     properties:
87       ServiceNetMap: {get_param: ServiceNetMap}
88       DefaultPasswords: {get_param: DefaultPasswords}
89       EndpointMap: {get_param: EndpointMap}
90       RoleName: {get_param: RoleName}
91       RoleParameters: {get_param: RoleParameters}
92       EnableInternalTLS: {get_param: EnableInternalTLS}
93
94   NovaBase:
95     type: ./nova-base.yaml
96     properties:
97       ServiceNetMap: {get_param: ServiceNetMap}
98       DefaultPasswords: {get_param: DefaultPasswords}
99       EndpointMap: {get_param: EndpointMap}
100       RoleName: {get_param: RoleName}
101       RoleParameters: {get_param: RoleParameters}
102
103 outputs:
104   role_data:
105     description: Role data for the Nova API service.
106     value:
107       service_name: nova_api
108       monitoring_subscription: {get_param: MonitoringSubscriptionNovaApi}
109       logging_source: {get_param: NovaApiLoggingSource}
110       logging_groups:
111         - nova
112       config_settings:
113         map_merge:
114         - get_attr: [NovaBase, role_data, config_settings]
115         - get_attr: [ApacheServiceBase, role_data, config_settings]
116         - nova::cron::archive_deleted_rows::hour: '*/12'
117           nova::cron::archive_deleted_rows::destination: '/dev/null'
118           tripleo.nova_api.firewall_rules:
119             '113 nova_api':
120               dport:
121                 - 8773
122                 - 3773
123                 - 8774
124                 - 13774
125                 - 8775
126           nova::keystone::authtoken::project_name: 'service'
127           nova::keystone::authtoken::user_domain_name: 'Default'
128           nova::keystone::authtoken::project_domain_name: 'Default'
129           nova::keystone::authtoken::password: {get_param: NovaPassword}
130           nova::keystone::authtoken::auth_uri: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix] }
131           nova::keystone::authtoken::auth_url: {get_param: [EndpointMap, KeystoneInternal, uri_no_suffix]}
132           nova::api::enabled: true
133           nova::api::default_floating_pool: {get_param: NovaDefaultFloatingPool}
134           nova::api::sync_db_api: true
135           nova::api::enable_proxy_headers_parsing: true
136           nova::api::api_bind_address:
137             str_replace:
138               template:
139                 "%{hiera('fqdn_$NETWORK')}"
140               params:
141                 $NETWORK: {get_param: [ServiceNetMap, NovaApiNetwork]}
142           nova_wsgi_enabled: true
143           nova::api::service_name: 'httpd'
144           nova::wsgi::apache_api::ssl: {get_param: EnableInternalTLS}
145           # NOTE: bind IP is found in Heat replacing the network name with the local node IP
146           # for the given network; replacement examples (eg. for internal_api):
147           # internal_api -> IP
148           # internal_api_uri -> [IP]
149           # internal_api_subnet - > IP/CIDR
150           nova::wsgi::apache_api::bind_host: {get_param: [ServiceNetMap, NovaApiNetwork]}
151           nova::wsgi::apache_api::servername:
152             str_replace:
153               template:
154                 "%{hiera('fqdn_$NETWORK')}"
155               params:
156                 $NETWORK: {get_param: [ServiceNetMap, NovaApiNetwork]}
157           nova::api::neutron_metadata_proxy_shared_secret: {get_param: NeutronMetadataProxySharedSecret}
158           nova::api::instance_name_template: {get_param: InstanceNameTemplate}
159           nova_enable_db_purge: {get_param: NovaEnableDBPurge}
160           nova::policy::policies: {get_param: NovaApiPolicies}
161         -
162           if:
163           - nova_workers_zero
164           - {}
165           - nova::api::osapi_compute_workers: {get_param: NovaWorkers}
166             nova::wsgi::apache_api::workers: {get_param: NovaWorkers}
167       step_config: |
168         include tripleo::profile::base::nova::api
169       service_config_settings:
170         mysql:
171           map_merge:
172           - {get_attr: [NovaBase, role_data, service_config_settings, mysql]}
173           - nova::db::mysql::password: {get_param: NovaPassword}
174             nova::db::mysql::user: nova
175             nova::db::mysql::host: {get_param: [EndpointMap, MysqlInternal, host_nobrackets]}
176             nova::db::mysql::dbname: nova
177             nova::db::mysql::allowed_hosts:
178               - '%'
179               - "%{hiera('mysql_bind_host')}"
180             nova::db::mysql_api::password: {get_param: NovaPassword}
181             nova::db::mysql_api::user: nova_api
182             nova::db::mysql_api::host: {get_param: [EndpointMap, MysqlInternal, host_nobrackets]}
183             nova::db::mysql_api::dbname: nova_api
184             nova::db::mysql_api::allowed_hosts:
185               - '%'
186               - "%{hiera('mysql_bind_host')}"
187         keystone:
188           nova::keystone::auth::tenant: 'service'
189           nova::keystone::auth::public_url: {get_param: [EndpointMap, NovaPublic, uri]}
190           nova::keystone::auth::internal_url: {get_param: [EndpointMap, NovaInternal, uri]}
191           nova::keystone::auth::admin_url: {get_param: [EndpointMap, NovaAdmin, uri]}
192           nova::keystone::auth::password: {get_param: NovaPassword}
193           nova::keystone::auth::region: {get_param: KeystoneRegion}
194       metadata_settings:
195         get_attr: [ApacheServiceBase, role_data, metadata_settings]
196       upgrade_tasks:
197         yaql:
198           expression: $.data.apache_upgrade + $.data.nova_api_upgrade
199           data:
200             apache_upgrade:
201               get_attr: [ApacheServiceBase, role_data, upgrade_tasks]
202             nova_api_upgrade:
203               - name: get bootstrap nodeid
204                 tags: common
205                 command: hiera bootstrap_nodeid
206                 register: bootstrap_node
207               - name: set is_bootstrap_node fact
208                 tags: common
209                 set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
210               - name: Extra migration for nova tripleo/+bug/1656791
211                 tags: step0,pre-upgrade
212                 when: is_bootstrap_node
213                 command: nova-manage db online_data_migrations
214               - name: Stop and disable nova_api service (pre-upgrade not under httpd)
215                 tags: step2
216                 service: name=openstack-nova-api state=stopped enabled=no
217               - name: Create puppet manifest to set transport_url in nova.conf
218                 tags: step5
219                 when: is_bootstrap_node
220                 copy:
221                   dest: /root/nova-api_upgrade_manifest.pp
222                   mode: 0600
223                   content: >
224                     $transport_url = os_transport_url({
225                       'transport' => hiera('messaging_service_name', 'rabbit'),
226                       'hosts'     => any2array(hiera('rabbitmq_node_names', undef)),
227                       'port'      => sprintf('%s',hiera('nova::rabbit_port', '5672') ),
228                       'username'  => hiera('nova::rabbit_userid', 'guest'),
229                       'password'  => hiera('nova::rabbit_password'),
230                       'ssl'       => sprintf('%s', bool2num(str2bool(hiera('nova::rabbit_use_ssl', '0'))))
231                     })
232                     oslo::messaging::default { 'nova_config':
233                       transport_url => $transport_url
234                     }
235               - name: Run puppet apply to set tranport_url in nova.conf
236                 tags: step5
237                 when: is_bootstrap_node
238                 command: puppet apply --modulepath /etc/puppet/modules:/opt/stack/puppet-modules:/usr/share/openstack-puppet/modules --detailed-exitcodes /root/nova-api_upgrade_manifest.pp
239                 register: puppet_apply_nova_api_upgrade
240                 failed_when: puppet_apply_nova_api_upgrade.rc not in [0,2]
241                 changed_when: puppet_apply_nova_api_upgrade.rc == 2
242               - name: Setup cell_v2 (map cell0)
243                 tags: step5
244                 when: is_bootstrap_node
245                 shell: nova-manage cell_v2 map_cell0 --database_connection=$(hiera nova::cell0_database_connection)
246               - name: Setup cell_v2 (create default cell)
247                 tags: step5
248                 when: is_bootstrap_node
249                 # (owalsh) puppet-nova expects the cell name 'default'
250                 # (owalsh) pass the db uri explicitly to avoid https://bugs.launchpad.net/tripleo/+bug/1662344
251                 shell: nova-manage cell_v2 create_cell --name='default' --database_connection=$(hiera nova::database_connection)
252                 register: nova_api_create_cell
253                 failed_when: nova_api_create_cell.rc not in [0,2]
254                 changed_when: nova_api_create_cell.rc == 0
255               - name: Setup cell_v2 (sync nova/cell DB)
256                 tags: step5
257                 when: is_bootstrap_node
258                 command: nova-manage db sync
259                 async: {get_param: NovaDbSyncTimeout}
260                 poll: 10
261               - name: Setup cell_v2 (get cell uuid)
262                 tags: step5
263                 when: is_bootstrap_node
264                 shell: nova-manage cell_v2 list_cells | sed -e '1,3d' -e '$d' | awk -F ' *| *' '$2 == "default" {print $4}'
265                 register: nova_api_cell_uuid
266               - name: Setup cell_v2 (migrate hosts)
267                 tags: step5
268                 when: is_bootstrap_node
269                 command: nova-manage cell_v2 discover_hosts --cell_uuid {{nova_api_cell_uuid.stdout}} --verbose
270               - name: Setup cell_v2 (migrate instances)
271                 tags: step5
272                 when: is_bootstrap_node
273                 command: nova-manage cell_v2 map_instances --cell_uuid {{nova_api_cell_uuid.stdout}}
274               - name: Sync nova_api DB
275                 tags: step5
276                 command: nova-manage api_db sync
277                 when: is_bootstrap_node
278               - name: Online data migration for nova
279                 tags: step5
280                 when: is_bootstrap_node
281                 command: nova-manage db online_data_migrations