Thanks for the reply.
Yep, I've already been doing that in a playbook, I just wondered if it was
possible to do using an adhoc command. That way I can quickly run a command
to say, list all machines running CentOS or all machines that are HP or
based on any other fact.
I guess the answer is that the filter parameter of the setup doesn't
currently allow for more than matching on a fact name.
On Friday, 18 July 2014 02:37:02 UTC+1, Michael DeHaan wrote:
>
> This may be useful, untested quick sketch though...
>
> Take a look at the group_by parameter to select all hosts where a fact has
> a certain value.
>
> - hosts: all
> tasks:
> - group_by: key=ansible_system_vendor_{{ ansible_system_vendor }}
>
> - hosts: ansible_system_vendor_HP
> tasks:
> - debug: msg="{{ inventory_hostname }} is an HP"
>
>
>
>
>
>
> On Thu, Jul 17, 2014 at 12:59 PM, KSS <[email protected] <javascript:>>
> wrote:
>
>> Hi,
>>
>> Is it possible to use the setup module along with the filter parameter to
>> return something based on the value of fact?
>>
>> For example, I want to quickly get a list of all my machines in ansible
>> that are VMWare based using an ad-hoc command. I can run the following to
>> get the vendor;
>>
>> ansible -i inventory all -m setup -a "filter=ansible_system_vendor" -o
>> 10.0.XXX.XXX | success >> {"ansible_facts": {"ansible_system_vendor":
>> "VMware, Inc."}, "changed": false}
>> 10.0.XXX.XXX | success >> {"ansible_facts": {"ansible_system_vendor":
>> "VMware, Inc."}, "changed": false}
>> 10.0.XXX.XXX | success >> {"ansible_facts": {"ansible_system_vendor":
>> "HP"}, "changed": false}
>>
>> And I can pipe the result though grep to get what I need, but is there
>> any way to quickly list all hosts by the value of a certain fact?
>>
>> Thanks.
>>
>> --
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/06e3878e-e78c-4525-adcd-71d9d19d2eea%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/ansible-project/06e3878e-e78c-4525-adcd-71d9d19d2eea%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/bf626860-ff81-4418-8b9f-5e60c8e90721%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.