add -i to freezelist
also make it report any host without freezes defined at all
This commit is contained in:
parent
4a496a72c8
commit
1c88ae6902
1 changed files with 16 additions and 2 deletions
|
@ -5,16 +5,30 @@
|
||||||
|
|
||||||
import ansible.inventory
|
import ansible.inventory
|
||||||
import sys
|
import sys
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
parser = OptionParser(version = "1.0")
|
||||||
|
parser.add_option('-i', dest='inventory', default=None,
|
||||||
|
help="Path to inventory file/dir")
|
||||||
|
opts,args = parser.parse_args(sys.argv[1:])
|
||||||
|
|
||||||
|
if opts.inventory:
|
||||||
|
inv = ansible.inventory.Inventory(host_list=opts.inventory)
|
||||||
|
else:
|
||||||
|
inv = ansible.inventory.Inventory()
|
||||||
|
|
||||||
|
|
||||||
inv = ansible.inventory.Inventory()
|
|
||||||
frozen = []
|
frozen = []
|
||||||
unfrozen = []
|
unfrozen = []
|
||||||
for host in sorted(inv.get_hosts()):
|
for host in sorted(inv.get_hosts()):
|
||||||
vars = inv.get_variables(host.name)
|
vars = inv.get_variables(host.name)
|
||||||
freezes = vars.get('freezes', None)
|
freezes = vars.get('freezes', None)
|
||||||
|
|
||||||
if freezes:
|
if freezes:
|
||||||
frozen.append(host.name)
|
frozen.append(host.name)
|
||||||
elif freezes == 'None':
|
elif freezes is None:
|
||||||
print 'Error: missing freezes: %s' % host.name
|
print 'Error: missing freezes: %s' % host.name
|
||||||
else:
|
else:
|
||||||
unfrozen.append(host.name)
|
unfrozen.append(host.name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue