Formatting in debug

36 views
Skip to first unread message

Veera

unread,
May 15, 2023, 2:24:07 AM5/15/23
to Ansible Project
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 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"
from the above debug output as a variable for my next play .




Kosala Atapattu

unread,
May 15, 2023, 2:34:25 AM5/15/23
to ansible...@googlegroups.com
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,
Kosala




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7bc37be6-dd57-47c4-b634-54cb521489b5n%40googlegroups.com.

Veera

unread,
May 15, 2023, 2:48:06 AM5/15/23
to Ansible Project
Hi,

No  STDOUT  or stdout_lines present.  After "msg" the output has only one line inside a {} .

Dick Visser

unread,
May 15, 2023, 3:57:54 AM5/15/23
to ansible...@googlegroups.com
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....


Veera

unread,
May 15, 2023, 4:25:14 AM5/15/23
to Ansible Project

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 .. 

Dick Visser

unread,
May 15, 2023, 6:02:21 AM5/15/23
to ansible...@googlegroups.com
On Mon, 15 May 2023 at 10:25, Veera <svee...@gmail.com> wrote:
>
>
> yes... I was using set_fact and the output shown above is the debug output of the set_fact.

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

Veera

unread,
May 17, 2023, 8:43:46 AM5/17/23
to Ansible Project
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 ..

Dick Visser

unread,
May 17, 2023, 9:25:24 AM5/17/23
to ansible...@googlegroups.com
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...?
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2c2b1e20-d691-457c-8a4d-6b0c4e3a558bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages