-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinventory.py
More file actions
40 lines (35 loc) · 846 Bytes
/
Copy pathinventory.py
File metadata and controls
40 lines (35 loc) · 846 Bytes
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
#!/usr/bin/env python3
import json
import sys
# Variáveis específicas de cada host
HOSTVARS = {
"w3.example.net": {
"webserver_port": 80
}
}
def main():
if len(sys.argv) == 2 and sys.argv[1] == "--list":
inventory = {
"webservers": {
"hosts": ["web.example.net", "w3.example.net"]
},
"dbservers": {
"hosts": ["db.example.net"]
},
"office": {
"hosts": ["off1.example.net"]
},
"windows": {
"children": [
"office"
]
},
"_meta": {
"hostvars": HOSTVARS
}
}
print(json.dumps(inventory))
else:
print(json.dumps({}))
if __name__ == "__main__":
main()