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