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