This project is designed to generate and execute Ansible playbooks using Large Language Models (LLMs). It takes a user requirement, refines it into a prompt, and generates a playbook through multiple iterations of refining and validation.
- Refine user requirements using an LLM
- Generate end-state descriptions in JSON format
- Concurrently request IaC code generation from multiple LLMs
- Validate and format the generated playbook
- Execute the Ansible playbook and capture errors
- Iteratively refine the playbook based on execution feedback
- Python 3.7+
- Ansible
-
Clone the repository:
git clone https://github.com/open-SDI/IaC.git cd IaC
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required Python packages:
pip install -r requirements.txt
-
Ensure Ansible is installed on your system. You can install it using:
pip install ansible
-
Run the main script:
python main.py
-
Enter your requirement for the Ansible playbook when prompted.
-
Provide additional information if requested.
-
The script will generate and execute the playbook iteratively, refining it based on the feedback and errors encountered.
- The configuration for LLM endpoints and models is defined in the script.
- You may need to update the IP addresses and model IDs as per your setup.
- Logs are saved in the
playbook_output_<timestamp>
directory created during execution. - Logs include detailed information about each iteration, including prompts, responses, and errors.