proxmox-ansible system configurator

apuctokpat

New Member
Mar 27, 2024
5
18
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:
It's a good start, yet there a lot of enterprise features I regularly use missing. Maybe there are also interessting to you and can be implemented:
  • cluster setup
  • ceph setup
  • multipath configuration
  • lvm management (e.g. for multipath)
  • sane defaults for PVE firewall
  • mail server configuration
  • metric integration
  • additional PBS-based host backup
  • authentication setup (LDAP, OAuth/OpenID)
  • old kernel version cleanup
Do you use nginx for redirection? If so, this could be done easily by iptables to redirect 443 to 8006.
 
It's a good start, yet there a lot of enterprise features I regularly use missing. Maybe there are also interessting to you and can be implemented:
  • cluster setup
  • ceph setup
  • multipath configuration
  • lvm management (e.g. for multipath)
  • sane defaults for PVE firewall
  • mail server configuration
  • metric integration
  • additional PBS-based host backup
  • authentication setup (LDAP, OAuth/OpenID)
  • old kernel version cleanup
Do you use nginx for redirection? If so, this could be done easily by iptables to redirect 443 to 8006.
Hello everyone,

In the upcoming version, I plan to include the following features:

  • Sane defaults for PVE firewall
  • Mail server configuration
  • Metric integration
  • Authentication setup (LDAP, OAuth/OpenID)
In the current version, I've already implemented:

  • Old kernel version cleanup
  • Nginx for redirection, currently configured through upstream.
The remaining features will be recorded for future releases. :)

Feel free to share your feedback or suggestions!
 
Absolutely great!
I was looking for a way to automate the pve configuration and came across your work.

Will definitely give it a shot!
 
[Release] v1.1.0 — Proxmox VE 9 support, new roles


Hi all! I’ve just shipped v1.1.0. Highlights:


  • Nginx performance + date/timezone configuration optimizations
  • Full compatibility with Proxmox VE 9
  • New roles:
    • Configure Mail
    • Configure Certificates
    • Configure ACME (Let’s Encrypt or custom CA)

No breaking changes expected; upgrade from 1.0.x is straightforward.


If you spot anything odd, please share logs and your environment details. Thanks for testing and feedback!