From 3cd040ab84c811b9c640fda52672968ae80020d5 Mon Sep 17 00:00:00 2001 From: Logan V Date: Sun, 12 May 2019 14:52:43 -0500 Subject: [PATCH] Make scenario construction more generic The bootstrap host scenario was very quirky because we had to a maintain a list of "special" scenario keywords that are not actual services, otherwise the role would fail when deploying non-existent AIO conf.d files. Instead, we can simply pass a full expanded scenario list (including the "special" keywords and all service keywords and only deploy the conf.d files that exist in the repo. This will make scenarios much more straight forward to use and less flaky when adding scenario variants that may not have a conf.d file to deploy. Change-Id: I621660f39c4e51db4b8063feee782aae5cd16840 --- .../openstack_user_config.yml.aio.j2 | 12 +++--- tests/roles/bootstrap-host/defaults/main.yml | 2 +- .../tasks/prepare_aio_config.yml | 28 +++++++++----- .../templates/user_variables.aio.yml.j2 | 2 +- tests/roles/bootstrap-host/vars/main.yml | 38 +++++++------------ 5 files changed, 40 insertions(+), 42 deletions(-) diff --git a/etc/openstack_deploy/openstack_user_config.yml.aio.j2 b/etc/openstack_deploy/openstack_user_config.yml.aio.j2 index b03cb1ad7d..aae9fcf45e 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.aio.j2 +++ b/etc/openstack_deploy/openstack_user_config.yml.aio.j2 @@ -1,9 +1,9 @@ --- cidr_networks: -{% if 'trove' in bootstrap_host_services %} +{% if 'trove' in bootstrap_host_scenarios_expanded %} dbaas: 172.29.232.0/22 {% endif %} -{% if 'octavia' in bootstrap_host_services %} +{% if 'octavia' in bootstrap_host_scenarios_expanded %} lbaas: 172.29.252.0/22 {% endif %} container: 172.29.236.0/22 @@ -11,11 +11,11 @@ cidr_networks: storage: 172.29.244.0/22 used_ips: -{% if 'trove' in bootstrap_host_services %} +{% if 'trove' in bootstrap_host_scenarios_expanded %} - "172.29.232.1,172.29.232.50" - "172.29.232.100" {% endif %} -{% if 'octavia' in bootstrap_host_services %} +{% if 'octavia' in bootstrap_host_scenarios_expanded %} - "172.29.252.1,172.29.252.50" - "172.29.252.100" - "172.29.253.1,172.29.253.200" @@ -66,7 +66,7 @@ global_overrides: net_name: "vxlan" group_binds: - neutron_linuxbridge_agent -{% if 'trove' in bootstrap_host_services %} +{% if 'trove' in bootstrap_host_scenarios_expanded %} - network: container_bridge: "br-dbaas" container_type: "veth" @@ -79,7 +79,7 @@ global_overrides: - neutron_linuxbridge_agent - rabbitmq {% endif %} -{% if 'octavia' in bootstrap_host_services %} +{% if 'octavia' in bootstrap_host_scenarios_expanded %} - network: container_bridge: "br-lbaas" container_type: "veth" diff --git a/tests/roles/bootstrap-host/defaults/main.yml b/tests/roles/bootstrap-host/defaults/main.yml index 9ef6ac78cc..7e12e1b4d0 100644 --- a/tests/roles/bootstrap-host/defaults/main.yml +++ b/tests/roles/bootstrap-host/defaults/main.yml @@ -87,7 +87,7 @@ bootstrap_host_loopback_zfs: yes bootstrap_host_loopback_zfs_size: 1024 # # Boolean option to deploy the OSD loopback disks and cluster UUID for Ceph -bootstrap_host_ceph: "{{ 'ceph' in bootstrap_host_services }}" +bootstrap_host_ceph: "{{ 'ceph' in bootstrap_host_scenarios_expanded }}" # Size of the Ceph OSD loopbacks bootstrap_host_loopback_ceph_size: 1024 # Ceph OSDs to create on the AIO host diff --git a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml index 26551778df..d0f504b6a2 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml @@ -21,13 +21,23 @@ tags: - create-directories +- name: Find user conf.d configurations to deploy + stat: + path: "{{ bootstrap_host_aio_config_path }}/conf.d/{{ item }}.yml.aio" + register: conf_d_stat + with_items: "{{ bootstrap_host_scenarios_expanded }}" + - name: Deploy user conf.d configuration config_template: - src: "{{ bootstrap_host_aio_config_path }}/conf.d/{{ item }}.yml.aio" - dest: "/etc/openstack_deploy/conf.d/{{ item }}.yml" - config_overrides: "{{ item.override | default({}) }}" + src: "{{ bootstrap_host_aio_config_path }}/conf.d/{{ item.item }}.yml.aio" + dest: "/etc/openstack_deploy/conf.d/{{ item.item }}.yml" + config_overrides: "{{ item.item.override | default({}) }}" config_type: "yaml" - with_items: "{{ bootstrap_host_services }}" + with_items: "{{ conf_d_stat.results | default([]) }}" + loop_control: + label: "{{ item.item }}" + when: + - item.stat.exists | bool tags: - deploy-confd @@ -156,26 +166,26 @@ with_items: - src: user_variables_ceph.yml.j2 dest: user_variables_ceph.yml - condition: "{{ 'ceph' in bootstrap_host_services }}" + condition: "{{ 'ceph' in bootstrap_host_scenarios_expanded }}" - src: user_variables_congress.yml.j2 dest: user_variables_congress.yml - condition: "{{ 'congress' in bootstrap_host_services }}" + condition: "{{ 'congress' in bootstrap_host_scenarios_expanded }}" - src: user_variables_translations.yml.j2 dest: user_variables_translations.yml condition: "{{ bootstrap_host_scenario is search('translations') }}" - src: user_variables_barbican.yml.j2 dest: user_variables_barbican.yml - condition: "{{ 'barbican' in bootstrap_host_services }}" + condition: "{{ 'barbican' in bootstrap_host_scenarios_expanded }}" - src: user_variables_manila.yml.j2 dest: user_variables_manila.yml - condition: "{{ 'manila' in bootstrap_host_services }}" + condition: "{{ 'manila' in bootstrap_host_scenarios_expanded }}" - name: Copy modified cinder-volume env.d file for ceph scenario copy: src: "{{ playbook_dir }}/../etc/openstack_deploy/env.d/cinder-volume.yml.container.example" dest: "/etc/openstack_deploy/env.d/cinder-volume.yml" when: - - "'ceph' in bootstrap_host_services" + - "'ceph' in bootstrap_host_scenarios_expanded" - name: Copy modified env.d file for metal scenario copy: diff --git a/tests/roles/bootstrap-host/templates/user_variables.aio.yml.j2 b/tests/roles/bootstrap-host/templates/user_variables.aio.yml.j2 index adf9cc88fe..12d881de16 100644 --- a/tests/roles/bootstrap-host/templates/user_variables.aio.yml.j2 +++ b/tests/roles/bootstrap-host/templates/user_variables.aio.yml.j2 @@ -232,7 +232,7 @@ octavia_v2: True # Disable Octavia V1 API octavia_v1: False octavia_management_net_subnet_cidr: "{{ (bootstrap_host_container_tech == 'nspawn') | ternary('172.29.240.0/22', '172.29.252.0/22') }}" -{% elif 'octavia' in bootstrap_host_services %} +{% elif 'octavia' in bootstrap_host_scenarios_expanded %} neutron_lbaas_octavia: True octavia_management_net_subnet_cidr: "{{ (bootstrap_host_container_tech == 'nspawn') | ternary('172.29.240.0/22', '172.29.252.0/22') }}" {% endif %} diff --git a/tests/roles/bootstrap-host/vars/main.yml b/tests/roles/bootstrap-host/vars/main.yml index 526e549247..f08a6783e1 100644 --- a/tests/roles/bootstrap-host/vars/main.yml +++ b/tests/roles/bootstrap-host/vars/main.yml @@ -15,45 +15,33 @@ bootstrap_host_scenarios: "{{ (bootstrap_host_scenario.split('_') | reject('equalto', '')) | list }}" -_non_service_scenarios: - - aio - - distro - - lxc - - metal - - nspawn - - octaviav2 - - proxy - - source - - telemetry - - translations - - varstest - -bootstrap_host_services: |- - {% set service_list = ['keystone'] %} - {% set service_list_extra = bootstrap_host_scenarios | difference(_non_service_scenarios) %} +# Expand the scenario list to include specific services that are being deployed +# as part of the scenario +bootstrap_host_scenarios_expanded: |- + {# Keystone is included in every scenario #} + {% set scenario_list = bootstrap_host_scenarios + ['keystone'] %} {% if 'metal' not in bootstrap_host_scenarios %} - {% set _ = service_list.append('haproxy') %} + {% set _ = scenario_list.append('haproxy') %} {% endif %} {% if ['aio', 'translations'] | intersect(bootstrap_host_scenarios) | length > 0 %} {# Base services deployed with aio and translations scenarios #} - {% set _ = service_list.extend(['cinder', 'glance', 'neutron', 'nova', 'placement']) %} + {% set _ = scenario_list.extend(['cinder', 'glance', 'neutron', 'nova', 'placement']) %} {% if 'metal' not in bootstrap_host_scenarios %} {# Horizon is a base service in container jobs #} - {% set _ = service_list.append('horizon') %} + {% set _ = scenario_list.append('horizon') %} {% endif %} {% endif %} {# Service additions based on scenario presence #} {% if 'ironic' in bootstrap_host_scenarios %} - {% set _ = service_list.extend(['swift']) %} + {% set _ = scenario_list.extend(['swift']) %} {% endif %} {% if 'octaviav2' in bootstrap_host_scenarios %} - {% set _ = service_list.extend(['octavia']) %} + {% set _ = scenario_list.extend(['octavia']) %} {% endif %} {% if 'telemetry' in bootstrap_host_scenarios %} - {% set _ = service_list.extend(['aodh', 'ceilometer', 'gnocchi', 'panko']) %} + {% set _ = scenario_list.extend(['aodh', 'ceilometer', 'gnocchi', 'panko']) %} {% endif %} {% if 'translations' in bootstrap_host_scenarios %} - {% set _ = service_list.extend(['designate', 'heat', 'magnum', 'sahara', 'swift', 'trove']) %} + {% set _ = scenario_list.extend(['designate', 'heat', 'magnum', 'sahara', 'swift', 'trove']) %} {% endif %} - {% set _ = service_list.extend(service_list_extra) %} - {{ (service_list | unique) | sort }} + {{ (scenario_list | unique) | sort }}