Execute service setup against a delegated host using Ansible built-in modules

In order to reduce the packages required to pip install on to the hosts,
we allow the service setup to be delegated to a specific host, defaulting
to the deploy host. We also switch as many tasks as possible to using the
built-in Ansible modules which make use of the shade library.

The 'virtualenv' package is now installed appropriately by the openstack_hosts
role, so there's no need to install it any more. The 'httplib2' package is a
legacy Ansible requirement for the get_url/get_uri module which is no longer
needed. The keystone client library is not required any more now that we're
using the upstream modules. As there are no required packages left, the task
to install them is also removed.

Unfortunately we need to use the openstack client to wait for a compute host
to register, so we add it into the nova venv and implement a change in the
way we do the wait so that openrc/clouds.yaml is only implemented on a single
compute host and the wait task is executed there.

Depends-On: https://review.openstack.org/582359
Change-Id: I702480a5188a583a03f66bb39609f7d25a996e4a
This commit is contained in:
Jesse Pretorius 2018-07-12 18:49:56 +01:00 committed by Jesse Pretorius (odyssey4me)
parent af190195b1
commit d0696a90ab
8 changed files with 181 additions and 219 deletions

View File

@ -26,6 +26,11 @@ nova_ceilometer_enabled: False
## Verbosity Options ## Verbosity Options
debug: False debug: False
# Set the host which will execute the shade modules
# for the service setup. The host must already have
# clouds.yaml properly configured.
nova_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}"
# Set the package install state for distribution and pip packages # Set the package install state for distribution and pip packages
# Options are 'present' and 'latest' # Options are 'present' and 'latest'
nova_package_state: "latest" nova_package_state: "latest"
@ -524,10 +529,6 @@ nova_services:
nova_novnc_pip_packages: nova_novnc_pip_packages:
- websockify - websockify
# nova packages that must be installed before anything else
nova_requires_pip_packages:
- virtualenv
nova_compute_ironic_pip_packages: nova_compute_ironic_pip_packages:
- python-ironicclient - python-ironicclient
@ -541,6 +542,7 @@ nova_pip_packages:
- python-keystoneclient - python-keystoneclient
- python-memcached - python-memcached
- python-novaclient - python-novaclient
- python-openstackclient
- uWSGI - uWSGI
nova_compute_lxd_pip_packages: nova_compute_lxd_pip_packages:

View File

@ -64,17 +64,6 @@
delay: 2 delay: 2
listen: "Restart nova services" listen: "Restart nova services"
- name: Wait for the nova-compute service to initialize
command: "openstack --os-cloud default compute service list --service nova-compute --format value --column Host"
register: _compute_host_list
retries: 10
delay: 5
until: "ansible_nodename in _compute_host_list.stdout_lines"
when:
- "nova_services['nova-compute']['group'] in group_names"
- "nova_discover_hosts_in_cells_interval | int < 1"
listen: "Restart nova services"
- meta: noop - meta: noop
listen: Manage LB listen: Manage LB
when: false when: false

View File

@ -40,4 +40,3 @@ galaxy_info:
dependencies: dependencies:
- apt_package_pinning - apt_package_pinning
- galera_client - galera_client
- openstack_openrc

View File

@ -0,0 +1,17 @@
---
features:
- |
The service setup in keystone for nova will now be executed
through delegation to the ``nova_service_setup_host`` which,
by default, is ``localhost`` (the deploy host). Deployers can
opt to rather change this to the utility container by implementing
the following override in ``user_variables.yml``.
.. code-block:: yaml
nova_service_setup_host: "{{ groups['utility_all'][0] }}"
deprecations:
- |
The variable ``nova_requires_pip_packages`` is no longer required
and has therefore been removed.

View File

@ -160,6 +160,20 @@
- name: Flush handlers - name: Flush handlers
meta: flush_handlers meta: flush_handlers
# We delegate this back to the conductor because that is
# where we want to isolate the clouds.yaml configuration,
# rather than have it implemented on all compute nodes.
- import_tasks: nova_compute_wait.yml
delegate_to: "{{ first_conductor }}"
when:
- "nova_services['nova-compute']['group'] in group_names"
- "nova_discover_hosts_in_cells_interval | int < 1"
vars:
first_conductor: "{{ groups[nova_services['nova-conductor']['group']][0] }}"
compute_host_to_wait_for: "{{ ansible_nodename }}"
tags:
- nova-config
# We have to delegate this back to the conductor # We have to delegate this back to the conductor
# because the compute hosts do not have access to # because the compute hosts do not have access to
# the database connection string and therefore # the database connection string and therefore

View File

@ -0,0 +1,30 @@
---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Implement openrc/clouds.yaml
include_role:
name: "openstack_openrc"
- name: Set the delegated task facts
set_fact:
_wait_nova_bin: "{{ hostvars[first_conductor]['nova_bin'] | default(nova_bin) }}"
- name: Wait for the nova-compute service to initialize
command: "{{ _wait_nova_bin }}/openstack --os-cloud default compute service list --service nova-compute --format value --column Host"
changed_when: false
register: _compute_host_list
retries: 10
delay: 5
until: "compute_host_to_wait_for in _compute_host_list.stdout_lines"

