Skip to content

xgueret/proxmox

Repository files navigation

πŸš€ Automated Proxmox Deployment with Ansible & Terraform

Stars Last Commit Status Proxmox VE

[toc]

πŸ“‹ Description

This repository provides secure and automated configuration of a Proxmox VE server using Ansible and Terraform. It also manages GitHub repositories for configuration publishing.

✨ Features include:

  • πŸ” SSH security hardening
  • πŸ‘€ Proxmox roles, users, and token creation
  • 🐧 Ubuntu Cloud-Init VM templates
  • 🌐 GitHub repository provisioning with Terraform

πŸ“ Project Structure

.
β”œβ”€β”€ ansible
β”‚   β”œβ”€β”€ ansible.cfg
β”‚   β”œβ”€β”€ host_vars
β”‚   β”‚   └── pve
β”‚   β”œβ”€β”€ inventory.yml
β”‚   β”œβ”€β”€ playbook.yml
β”‚   β”œβ”€β”€ roles
β”‚   β”‚   β”œβ”€β”€ configure
β”‚   β”‚   └── manage
β”‚   └── SHA256SUMS
β”œβ”€β”€ check_ansible_vault.sh
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
└── terraform
    └── github
        β”œβ”€β”€ data_sources.tf
        β”œβ”€β”€ main.tf
        β”œβ”€β”€ outputs.tf
        β”œβ”€β”€ providers.tf
        β”œβ”€β”€ terraform.tfstate
        β”œβ”€β”€ terraform.tfvars
        └── variables.tf

βœ… Requirements

  • 🐍 Ansible
  • 🌍 Terraform
  • πŸ” SSH access to your Proxmox instance
  • πŸ™ GitHub access with a personal token

πŸ“¦ Installing dependencies

pip install -r requirements.txt
pre-commit install

πŸ”§ Environment Configuration

Configure Environment Variables

Copy the example environment file and customize it:

cp .env.example .env
chmod 600 .env

Edit .env and set your values:

  • SSH_USER: SSH user for VM connections (default: ansible)
  • SSH_KEY_FILE: Path to SSH public key (default: ~/.ssh/proxmox.pub)
  • PROXMOX_IP: Your Proxmox server IP address
  • GEN_PASS: Password for Proxmox users (store in Ansible Vault)
  • CLOUD_INIT_ROOT_PASSWD: Root password for VM templates

⚠️ Security Note: Never commit .env to version control!

πŸ“š Additional Documentation

🧩 1. Installing Proxmox on my Acer XC-605 PC

1.1. Download the Proxmox ISO

mkdir -p ~/Worspace/tmp/proxmox
cd ~/Worspace/tmp/proxmox

1.2. Download the archive and SHA256 file

wget https://enterprise.proxmox.com/iso/proxmox-ve_9.0-1.iso
wget https://enterprise.proxmox.com/iso/SHA256SUMS

1.3. Verify the SHA-256 hash

cat SHA256SUMS | grep proxmox-ve_9.0-1.iso | sha256sum -c
# Output:
# proxmox-ve_9.0-1.iso: OK

πŸ’½ 2. Install Proxmox with Ventoy

πŸ“ See Ventoy official site or Ubuntu-fr doc

If you have a USB drive with Ventoy, simply copy the ISO:

cp ~/Workspace/tmp/proxmox/proxmox-ve_9.0-1.iso /media/xgueret/Ventoy

2.1. BIOS/UEFI Settings

ℹ️ At startup, press the Delete key to access the BIOS menu

  • ❌ Disable Secure Boot
  • βœ… Enable VT-x/Virtualization

πŸ‘‰ Use the USB drive with Ventoy on your Acer XC-605 to boot and install Proxmox

⌨️ At startup, press F12 to access the boot menu

2.2. Troubleshooting Installation

πŸ’‘ If you encounter an issue during Proxmox 9 installation (see Proxmox forum thread):

➑️ At the installation menu, press e to edit boot options. ➑️ At the line starting with linux, append:

nomodeset

press F10

Then proceed with installation πŸŽ‰

πŸ”‘ 3. SSH Configuration on my Linux workstation

3.1. Generate a key pair

ssh-keygen -t rsa -b 4096 -f ~/.ssh/proxmox -C "[email protected]"

ℹ️ Include a passphrase if necessary πŸ“ Check keys:

ls -al ~/.ssh

3.2. Copy the key to Proxmox

ssh-copy-id -i ~/.ssh/proxmox.pub [email protected]

3.3. Activate ssh-agent (optional)

eval $(ssh-agent)
ssh-add ~/.ssh/proxmox
ssh [email protected]

3.4. Get the repository

cd ~/Workspace
git clone <REPO_URL>
cd proxmox
cd ansible

Make sure Python venv is activated and Ansible is installed

πŸš€ 4. Usage

4.1. Configure Inventory

Edit the file:

ansible/inventory.yml

Add your Proxmox host.

4.2. Vaulted Secrets

Passwords and IPs are encrypted in:

ansible/host_vars/<host>/vault/main.yml

(i) check all with pre-commit

pre-commit run --all-files

4.3 Run the playbook with the following tag to configure the ansible user on the target server

ansible-playbook -u root playbook.yml --tags "security_ssh_hardening"

4.4 Then run the playbook without the -u root parameter

ansible-playbook playbook.yml

πŸ“š Enjoy your automated Proxmox setup! 😎


πŸ‘₯ Contributors

  • Author: Xavier GUERET GitHub followers Twitter Follow LinkedIn

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Managed by Terraform:[HomeLab] proxmox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published