From 74bebf5d57c6aa1a2b450361a6718b1fa382942b Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 21 Nov 2018 12:58:30 +0000 Subject: [PATCH] Ensure AIO container_tech/install_method vars are namespaced To ensure there are no clashes with the inventory and other uses beyond the AIO bootstrap, we namespace the container_tech variable and the install_method variable. This also allows us to use those variables as the common base in all conditionals, rather than repeat the use of the env var lookup here and there. We also tidy up a bit of content in the user_variables.yml template and the bootstrap-aio.yml playbook. Finally, we remove the unnecessary specification of the 'bootstrap_host_scenario', 'install_method' and 'openstack_confd_entries' variables in the playbook, given that they're now in the role defaults. Change-Id: I5c276a2efed5e1b300fc72f2767abb008199571c --- .../openstack_user_config.yml.aio.j2 | 4 ++-- tests/bootstrap-aio.yml | 13 +++++-------- tests/roles/bootstrap-host/defaults/main.yml | 13 ++++++++----- tests/roles/bootstrap-host/tasks/main.yml | 4 ++-- .../bootstrap-host/tasks/prepare_aio_config.yml | 4 ++-- .../templates/user_variables.aio.yml.j2 | 10 +++++----- .../templates/user_variables_translations.yml.j2 | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/etc/openstack_deploy/openstack_user_config.yml.aio.j2 b/etc/openstack_deploy/openstack_user_config.yml.aio.j2 index 81bfa764f4..9a4bd8ac27 100644 --- a/etc/openstack_deploy/openstack_user_config.yml.aio.j2 +++ b/etc/openstack_deploy/openstack_user_config.yml.aio.j2 @@ -120,11 +120,11 @@ shared-infra_hosts: ip: 172.29.236.100 container_vars: # Optional | container_tech for a target host, default is "lxc". - container_tech: "{{ container_tech }}" + container_tech: "{{ bootstrap_host_container_tech }}" repo-infra_hosts: aio1: -{% if install_method == 'distro' %} +{% if bootstrap_host_install_method == 'distro' %} affinity: repo_container: 0 {% endif %} diff --git a/tests/bootstrap-aio.yml b/tests/bootstrap-aio.yml index b2f66f7403..a6eb612bf2 100644 --- a/tests/bootstrap-aio.yml +++ b/tests/bootstrap-aio.yml @@ -20,11 +20,12 @@ roles: - role: "sshd" - role: "bootstrap-host" + vars_files: + - "{{ playbook_dir }}/../playbooks/defaults/repo_packages/openstack_services.yml" + - vars/bootstrap-aio-vars.yml + environment: "{{ deployment_environment_variables | default({}) }}" vars: ansible_python_interpreter: "/usr/bin/python" - bootstrap_host_scenario: "{{ lookup('env','SCENARIO') | default('aio_lxc', true) }}" - install_method: "{{ lookup('env', 'INSTALL_METHOD') | default('source', true) }}" - openstack_confd_entries: "{{ confd_overrides[bootstrap_host_scenario] }}" pip_install_upper_constraints_proto: "{{ ansible_python_version | version_compare('2.7.9', '>=') | ternary('https','http') }}" pip_install_upper_constraints: >- {{ (playbook_dir ~ '/../global-requirement-pins.txt') | realpath }} @@ -82,8 +83,4 @@ - ansible_eth13['active'] == true - ansible_eth14['active'] == true when: - - (container_tech | default('unknown')) != 'nspawn' - vars_files: - - "{{ playbook_dir }}/../playbooks/defaults/repo_packages/openstack_services.yml" - - vars/bootstrap-aio-vars.yml - environment: "{{ deployment_environment_variables | default({}) }}" + - (bootstrap_host_container_tech | default('unknown')) != 'nspawn' diff --git a/tests/roles/bootstrap-host/defaults/main.yml b/tests/roles/bootstrap-host/defaults/main.yml index bf1a7bf60d..6f3ad4c9fb 100644 --- a/tests/roles/bootstrap-host/defaults/main.yml +++ b/tests/roles/bootstrap-host/defaults/main.yml @@ -15,7 +15,7 @@ ## AIO user-space configuration options # Scenario used to bootstrap the host -bootstrap_host_scenario: aio_lxc +bootstrap_host_scenario: "{{ lookup('env','SCENARIO') | default('aio_lxc', true) }}" # # Boolean option to implement OpenStack-Ansible configuration for an AIO # Switch to no for a multi-node configuration @@ -188,9 +188,9 @@ bootstrap_host_data_mount_options: lvm: "defaults" swap: "%%" -bootstrap_host_data_disk2_fs: "{{ bootstrap_host_data_disk2_formats[((container_tech == 'nspawn') | ternary('btrfs', lxc_container_backing_store))] }}" -bootstrap_host_data_disk2_fs_mount_options: "{{ bootstrap_host_data_mount_options[((container_tech == 'nspawn') | ternary('btrfs', lxc_container_backing_store))] }}" -bootstrap_host_data_disk2_path: "{{ (lxc_container_backing_store == 'machinectl' or container_tech == 'nspawn') | ternary('/var/lib/machines', '/var/lib/lxc') }}" +bootstrap_host_data_disk2_fs: "{{ bootstrap_host_data_disk2_formats[((bootstrap_host_container_tech == 'nspawn') | ternary('btrfs', lxc_container_backing_store))] }}" +bootstrap_host_data_disk2_fs_mount_options: "{{ bootstrap_host_data_mount_options[((bootstrap_host_container_tech == 'nspawn') | ternary('btrfs', lxc_container_backing_store))] }}" +bootstrap_host_data_disk2_path: "{{ (lxc_container_backing_store == 'machinectl' or bootstrap_host_container_tech == 'nspawn') | ternary('/var/lib/machines', '/var/lib/lxc') }}" ### Optional Settings ### @@ -199,8 +199,11 @@ bootstrap_host_data_disk2_path: "{{ (lxc_container_backing_store == 'machinectl' # host's network interface that has the default route on it. #bootstrap_host_public_address: 0.0.0.0 +# Set the install method for the deployment. Options are ['source', 'distro'] +bootstrap_host_install_method: "{{ lookup('env', 'INSTALL_METHOD') | default('source', true) }}" + # Set the container technology in service. Options are nspawn and lxc. -container_tech: "{{ ('nspawn' in bootstrap_host_scenario) | ternary('nspawn', 'lxc') }}" +bootstrap_host_container_tech: "{{ (bootstrap_host_scenario is search('nspawn')) | ternary('nspawn', 'lxc') }}" # Set the lxc backing store for the job lxc_container_backing_store: dir diff --git a/tests/roles/bootstrap-host/tasks/main.yml b/tests/roles/bootstrap-host/tasks/main.yml index f76c674006..1c209ae92e 100644 --- a/tests/roles/bootstrap-host/tasks/main.yml +++ b/tests/roles/bootstrap-host/tasks/main.yml @@ -66,7 +66,7 @@ when: - bootstrap_host_loopback_machines | bool - bootstrap_host_data_disk_device == None - - lxc_container_backing_store == 'machinectl' or container_tech == 'nspawn' + - lxc_container_backing_store == 'machinectl' or bootstrap_host_container_tech == 'nspawn' tags: - prepare-loopback @@ -125,7 +125,7 @@ # Prepare the network interfaces - include: prepare_networking.yml when: - - container_tech != 'nspawn' + - bootstrap_host_container_tech != 'nspawn' tags: - prepare-networking diff --git a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml index 060349133d..fdfd2c23f9 100644 --- a/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml +++ b/tests/roles/bootstrap-host/tasks/prepare_aio_config.yml @@ -27,13 +27,13 @@ dest: "/etc/openstack_deploy/conf.d/{{ item.name | regex_replace('.aio$', '') }}" config_overrides: "{{ item.override | default({}) }}" config_type: "yaml" - with_items: "{{ openstack_confd_entries | default([]) }}" + with_items: "{{ confd_overrides[bootstrap_host_scenario] | default([]) }}" tags: - deploy-confd - name: Deploy openstack_user_config config_template: - src: "{{ bootstrap_host_aio_config_path }}/openstack_user_config.yml.{{ (container_tech == 'nspawn') | ternary('aio-nspawn', 'aio') }}.j2" + src: "{{ bootstrap_host_aio_config_path }}/openstack_user_config.yml.{{ (bootstrap_host_container_tech == 'nspawn') | ternary('aio-nspawn', 'aio') }}.j2" dest: "/etc/openstack_deploy/openstack_user_config.yml" config_overrides: "{{ openstack_user_config_overrides | default({}) }}" config_type: "yaml" 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 352d800148..63bcc4ffdd 100644 --- a/tests/roles/bootstrap-host/templates/user_variables.aio.yml.j2 +++ b/tests/roles/bootstrap-host/templates/user_variables.aio.yml.j2 @@ -17,15 +17,15 @@ debug: True ## Installation method for OpenStack services -install_method: "{{ lookup('env','INSTALL_METHOD') | default('source', true) }}" +install_method: "{{ bootstrap_host_install_method }}" ## Tempest settings -{% if container_tech == 'nspawn' %} +{% if bootstrap_host_container_tech == 'nspawn' %} tempest_public_subnet_cidr: "172.29.236.0/22" tempest_public_subnet_allocation_pools: "172.29.239.110-172.29.239.200" {% else %} ## Tempest settings -tempest_public_subnet_cidr: 172.29.248.0/22 +tempest_public_subnet_cidr: "172.29.248.0/22" tempest_public_subnet_allocation_pools: "172.29.249.110-172.29.249.200" {% endif %} @@ -155,7 +155,7 @@ lxc_net_address: 10.255.255.1 lxc_net_netmask: 255.255.255.0 lxc_net_dhcp_range: 10.255.255.2,10.255.255.253 -{% if repo_build_pip_extra_indexes is defined and repo_build_pip_extra_indexes|length > 0 %} +{% if repo_build_pip_extra_indexes is defined and repo_build_pip_extra_indexes | length > 0 %} ## Wheel mirrors for the repo_build to use repo_build_pip_extra_indexes: {{ repo_build_pip_extra_indexes | to_nice_yaml }} @@ -205,5 +205,5 @@ openstack_user_kernel_options: {% if bootstrap_host_scenario in ['octavia'] %} # Octavia specific stuff neutron_lbaas_octavia: True -octavia_management_net_subnet_cidr: "{{ (container_tech == 'nspawn') | ternary('172.29.240.0/22', '172.29.252.0/22') }}" +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/templates/user_variables_translations.yml.j2 b/tests/roles/bootstrap-host/templates/user_variables_translations.yml.j2 index 56e700bdae..ccc734800f 100644 --- a/tests/roles/bootstrap-host/templates/user_variables_translations.yml.j2 +++ b/tests/roles/bootstrap-host/templates/user_variables_translations.yml.j2 @@ -18,7 +18,7 @@ trove_provider_net_name: flat-db trove_service_net_phys_net: flat-db trove_service_net_setup: True -{% if container_tech == 'nspawn' %} +{% if bootstrap_host_container_tech == 'nspawn' %} trove_service_net_subnet_cidr: "172.29.236.0/22" trove_service_net_allocation_pool_start: "172.29.237.110" trove_service_net_allocation_pool_end: "172.29.237.200"