Files
ansible/roles/proxmox/README.md
Tuan-Dat Tran 2882abfc0b Added README.md for roles
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2025-07-27 16:40:46 +02:00

67 lines
2.9 KiB
Markdown

# Proxmox Ansible Role
This role facilitates the management of Proxmox VE resources, including virtual machines (VMs) and LXC containers. It automates the setup of Proxmox nodes and the creation, configuration, and destruction of guests.
## Requirements
- `community.general.proxmox_vm_info`
- `community.general.proxmox_kvm`
## Role Variables
| Variable | Description | Default Value |
|---|---|---|
| `proxmox_author` | The author of the Proxmox resources. | `tuan-dat.tran@tudattr.dev` |
| `proxmox_creator` | The creator of the Proxmox resources. | `ansible` |
| `proxmox_storage` | The Proxmox storage to use. | `proxmox` |
| `proxmox_vault_file` | The path to the vault file for storing secrets. | `../vars/group_vars/proxmox/secrets_vm.yml` |
| `proxmox_secrets_prefix` | The prefix for secrets stored in the vault. | `secrets_vm` |
| `proxmox_cloud_init_images` | A dictionary of cloud-init images to download. | `{ 'debian': { 'name': 'debian-12-genericcloud-amd64.qcow2', 'url': '...' }, 'ubuntu': { 'name': 'noble-server-cloudimg-amd64.img', 'url': '...' } }` |
| `proxmox_dirs` | A dictionary of directories used by the role. | `{ 'isos': '/opt/proxmox/template/iso/' }` |
| `proxmox_tags` | A list of tags to apply to the Proxmox resources. | `['{{ proxmox_creator }}']` |
| `proxmox_node_dependencies` | A list of dependencies to install on the Proxmox node. | `['nmap']` |
| `proxmox_localhost_dependencies` | A list of dependencies to install on the localhost. | `[]` |
| `vms` | A list of VMs to create. | `[{ 'name': 'test-vm', 'vmid': 1000, ... }]` |
| `lxcs` | A list of LXC containers to create. | `[{ 'name': 'test-lxc', 'vmid': 2000, ... }]` |
## Handlers
- `Reboot Node`: Reboots the Proxmox node. This is triggered when the GRUB configuration or VFIO modules are changed.
## Tasks
The role includes the following main tasks:
- `00_setup_machines.yml`: Prepares the localhost and Proxmox nodes by installing dependencies and configuring hardware acceleration.
- `10_create_secrets.yml`: Creates a vault file and generates secrets for the VMs.
- `40_prepare_vm_creation.yml`: Downloads cloud-init images required for VM creation.
- `50_create_vms.yml`: Creates VMs based on the `vms` variable.
- `60_create_containers.yml`: Creates LXC containers based on the `lxcs` variable.
## Usage
Here is an example of how to use this role in a playbook:
```yaml
- hosts: proxmox
roles:
- role: proxmox
vars:
proxmox_api_user: "root@pam"
proxmox_api_token_id: "your-token-id"
proxmox_api_token_secret: "your-token-secret"
proxmox_api_host: "your-proxmox-host"
vms:
- name: my-vm
vmid: 1001
node: proxmox
cores: 4
memory: 8192
disk_size: 50
boot_image: debian-12-genericcloud-amd64.img
ciuser: myuser
sshkeys: "your-ssh-key"
net:
net0: "virtio=BC:24:11:7E:2B:A1,bridge=vmbr0"
```