View File

@ -25,21 +25,6 @@
tags: tags:
- nova-pip-packages - nova-pip-packages
- name: Install required pip packages
pip:
name: "{{ nova_requires_pip_packages }}"
state: "{{ nova_pip_package_state }}"
extra_args: >-
{{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages is success
retries: 5
delay: 2
tags:
- nova-pip-packages
- name: Retrieve checksum for venv download - name: Retrieve checksum for venv download
uri: uri:
url: "{{ nova_venv_download_url | replace('tgz', 'checksum') }}" url: "{{ nova_venv_download_url | replace('tgz', 'checksum') }}"

View File

@ -13,194 +13,120 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# Create a service # We set the python interpreter to the ansible runtime venv if
- name: Ensure nova service # the delegation is to localhost so that we get access to the
keystone: # appropriate python libraries in that venv. If the delegation
command: "ensure_service" # is to another host, we assume that it is accessible by the
endpoint: "{{ keystone_service_adminurl }}" # system python instead.
login_user: "{{ keystone_admin_user_name }}" - name: Setup the service
login_password: "{{ keystone_auth_admin_password }}" delegate_to: "{{ nova_service_setup_host }}"
login_project_name: "{{ keystone_admin_tenant_name }}" vars:
service_name: "{{ nova_service_name }}" ansible_python_interpreter: >-
service_type: "{{ nova_service_type }}" {{ (nova_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable']) }}
description: "{{ nova_service_description }}" block:
insecure: "{{ keystone_service_adminuri_insecure }}" - name: Add services to the keystone service catalog
register: add_service os_keystone_service:
until: add_service is success cloud: default
retries: 5 state: present
delay: 2 name: "{{ item.name }}"
no_log: True service_type: "{{ item.service_type }}"
tags: description: "{{ item.description }}"
- nova-api-setup endpoint_type: admin
- nova-service-add verify: "{{ not keystone_service_adminuri_insecure }}"
- nova-setup register: add_service
until: add_service is success
retries: 5
delay: 10
with_items:
- name: "{{ nova_service_name }}"
service_type: "{{ nova_service_type }}"
description: "{{ nova_service_description }}"
- name: "{{ nova_placement_service_name }}"
service_type: "{{ nova_placement_service_type }}"
description: "{{ nova_placement_service_description }}"
# Create an admin user - name: Add service users
- name: Ensure nova user os_user:
keystone: cloud: default
command: "ensure_user" state: present
endpoint: "{{ keystone_service_adminurl }}" name: "{{ item.name }}"
login_user: "{{ keystone_admin_user_name }}" password: "{{ item.password }}"
login_password: "{{ keystone_auth_admin_password }}" domain: default
login_project_name: "{{ keystone_admin_tenant_name }}" default_project: "{{ item.default_project }}"
user_name: "{{ nova_service_user_name }}" endpoint_type: admin
tenant_name: "{{ nova_service_project_name }}" verify: "{{ not keystone_service_adminuri_insecure }}"
password: "{{ nova_service_password }}" register: add_service
insecure: "{{ keystone_service_adminuri_insecure }}" when: "{{ item.condition }}"
register: add_service until: add_service is success
when: retries: 5
- not nova_service_in_ldap | bool delay: 10
until: add_service is success no_log: True
retries: 5 with_items:
delay: 10 - name: "{{ nova_service_user_name }}"
no_log: True password: "{{ nova_service_password }}"
tags: default_project: "{{ nova_service_project_name }}"
- nova-api-setup condition: "{{ not nova_service_in_ldap | bool }}"
- nova-service-add - name: "{{ nova_placement_service_username }}"
- nova-setup password: "{{ nova_placement_service_password }}"
default_project: "{{ nova_placement_service_project_name }}"
condition: "{{ not nova_service_in_ldap | bool }}"
loop_control:
label: "{{ item.name }}"
# Add a role to the user - name: Add service users to admin roles
- name: Ensure nova user to admin role os_user_role:
keystone: cloud: default
command: "ensure_user_role" state: present
endpoint: "{{ keystone_service_adminurl }}" user: "{{ item.user }}"
login_user: "{{ keystone_admin_user_name }}" role: "{{ item.role }}"
login_password: "{{ keystone_auth_admin_password }}" project: "{{ item.project }}"
login_project_name: "{{ keystone_admin_tenant_name }}" endpoint_type: admin
user_name: "{{ nova_service_user_name }}" verify: "{{ not keystone_service_adminuri_insecure }}"
tenant_name: "{{ nova_service_project_name }}" register: add_service
role_name: "{{ nova_service_role_name }}" when: "{{ item.condition }}"
insecure: "{{ keystone_service_adminuri_insecure }}" until: add_service is success
register: add_service retries: 5
when: delay: 10
- not nova_service_in_ldap | bool with_items:
until: add_service is success - user: "{{ nova_service_user_name }}"
retries: 5 role: "{{ nova_service_role_name }}"
delay: 10 project: "{{ nova_service_project_name }}"
no_log: True condition: "{{ not nova_service_in_ldap | bool }}"
tags: - user: "{{ nova_placement_service_username }}"
- nova-api-setup role: "{{ nova_placement_service_role_name }}"
- nova-service-add project: "{{ nova_placement_service_project_name }}"
- nova-setup condition: "{{ not nova_placement_service_in_ldap | bool }}"
# Create an endpoint - name: Add endpoints to keystone endpoint catalog
- name: Ensure nova endpoint os_keystone_endpoint:
keystone: cloud: default
command: "ensure_endpoint" state: present
endpoint: "{{ keystone_service_adminurl }}" service: "{{ item.service }}"
login_user: "{{ keystone_admin_user_name }}" endpoint_interface: "{{ item.interface }}"
login_password: "{{ keystone_auth_admin_password }}" url: "{{ item.url }}"
login_project_name: "{{ keystone_admin_tenant_name }}" region: "{{ nova_service_region }}"
region_name: "{{ nova_service_region }}" endpoint_type: admin
service_name: "{{ nova_service_name }}" verify: "{{ not keystone_service_adminuri_insecure }}"
service_type: "{{ nova_service_type }}" register: add_service
insecure: "{{ keystone_service_adminuri_insecure }}" until: add_service is success
endpoint_list: retries: 5
- url: "{{ nova_service_publicurl }}" delay: 10
interface: "public" with_items:
- url: "{{ nova_service_internalurl }}" - service: "{{ nova_service_name }}"
interface: "internal" interface: "public"
- url: "{{ nova_service_adminurl }}" url: "{{ nova_service_publicurl }}"
interface: "admin" - service: "{{ nova_service_name }}"
register: add_service interface: "internal"
until: add_service is success url: "{{ nova_service_internalurl }}"
retries: 5 - service: "{{ nova_service_name }}"
delay: 10 interface: "admin"
no_log: True url: "{{ nova_service_adminurl }}"
tags: - service: "{{ nova_placement_service_name }}"
- nova-api-setup interface: "public"
- nova-service-add url: "{{ nova_placement_service_publicurl }}"
- nova-setup - service: "{{ nova_placement_service_name }}"
interface: "internal"
# Create a service url: "{{ nova_placement_service_internalurl }}"
- name: Ensure nova placement service - service: "{{ nova_placement_service_name }}"
keystone: interface: "admin"
command: "ensure_service" url: "{{ nova_placement_service_adminurl }}"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
service_name: "{{ nova_placement_service_name }}"
service_type: "{{ nova_placement_service_type }}"
description: "{{ nova_placement_service_description }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
register: add_service
until: add_service is success
retries: 5
delay: 2
no_log: True
tags:
- nova-api-setup
- nova-service-add
# Create an admin user
- name: Ensure nova placement user
keystone:
command: "ensure_user"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
user_name: "{{ nova_placement_service_username }}"
tenant_name: "{{ nova_placement_service_project_name }}"
password: "{{ nova_placement_service_password }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
register: add_service
when: not nova_placement_service_in_ldap | bool
until: add_service is success
retries: 5
delay: 10
no_log: True
tags:
- nova-api-setup
- nova-service-add
# Add a role to the user
- name: Ensure nova user to admin role
keystone:
command: "ensure_user_role"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
user_name: "{{ nova_placement_service_username }}"
tenant_name: "{{ nova_placement_service_project_name }}"
role_name: "{{ nova_placement_service_role_name }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
register: add_service
when: not nova_placement_service_in_ldap | bool
until: add_service is success
retries: 5
delay: 10
no_log: True
tags:
- nova-api-setup
- nova-service-add
# Create an endpoint
- name: Ensure nova endpoint
keystone:
command: "ensure_endpoint"
endpoint: "{{ keystone_service_adminurl }}"
login_user: "{{ keystone_admin_user_name }}"
login_password: "{{ keystone_auth_admin_password }}"
login_project_name: "{{ keystone_admin_tenant_name }}"
region_name: "{{ nova_placement_service_region }}"
service_name: "{{ nova_placement_service_name }}"
service_type: "{{ nova_placement_service_type }}"
insecure: "{{ keystone_service_adminuri_insecure }}"
endpoint_list:
- url: "{{ nova_placement_service_publicurl }}"
interface: "public"
- url: "{{ nova_placement_service_internalurl }}"
interface: "internal"
- url: "{{ nova_placement_service_adminurl }}"
interface: "admin"
register: add_service
until: add_service is success
retries: 5
delay: 10
no_log: True
tags:
- nova-api-setup
- nova-service-add