From 94bea77fd75f8ff1453283d6c0013f51ebf2f742 Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Wed, 24 Mar 2021 18:03:20 +0100 Subject: [PATCH] migration: Remove crudini when migrating tunnels It turned out there doesn't need to be crudini tool present on the node running the command. This patch fetches the Neutron conf file instead and performs an ini lookup over it in order to get the DB connection string. Change-Id: Iaf79b8512a920e9f667bd6881d50e8852595fa71 Signed-off-by: Jakub Libosvar --- .../roles/prepare-controllers/defaults/main.yml | 1 + .../roles/prepare-controllers/tasks/main.yml | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/defaults/main.yml b/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/defaults/main.yml index c7f133d1921..47b301794db 100644 --- a/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/defaults/main.yml +++ b/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/defaults/main.yml @@ -1,2 +1,3 @@ --- neutron_conf_path: /var/lib/config-data/puppet-generated/neutron/etc/neutron/neutron.conf +neutron_conf_tempfile: /tmp/neutron.conf diff --git a/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/tasks/main.yml b/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/tasks/main.yml index 949656e8ce3..13419328fea 100644 --- a/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/tasks/main.yml +++ b/tools/ovn_migration/tripleo_environment/playbooks/roles/prepare-controllers/tasks/main.yml @@ -1,8 +1,15 @@ --- -- name: Get DB connection string - command: crudini --get {{ neutron_conf_path }} database connection +- name: Fetch neutron configuration + fetch: + src: "{{ neutron_conf_path }}" + dest: "{{ neutron_conf_tempfile }}" + flat: yes + when: ovn_central is defined + +- name: Get DB connection string + set_fact: + db_connection_string: "{{ lookup('ini', 'connection section=database file={{ neutron_conf_tempfile }}') }}" when: ovn_central is defined - register: mysql_url # The shell below is not readable well. The code spawns a sqlalchemy engine # and connects to the Neutron database to run following SQL command: @@ -16,5 +23,5 @@ # conn.execute("SQL COMMAND") # - name: Change vxlan networks to Geneve - shell: podman exec -it neutron_api python3 -c $'from sqlalchemy import create_engine\nengine = create_engine("{{ mysql_url.stdout }}")\nwith engine.connect() as conn:\n\tconn.execute("update networksegments set networksegments.network_type=\'geneve\' where networksegments.network_type=\'vxlan\';")' + shell: podman exec -it neutron_api python3 -c $'from sqlalchemy import create_engine\nengine = create_engine("{{ db_connection_string }}")\nwith engine.connect() as conn:\n\tconn.execute("update networksegments set networksegments.network_type=\'geneve\' where networksegments.network_type=\'vxlan\';")' when: ovn_central is defined