# Formatting in debug

**URL:** <https://forum.ansible.com/t/formatting-in-debug/37982>\
**Category:** Ansible Project\
**Created:** [May 15, 2023, 6:24am UTC](https://forum.ansible.com/t/formatting-in-debug/37982 "2023-05-15T06:24:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Veera](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/veera/32/4107_2.png) [@Veera](https://forum.ansible.com/u/Veera)\
**Post date:** [May 15, 2023, 6:24am UTC](https://forum.ansible.com/t/formatting-in-debug/37982/1 "2023-05-15T06:24:07Z")

</div>

Hello,

While i try to grep/cut the url from my below debug output , I am unable to get the exact output. I tried with split, dict2items ,item2dicts to break it and grep the exact line .

TASK [debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Monday 15 May 2023 09:10:06 +0300 (0:00:00.027) 0:00:02.906 \*\*\*\*\*\*\*\*\*\*\*\*  
ok: [localhost] =\> {  
“msg”: “export OS\_AUTH\_URL=[https://mydomain.net:9001/v3\nexport](https://mydomain.net:9001/v3%5Cnexport) OS\_PROJECT\_ID=abcdefghijklmnopqwertyuu\nexport OS\_PROJECT\_NAME="my\_project"\nexport OS\_USER\_DOMAIN\_NAME="Default"\nif [-z "$OS\_USER\_DOMAIN\_NAME"]; then unset OS\_USER\_DOMAIN\_NAME; fi\nexport OS\_PROJECT\_DOMAIN\_ID="default"\nif [-z "$OS\_PROJECT\_DOMAIN\_ID"]; then unset OS\_PROJECT\_DOMAIN\_ID; fi\nunset OS\_TENANT\_ID\nunset OS\_TENANT\_NAME\nexport OS\_USERNAME="my\_project"\nexport OS\_INTERFACE=public\nexport OS\_IDENTITY\_API\_VERSION=3”  
}

I need only the string “[https://mydomain.net:9001/v3](https://mydomain.net:9001/v3)”  
from the above debug output as a variable for my next play .

---

<div class="post-metadata">

**Author:** ![Kosala\_Atapattu1](https://avatars.discourse-cdn.com/v4/letter/k/7feea3/32.png) [@Kosala\_Atapattu1](https://forum.ansible.com/u/Kosala_Atapattu1)\
**Post date:** [May 15, 2023, 6:33am UTC](https://forum.ansible.com/t/formatting-in-debug/37982/2 "2023-05-15T06:33:57Z")

</div>

If you get more verbose, you the the output with STDOUT and STDOUT\_LINES. STDOUT\_LINESis the closest you get for what you’re after. May be callback\_plugin may help… not sure, never tried that.

Cheers,

---

<div class="post-metadata">

**Author:** ![Veera](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/veera/32/4107_2.png) [@Veera](https://forum.ansible.com/u/Veera)\
**Post date:** [May 15, 2023, 6:48am UTC](https://forum.ansible.com/t/formatting-in-debug/37982/3 "2023-05-15T06:48:06Z")

</div>

Hi,

No STDOUT or stdout\_lines present. After “msg” the output has only one line inside a {} .

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [May 15, 2023, 7:57am UTC](https://forum.ansible.com/t/formatting-in-debug/37982/4 "2023-05-15T07:57:20Z")

</div>

Don’t parse the console output, use set\_fact to fetch it.  
The important question is: what does your debug command look like?  
It all sounds like you should be doing something simpler earlier on…

---

<div class="post-metadata">

**Author:** ![Veera](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/veera/32/4107_2.png) [@Veera](https://forum.ansible.com/u/Veera)\
**Post date:** [May 15, 2023, 8:25am UTC](https://forum.ansible.com/t/formatting-in-debug/37982/5 "2023-05-15T08:25:14Z")

</div>

yes… I was using set\_fact and the output shown above is the debug output of the set\_fact.

Still to fetch the URL alone from the output(debug) of the set\_fact , and to set it as a new variable( using set\_fact) … which is what i am looking for …

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [May 15, 2023, 10:01am UTC](https://forum.ansible.com/t/formatting-in-debug/37982/6 "2023-05-15T10:01:46Z")

</div>

OK, so my question is: what does your set\_fact task look like? I.e.  
where do you get that string from?

---

<div class="post-metadata">

**Author:** ![Veera](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/veera/32/4107_2.png) [@Veera](https://forum.ansible.com/u/Veera)\
**Post date:** [May 17, 2023, 12:43pm UTC](https://forum.ansible.com/t/formatting-in-debug/37982/7 "2023-05-17T12:43:46Z")

</div>

The setfact task has the contents of a keystone rc file .  
However I got the result by writing it into a file , replace the string, read the required lines and then deleted the file …

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [May 17, 2023, 1:24pm UTC](https://forum.ansible.com/t/formatting-in-debug/37982/8 "2023-05-17T13:24:52Z")

</div>

So how is the keystone rc file being populated?  
Are you perhaps trying to manage a host with ansible, that is already  
managed in some other way...?
