output of list_vms does not have stdout

10 views
Skip to first unread message

Mauricio Tavares

unread,
Jan 11, 2020, 10:06:02 PM1/11/20
to ansible...@googlegroups.com
So I have the following tasks

name: get running guests
virt:
command: "list_vms"
register: vms
when: test_kvm |default(False)

- name: List running guests
debug:
msg: "{{ vms }}"
when: test_kvm |default(False)

I would expect when you register a variable, you should see stdout
associated with this variable. Instead,

ok: [vmhost] => {
"msg": {
"changed": false,
"failed": false,
"list_vms": [
"testcentos"
]
}
}

Is there a bit of inconsistency going on here or am I just confused?

Vladimir Botka

unread,
Jan 12, 2020, 1:47:08 AM1/12/20
to Mauricio Tavares, ansible...@googlegroups.com
On Sat, 11 Jan 2020 22:05:36 -0500
Mauricio Tavares <raub...@gmail.com> wrote:

> name: get running guests
> virt:
> command: "list_vms"
> register: vms
> [...]
> I would expect when you register a variable, you should see stdout
> associated with this variable. Instead,
>
> ok: [vmhost] => {
> "msg": {
> "changed": false,
> "failed": false,
> "list_vms": [
> "testcentos"
> ]
> }
> }
>
> Is there a bit of inconsistency going on here or am I just confused?

It's not a general rule that stdout is included in the data returned by a
module. It depends on the developers. In this particular case the returned
data is as designed. Quoting from the doc:

RETURN VALUES:

# for list_vms command
list_vms:
description: The list of vms defined on the remote system
type: list
returned: success
sample: [
"build.example.org",
"dev.example.org"
]

HTH,

-vlado
Reply all
Reply to author
Forward
0 new messages