#4848 create script to list hosts matching arbitrary ansible vars
Closed: Fixed None Opened 8 years ago by kevin.

we currently have a 'freezelist' script in ansible/scripts/freezelist that lists all the hosts in the inventory that have 'freezes: true' and 'freezes: false'.

It would be nice to generalize this so you can specify a variable and value and list all hosts that have that variable at that value.

This could be used for example for listing all hosts that have a specific fas group with access or all hosts with some nfs mounts,etc


I'd like to work on this.
kindly review the attached script. use -o var=value.

Can't seem to get it working here. ;(

{{{
~/hosts_with_var_set.py -i /srv/web/infra/ansible/inventory -o var=vmhost
hosts with var:
}}}

This is on lockbox01...

Replying to [comment:3 kevin]:

Can't seem to get it working here. ;(

{{{
~/hosts_with_var_set.py -i /srv/web/infra/ansible/inventory -o var=vmhost
hosts with var:
}}}

This is on lockbox01...

sorry for the confusion, but its more like: ~/hosts_with_var_set.py -o vmhost=virthost02.phx2.fedoraproject.org

or should it be vmhost set/unset only?

ah, I see. Yep. That does the trick. ;)

Commiting it to ansible. Thanks!

Login to comment on this ticket.

Metadata