File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
inventory/vagrants/inventory_dir Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
- #!/usr/bin/env python
1
+ #!/usr/bin/env python3
2
2
# NOTE: this file must be executable `chmod +x centos.py`
3
3
# challenge: make this file not executable and see what `ansible-inventory --list` prints
4
4
24
24
# challenge: port ubuntu static inventory to script too
25
25
# challenge: port centos.py script (this file) back into static inventory
26
26
for i in range (2 ):
27
- inventory ["_meta" ]["hostvars" ]["centos2{:d}" .format (i )] = {
28
- "ansible_host" : "192.168.50.2{:d}" .format (i ),
29
- "ansible_private_key_file" : ".vagrant/machines/centos2{:d}/virtualbox/private_key" .format (i )
27
+ host = f"centos2{ i } "
28
+ inventory ["_meta" ]["hostvars" ][host ] = {
29
+ "ansible_host" : f"192.168.50.2{ i } " ,
30
+ "ansible_private_key_file" : f".vagrant/machines/{ host } /virtualbox/private_key"
30
31
}
31
- inventory ["centos" ]["hosts" ].append ("centos2{:d}" . format ( i ) )
32
+ inventory ["centos" ]["hosts" ].append (host )
32
33
33
34
# python json API https://docs.python.org/3/library/json.html
34
35
# script returns inventory formatted as json to ansible
You can’t perform that action at this time.
0 commit comments