summaryrefslogtreecommitdiffstats
path: root/scripts/freezelist
blob: 1468e525c89d99231f6cbca0625f50de7924ee42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python
# skvidal
# dump out the hosts marked with 'freezes: true' in their vars


import ansible.inventory
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()


frozen = []
unfrozen = []
for host in sorted(inv.get_hosts()):
    vars = inv.get_variables(host.name)
    freezes = vars.get('freezes', None)

    if freezes:
        frozen.append(host.name)
    elif freezes is None:
        print 'Error: missing freezes: %s' % host.name
    else:
        unfrozen.append(host.name)

print 'freeze:'
for host in sorted(frozen):
    print 'F: ' + host


print 'do not freeze:'
for host in sorted(unfrozen):
    print 'NF: ' + host