From 167e2ff3db19f32544e324bd02f4586e36486650 Mon Sep 17 00:00:00 2001
From: Doug Szumski <doug@stackhpc.com>
Date: Fri, 21 Feb 2020 15:43:46 +0000
Subject: [PATCH] Fix Kayobe overcloud introspection data save

Kayobe overcloud introspection data save fails because the dynamic
inventory script siliently breaks causing Ansible to parse it as a
static inventory file. The failure occurs due to OS_TOKEN being set.
This change works around setting OS_TOKEN before running the dynamic
inventory script by setting OS_CLOUD before querying inspector.

Confirmed on Stein and Train, and verified in both environments.

Story: 2007326
Task: 38846
Change-Id: I57fbf91ae3440d3e4e6a64cd7d05151e299c9322
---
 ansible/overcloud-introspection-data-save.yml               | 3 +--
 .../notes/fix-introspection-data-save-cfc83714f66fd63c.yaml | 6 ++++++
 2 files changed, 7 insertions(+), 2 deletions(-)
 create mode 100644 releasenotes/notes/fix-introspection-data-save-cfc83714f66fd63c.yaml

diff --git a/ansible/overcloud-introspection-data-save.yml b/ansible/overcloud-introspection-data-save.yml
index 9ffa8133e..2cd80bc2e 100644
--- a/ansible/overcloud-introspection-data-save.yml
+++ b/ansible/overcloud-introspection-data-save.yml
@@ -13,7 +13,6 @@
       command: >
         docker exec bifrost_deploy
         bash -c '
-        export OS_TOKEN=fake-token &&
         export BIFROST_INVENTORY_SOURCE=ironic &&
         ansible baremetal
         --connection local
@@ -22,7 +21,7 @@
         -e @/etc/bifrost/dib.yml
         --limit {{ inventory_hostname }}
         -m shell
-        -a "env OS_URL=http://localhost:5050 openstack baremetal introspection data save {% raw %}{{ inventory_hostname }}{% endraw %}"'
+        -a "env OS_CLOUD=bifrost-inspector openstack baremetal introspection data save {% raw %}{{ inventory_hostname }}{% endraw %}"'
       register: save_result
       changed_when: False
       # Ignore errors, log a message later.
diff --git a/releasenotes/notes/fix-introspection-data-save-cfc83714f66fd63c.yaml b/releasenotes/notes/fix-introspection-data-save-cfc83714f66fd63c.yaml
new file mode 100644
index 000000000..3a32c45c7
--- /dev/null
+++ b/releasenotes/notes/fix-introspection-data-save-cfc83714f66fd63c.yaml
@@ -0,0 +1,6 @@
+---
+fixes:
+  - |
+    Fixes a bug where introspection data save would fail.
+    See `Story 2007326 <https://storyboard.openstack.org/#!/story/2007326>`_
+    for more details.