Easy way to parse out.stdout_lines to get the value?

27 views
Skip to first unread message

Rubén Ortiz

unread,
Aug 19, 2016, 7:06:10 AM8/19/16
to Ansible Project

I have a silly playbook which just runs a command to get the list of vhost in every host on webserver group. As all vhost are located in /var/www is easy to get the list of webs.

The problem is the way of Ansible returns the info. For example:

ok: [host1] => {
    "var": {
        "out.stdout_lines": [
            "",
            "host1.com"
        ]
    }
}
ok: [host2] => {
    "var": {
        "out.stdout_lines": [
            "",
            "host2.com"
        ]
    }
}

Do you know an easy way to just get the name of the vhosts? Using grep awk or something like that?

Kai Stian Olstad

unread,
Aug 19, 2016, 8:44:30 AM8/19/16
to ansible...@googlegroups.com
Maybe Ansible ad-hoc is something too use
ansible webservers -a "ls /var/www" | egrep -v ">>|^$"

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages