refactor ♻️: Refactor README and update role for Proxmox VE provisioning
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 11s
Gitleaks Scan / gitleaks (push) Successful in 5s
Markdown Lint / markdown-lint (push) Failing after 4s

This refactoring includes updating the README, changing the role name to focus on Proxmox VE, enhancing compatibility matrix, and refactoring default values for role variables. Handlers are updated to manage apt cache, restart pveproxy, and reload systemd. Role metadata is also updated for better Proxmox VE provisioning.
This commit is contained in:
2026-02-07 08:29:45 +01:00
parent 8c9ad60602
commit 8341d6e295
15 changed files with 212 additions and 162 deletions

View File

@@ -1,28 +0,0 @@
---
# # ansible-role-template/tasks/backup.yml
# Backup tasks
# ============
- name: backup | Ensure backup directory exists
ansible.builtin.file:
path: "{{ role_template_backup_dir }}"
state: directory
mode: "0750"
owner: root
group: root
- name: backup | Create backup script
ansible.builtin.template:
src: templates/backup_script.sh.j2
dest: /usr/local/bin/backup_{{ role_template_service_name }}
mode: "0755"
owner: root
group: root
- name: backup | Create cron job for backups
ansible.builtin.cron:
name: "Backup {{ role_template_service_name }}"
user: root
minute: "0"
hour: "3"
job: "/usr/local/bin/backup_{{ role_template_service_name }}"

8
tasks/logrotate.yml Normal file
View File

@@ -0,0 +1,8 @@
---
- name: Configure Proxmox logrotate limits
template:
src: logrotate-pve.j2
dest: /etc/logrotate.d/proxmox
owner: root
group: root
mode: "0644"

View File

@@ -1,8 +1,23 @@
---
# ansible-role-template/tasks/main.yml
# ansible_role_proxmox_provision/tasks/main.yml
# Main tasks for role
# ===================
- name: Disable enterprise repo, enable no-subscription
ansible.builtin.import_tasks: repos.yml
- name: Remove the infamous subscription nag
ansible.builtin.import_tasks: subscription.yml
- name: Disable swap or tune it
ansible.builtin.import_tasks: swap.yml
- name: Stop logs from quietly murdering /
ansible.builtin.import_tasks: logrotate.yml
- name: Install, auto-tune, and make it persistent
ansible.builtin.import_tasks: powertop.yml
# Import backup tasks
- name: Import backup tasks
ansible.builtin.import_tasks: backup.yml

View File

@@ -1,22 +0,0 @@
---
# # ansible-role-template/tasks/monitoring.yml
# Monitoring tasks
# ================
- name: monitoring | Ensure monitoring directory exists
ansible.builtin.file:
path: "/var/log/monitoring/{{ role_template_service_name }}"
state: directory
mode: "0755"
- name: monitoring | Create monitoring configuration
ansible.builtin.template:
src: templates/monitoring_config.yml.j2
dest: "/etc/monitoring/{{ role_template_service_name }}.yml"
mode: "0640"
- name: monitoring | Ensure monitoring service is running
ansible.builtin.service:
name: monitoring-service
state: started
enabled: yes

22
tasks/powertop.yml Normal file
View File

@@ -0,0 +1,22 @@
---
- name: Install powertop
apt:
name: powertop
state: present
update_cache: yes
when: proxmox_enable_powertop
- name: Create powertop systemd service
template:
src: powertop.service.j2
dest: /etc/systemd/system/powertop.service
mode: "0644"
when: proxmox_enable_powertop
notify: reload systemd
- name: Enable and start powertop service
systemd:
name: powertop
enabled: true
state: started
when: proxmox_enable_powertop

15
tasks/repos.yml Normal file
View File

@@ -0,0 +1,15 @@
---
- name: Remove enterprise repo files (all known locations)
file:
path: "{{ item }}"
state: absent
loop:
- /etc/apt/sources.list.d/pve-enterprise.list
- /etc/apt/sources.list.d/ceph.list
- name: Enable Proxmox no-subscription repo
copy:
dest: /etc/apt/sources.list.d/pve-no-subscription.list
content: |
deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription
notify: apt update

16
tasks/subscription.yml Normal file
View File

@@ -0,0 +1,16 @@
---
- name: Remove subscription nag (legacy proxmoxlib.js)
replace:
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
regexp: "if \\(data.status !== 'Active'\\)"
replace: "if (false)"
ignore_errors: true
notify: restart pveproxy
- name: Remove subscription nag (minified bundle for VE 8/9)
replace:
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js
regexp: "data.status!=='Active'"
replace: "false"
ignore_errors: true
notify: restart pveproxy

23
tasks/swap.yml Normal file
View File

@@ -0,0 +1,23 @@
---
- name: Set vm.swappiness
sysctl:
name: vm.swappiness
value: "{{ proxmox_swapiness }}"
state: present
reload: yes
- name: Disable swap if host has enough RAM
command: swapoff -a
when:
- proxmox_disable_swap
- ansible_memtotal_mb >= proxmox_min_ram_mb_for_no_swap
changed_when: false
- name: Remove swap from fstab
replace:
path: /etc/fstab
regexp: '^\S+\s+\S+\s+swap\s+.*$'
replace: ''
when:
- proxmox_disable_swap
- ansible_memtotal_mb >= proxmox_min_ram_mb_for_no_swap