From cfb5c004eafd7df7e0c5e94b7697811e174301ff Mon Sep 17 00:00:00 2001
From: Michal Nasiadka <mnasiadka@gmail.com>
Date: Wed, 31 Aug 2022 10:10:02 +0200
Subject: [PATCH] nclu-switch: Fix order in template

Currently description is applied first to the interface, but if it's a
virtual one - it won't exist before running the configuration commands.

Story: 2010279
Task: 46232

Change-Id: I40212b40a4d391272f4063f42e8a7043b3d58fd7
---
 ansible/roles/nclu-switch/templates/nclu-config.j2  | 6 +++---
 releasenotes/notes/nclu-order-dc4cb33d633b73a2.yaml | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 releasenotes/notes/nclu-order-dc4cb33d633b73a2.yaml

diff --git a/ansible/roles/nclu-switch/templates/nclu-config.j2 b/ansible/roles/nclu-switch/templates/nclu-config.j2
index 8177e892..96d1bdc0 100644
--- a/ansible/roles/nclu-switch/templates/nclu-config.j2
+++ b/ansible/roles/nclu-switch/templates/nclu-config.j2
@@ -4,10 +4,10 @@
 {% endfor %}
 
 {% for interface, config in nclu_switch_interface_config.items() %}
-{% if config.description is defined %}
-add {{ config.type | default("interface") }} {{ interface }} alias {{ config.description }}
-{% endif %}
 {% for line in config.config %}
 add {{ config.type | default("interface") }} {{ interface }} {{ line }}
 {% endfor %}
+{% if config.description is defined %}
+add {{ config.type | default("interface") }} {{ interface }} alias {{ config.description }}
+{% endif %}
 {% endfor %}
diff --git a/releasenotes/notes/nclu-order-dc4cb33d633b73a2.yaml b/releasenotes/notes/nclu-order-dc4cb33d633b73a2.yaml
new file mode 100644
index 00000000..68c45f34
--- /dev/null
+++ b/releasenotes/notes/nclu-order-dc4cb33d633b73a2.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Fixes an issue with nclu-switch command ordering, when description was
+    applied first to a non-existent (virtual) interface. See `story 2010279
+    <https://storyboard.openstack.org/#!/story/2010279>`__ for details.
-- 
GitLab