From 2f37a61a46eaafeb1622b6cc1340692083f0ab41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Va=C5=A1ek?= Date: Thu, 30 Sep 2021 12:24:07 +0200 Subject: [PATCH] [CI] Make devstack local.conf configurable (#1651) * install-devstack now generates local.conf from a template * test-occm-e2e: specify which devstack services to enable * tempate expressions must be in quotes * add enable_services var to defaults/main.yaml * removed enable_plugin calls where not needed * local.conf template: move rest of the sections to the bottom of the file --- .../roles/install-devstack/defaults/main.yaml | 9 +- .../roles/install-devstack/tasks/main.yml | 19 +-- .../install-devstack/templates/local.conf.j2 | 119 ++++++++++++++++++ tests/playbooks/test-occm-e2e.yaml | 9 +- 4 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 tests/playbooks/roles/install-devstack/templates/local.conf.j2 diff --git a/tests/playbooks/roles/install-devstack/defaults/main.yaml b/tests/playbooks/roles/install-devstack/defaults/main.yaml index cdbe2cad2a..10ee4cd329 100644 --- a/tests/playbooks/roles/install-devstack/defaults/main.yaml +++ b/tests/playbooks/roles/install-devstack/defaults/main.yaml @@ -1,4 +1,11 @@ --- user: "stack" workdir: "/home/{{ user }}/devstack" -branch: "stable/wallaby" \ No newline at end of file +branch: "stable/wallaby" +enable_services: + - nova + - glance + - cinder + - neutron + - octavia + - barbican diff --git a/tests/playbooks/roles/install-devstack/tasks/main.yml b/tests/playbooks/roles/install-devstack/tasks/main.yml index 6e91cdfb23..4cb14c232b 100644 --- a/tests/playbooks/roles/install-devstack/tasks/main.yml +++ b/tests/playbooks/roles/install-devstack/tasks/main.yml @@ -62,16 +62,21 @@ version: "{{ branch }}" force: false - - name: Prepare local.conf + - name: Retrieve local IP address shell: executable: /bin/bash cmd: | set -ex - branch={{ branch }} - curl -sSL https://gist.github.com/lingxiankong/a109303f48e9a74fc8a7c01de4156d71/raw -o {{ workdir }}/local.conf - local_ip=$(ip route get 8.8.8.8 | head -1 | awk '{print $7}') - sed -i "s/LOCAL_IP_ADDRESS/$local_ip/g" {{ workdir }}/local.conf - sed -i "s,MYBRANCH,$branch,g" {{ workdir }}/local.conf + ip route get 8.8.8.8 | head -1 | awk '{print $7}' + register: local_ip_output + + - set_fact: + local_ip_address: "{{ local_ip_output.stdout }}" + + - name: Prepare local.conf + template: + src: local.conf.j2 + dest: "{{ workdir }}/local.conf" - name: Fix localhost shell: @@ -107,4 +112,4 @@ executable: /bin/bash cmd: | # To avoid the warning msg: "CryptographyDeprecationWarning: int_from_bytes is deprecated, use int.from_bytes instead" - python3 -m pip install cryptography==3.3.2 \ No newline at end of file + python3 -m pip install cryptography==3.3.2 diff --git a/tests/playbooks/roles/install-devstack/templates/local.conf.j2 b/tests/playbooks/roles/install-devstack/templates/local.conf.j2 new file mode 100644 index 0000000000..e0c6194345 --- /dev/null +++ b/tests/playbooks/roles/install-devstack/templates/local.conf.j2 @@ -0,0 +1,119 @@ +[[local|localrc]] +RECLONE=False +HOST_IP={{ local_ip_address }} +DEST=/opt/stack +DATA_DIR=${DEST}/data +USE_PYTHON3=True +LOGFILE=$DEST/logs/stack.sh.log +VERBOSE=True +LOG_COLOR=False +LOGDAYS=1 +SERVICE_TIMEOUT=300 + +DATABASE_PASSWORD=password +ADMIN_PASSWORD=password +SERVICE_PASSWORD=password +SERVICE_TOKEN=password +RABBIT_PASSWORD=password + +TARGET_BRANCH={{ branch }} + +ENABLED_SERVICES=rabbit,mysql,key + +{% if "nova" in enable_services %} +# Nova +enable_service n-api +enable_service n-cpu +enable_service n-cond +enable_service n-sch +enable_service n-api-meta + +enable_service placement-api +enable_service placement-client +{% endif %} + +{% if "glance" in enable_services %} +# Glance +enable_service g-api +enable_service g-reg +{% endif %} + +{% if "cinder" in enable_services %} +# Cinder +enable_service cinder +enable_service c-api +enable_service c-vol +enable_service c-sch +{% endif %} + +{% if "neutron" in enable_services %} +# Neutron +enable_plugin neutron https://opendev.org/openstack/neutron.git {{ branch }} +enable_service q-svc +enable_service q-agt +enable_service q-dhcp +enable_service q-l3 +enable_service q-meta +IP_VERSION=4 +IPV4_ADDRS_SAFE_TO_USE=10.1.0.0/26 +FIXED_RANGE=10.1.0.0/26 +NETWORK_GATEWAY=10.1.0.1 +FLOATING_RANGE=172.24.5.0/24 +PUBLIC_NETWORK_GATEWAY=172.24.5.1 +Q_PLUGIN=ml2 +Q_ML2_TENANT_NETWORK_TYPE=vxlan +Q_DVR_MODE=legacy +Q_AGENT=openvswitch +Q_ML2_PLUGIN_MECHANISM_DRIVERS=openvswitch +{% endif %} + +{% if "octavia" in enable_services %} +# Octavia +enable_plugin octavia https://opendev.org/openstack/octavia.git {{ branch }} +enable_service octavia +enable_service o-cw +enable_service o-hm +enable_service o-hk +enable_service o-api + +LIBS_FROM_GIT+=,python-octaviaclient + +OCTAVIA_MGMT_SUBNET=10.51.0.0/16 +OCTAVIA_MGMT_SUBNET_START=10.51.0.2 +OCTAVIA_MGMT_SUBNET_END=10.51.0.254 +{% endif %} + +{% if "barbican" in enable_services %} +# Barbican +enable_plugin barbican https://opendev.org/openstack/barbican.git {{ branch }} +enable_service barbican-vault + +LIBS_FROM_GIT+=,python-barbicanclient +{% endif %} + +{% if "glance" in enable_services %} +[[post-config|$GLANCE_API_CONF]] +[glance_store] +default_store = file +{% endif %} + +{% if "neutron" in enable_services %} +[[post-config|$NEUTRON_CONF]] +[DEFAULT] +global_physnet_mtu = 1430 +{% endif %} + +{% if "octavia" in enable_services %} +[[post-config|$OCTAVIA_CONF]] +[api_settings] +allow_tls_terminated_listeners = True +[controller_worker] +loadbalancer_topology = SINGLE +amp_active_retries = 60 +amp_active_wait_sec = 10 +[haproxy_amphora] +rest_request_conn_timeout = 300 +rest_request_read_timeout = 600 +[health_manager] +health_check_interval = 30 +{% endif %} diff --git a/tests/playbooks/test-occm-e2e.yaml b/tests/playbooks/test-occm-e2e.yaml index 958ebd59c3..ce34152610 100644 --- a/tests/playbooks/test-occm-e2e.yaml +++ b/tests/playbooks/test-occm-e2e.yaml @@ -12,6 +12,13 @@ roles: - role: install-golang - role: install-devstack + enable_services: + - nova + - glance + - cinder + - neutron + - octavia + - barbican - role: install-k3s worker_node_count: 0 k8s_branch: release-1.22 @@ -19,4 +26,4 @@ - role: install-docker-registry cert_hosts: ' ["{{ ansible_default_ipv4.address }}"]' - role: install-cpo-occm - environment: "{{ global_env }}" \ No newline at end of file + environment: "{{ global_env }}"