level up ansible stuff
This commit is contained in:
		
							parent
							
								
									495e8bd09c
								
							
						
					
					
						commit
						9cfe1f008f
					
				
					 3 changed files with 24 additions and 1 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					.venv
 | 
				
			||||||
 | 
					inventory.yaml
 | 
				
			||||||
							
								
								
									
										21
									
								
								mkinv
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								mkinv
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					import yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def main():
 | 
				
			||||||
 | 
					    hosts = {}
 | 
				
			||||||
 | 
					    counter = 0
 | 
				
			||||||
 | 
					    for addr in sys.argv[1:]:
 | 
				
			||||||
 | 
					        hosts[f"vm{counter}"] = { "ansible_host": addr }
 | 
				
			||||||
 | 
					        counter += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    inventory = { "all": { "hosts": hosts } }
 | 
				
			||||||
 | 
					    inventory_yaml = yaml.dump(inventory)
 | 
				
			||||||
 | 
					    print(inventory_yaml)
 | 
				
			||||||
 | 
					#   with open("./inventory.yaml", "w", encoding="utf8") as inv_file:
 | 
				
			||||||
 | 
					#       inv_file.write(inventory_yaml)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if __name__ == "__main__":
 | 
				
			||||||
 | 
					    main()
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ http {
 | 
				
			||||||
  server {
 | 
					  server {
 | 
				
			||||||
    listen 80 default_server;
 | 
					    listen 80 default_server;
 | 
				
			||||||
    location / {
 | 
					    location / {
 | 
				
			||||||
      return 200 ">>>>>>>>>> My ip is: {{ inventory_hostname }} <<<<<<<<<<\n";
 | 
					      return 200 ">>>>>>>>>> I am {{ inventory_hostname }} ({{ ipv4.address }}) <<<<<<<<<<\n";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue