This Python script automates the setup and validation of machine configurations, ensuring they meet predefined requirements. It also provides an option to install Nginx on the machines.
- Accepts user input to define new machines
- Validates machine configurations using JSON schema
- Prevents duplicate IP addresses
- Saves machine configurations to a JSON file
- Runs a Bash script to install Nginx (optional)
- Logs all activities for troubleshooting
- Python 3.13.2
- Required Python packages:
jsonloggingsubprocessjsonschema
- A valid
configs/instances.jsonfile (if not present, create an empty JSON array[]) - A Bash script
Scripts/nginx_installtion.shfor Nginx installation
- Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On macOS/Linux venv\Scripts\activate # On Windows
- Install dependencies from
requirements.txt:pip install -r requirements.txt
- Run the script:
python infra_simulator.py
- Enter machine details when prompted, including:
- Machine name
- IP address
- Operating system (e.g., Ubuntu, CentOS)
- CPU configuration (e.g., 2vCPU)
- RAM size (GB)
- The script will validate the configuration and save it if valid.
- Optionally, install Nginx by selecting "yes" when prompted.
- Logs are stored in
logs/provisioning.logfor debugging.
- If a validation error occurs, check
logs/provisioning.log. - If the script cannot execute the Bash script, ensure it has execution permissions:
chmod +x Scripts/nginx_installtion.sh