proxmox-ansible system configurator

apuctokpat

New Member
Mar 27, 2024
2
4
3
Proxmox Ansible Playbook: Automate Your Proxmox Setup and Management! (Beta Version)

Hi everyone!

I’m excited to share the first BETA version of my Ansible playbook, designed to automate the configuration, optimization, and management of Proxmox VE.

The idea to create this playbook came from my own experience — I couldn’t find a good tool online for provisioning Proxmox hosts that met my needs. So, I decided to build my own solution from scratch. I hope this tool will save you time and effort when working with Proxmox!

Please note that this is a work in progress, and I’ve been developing it solo. It may still need refinements and improvements, and I’d greatly appreciate any feedback or suggestions from the community.

Key Features:

  • General System Settings: Automatically configure backups, reboots, and system updates.
  • Network Configuration: Set up static IPs, bridges, and DNS servers with ease.
  • User Management: Add users, set passwords, and manage SSH keys automatically.
  • Performance Optimization: Fine-tune CPU scaling governors, enable nested virtualization, and manage ZFS ARC.
  • Service Management: Enable or disable services like AppArmor, Fail2Ban, and Nginx.
  • Kernel Management: Pin/unpin kernels or install specific kernel versions.
  • Custom ISO Management: Automate the download of Windows VirtIO drivers or custom ISO images.
  • RAM Disk for Logs: Move logs to a RAM disk for better performance and cleaner storage.

✅ Compatibility:​

  • Proxmox VE Versions: Tested on 7.x and 8.x.
  • Boot Modes: Works with both GRUB and UEFI configurations.

GitHub Repository:

Check out on GitHub
Vars example on GitHub

How to Use:​

Clone the repository:​

git clone git@github.com:yokozu777/proxmox-ansible.git
cd proxmox-ansible

Configure variables for your hosts:​

Copy and customize the example variables file:
cp hosts_vars/example.yml hosts_vars/<your_host_name>.yml
Edit your_host_name.yml to match your desired configuration.

Required Variables for Connection​

To ensure a successful connection, make sure to fill in the following variables in your host vars file:

Users Configuration​

initial_user: root # The initial user for the system.
initial_password: P@ssw0rd* # The initial user's password.

Using SSH Keys for Authentication​

If you prefer to use SSH keys for authentication, follow these steps:
Create a pub_keys folder:
  • In the same directory as your host vars file, create a folder named pub_keys.
Add your .pub keys:
  • Place your public SSH keys (.pub files) in the pub_keys folder.
User Association:
These keys will automatically be added to the user specified in the system_user variable.

Example:​

system_user: localuser # The user to which the public keys will be added

Add your hosts to the inventory:​

Update inventory.yml with your host(s) and link to the variables file:
all:
hosts:
proxmox-host:
ansible_host: <your_proxmox_ip>
vars_files:
- hosts_vars/<your_host_name>.yml

Quick Start with Docker​

If you do not have Ansible installed, but Docker is available, you can use the provided Dockerfile for a quick setup.

Steps to Use Docker:​

Build the Docker Image:
docker build -t proxmox:latest .
Run the Docker Container:
docker run -it --name proxmox -v $PWD/:/opt proxmox:latest
This will create and start a Docker container with Ansible pre-installed, allowing you to run the playbook directly from the container.

Run the playbook:​

ansible-playbook proxmox.yml


Feedback and Contributions:​

This playbook was born out of the lack of tools for provisioning Proxmox hosts I could find online. If you have any feedback, suggestions, or ideas to improve it, I’d be incredibly grateful to hear them! Contributions are also welcome if you’d like to collaborate on making this tool even better.


Thanks for checking it out, and I hope it helps streamline your Proxmox management!
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!