working version

main
Дмитрий Фёдоров 2024-10-08 00:38:24 +03:00
parent 656d1e1f69
commit 181c9de09b
7 changed files with 126 additions and 97 deletions

View File

@ -9,7 +9,7 @@ shutdown_vms: true
use_enterprise_repos: false
# download created backups? (boolean)
download_backups: true
download_backups: false
# where to save backups?
backup_path: "/var/backups"
@ -18,7 +18,7 @@ backup_path: "/var/backups"
proxmox_pveversion: "/usr/bin/pveversion"
proxmox_backup_manager: "/usr/sbin/proxmox-backup-manager"
proxmox_qm_manager: "/usr/sbin/qm"
proxmox_pve_min_version: "7.4-15"
proxmox_pve_min_version: "7.4-25"
proxmox_pbs_min_version: "2.4.2"
proxmox_get_vms_cmd: "qm list |grep running |awk '{print $1}'"
proxmox_shutdown_vms_opts: "--forceStop 1"

View File

@ -3,7 +3,7 @@
ansible.builtin.find:
path: /etc
patterns: '*.dpkg-dist'
recurse: yes
recurse: true
register: dpkg_dist_files
- name: please check following new configuration files and apply your changes, files could be deleted after that.

View File

@ -4,17 +4,6 @@
msg: "Server is already on newest version, stopping here!"
when: ansible_distribution_release == proxmox_newest_deb_relase
- name: include OS specific variables
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
paths:
- "vars"
tags:
- always
- name: gather facts and check prerequisites
ansible.builtin.include_tasks:
file: prepare.yml
@ -28,7 +17,31 @@
tags:
- backup
- name: perform tasks for Proxmox Virtual Environment Server
- name: perform tasks for Proxmox Virtual Environment Server v.6
ansible.builtin.include_tasks:
file: upgrade-pve-Debian10.yml
when: is_pve_role and ansible_distribution_release == "buster"
tags:
- backup
# - name: Force ansible to regather facts for distribution
# ansible.builtin.setup:
# filter:
# - 'ansible_distribution'
# - 'ansible_distribution_release'
# - 'ansible_distribution_major_version'
# when: is_pve_role
# tags:
# - backup
- name: Print all available facts
ansible.builtin.debug:
var: ansible_distribution_release
- name: Print all available facts
ansible.builtin.debug:
var: ansible_distribution_major_version
- name: perform tasks for Proxmox Virtual Environment Server v.7
ansible.builtin.include_tasks:
file: upgrade-pve.yml
when: is_pve_role

View File

@ -37,3 +37,16 @@
ansible.builtin.fail:
msg: Stopping because there is not enough free space! There should be at least 5GB free of space.
when: space_free_gb > '5'
- name: "Ensure /etc/network/interfaces contains 'hwaddress'"
command: grep hwaddress /etc/network/interfaces
register: macaddr
ignore_errors: true
changed_when: false
- name: Write mac-address in file
ansible.builtin.lineinfile:
path: /etc/network/interfaces
insertafter: 'gateway'
line: ' hwaddress {{ hostvars[inventory_hostname].ansible_default_ipv4.macaddress }}'
when: macaddr.rc == 1

View File

@ -1,18 +1,29 @@
---
- name: remove pve-enterprise subscription repo
- name: perform tasks for Proxmox Virtual Environment 6
block:
- name: include OS specific variables
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
paths:
- "vars"
- name: remove pve-enterprise subscription repo
ansible.builtin.file:
path: "{{ proxmox_pve_enterprise_list }}"
state: absent
when: use_enterprise_repos == false
- name: make sure that pve-no-subscription repos are active
- name: make sure that pve-no-subscription repos are active
ansible.builtin.apt_repository:
repo: "{{ item.line }}"
state: present
update_cache: false
loop: "{{ __deb_proxmox_pve_repos | selectattr('release', '==', ansible_distribution_release) }}"
- name: Update packages on Debian 10
- name: Update packages on Debian 10
ansible.builtin.apt:
name: "*"
state: latest
@ -20,10 +31,10 @@
notify:
- reboot server
- name: flush handlers to reboot instantly
- name: flush handlers to reboot instantly
ansible.builtin.meta: flush_handlers
- name: create backup of configuration
- name: create backup of configuration
community.general.archive:
path: /etc
dest: "{{ backup_path }}proxmox-pve-backup-{{ ansible_date_time.date }}.tar.gz"
@ -32,37 +43,29 @@
tags:
- backup
- name: get running virtual maschines
- name: get running virtual maschines
ansible.builtin.shell:
cmd: "{{ proxmox_get_vms_cmd }}"
register: proxmox_running_vms_info
changed_when: false
- name: shutting down virtual maschines
- name: shutting down virtual maschines
ansible.builtin.command:
cmd: "{{ proxmox_qm_manager }} shutdown {{ item }} {{ proxmox_shutdown_vms_opts }}"
loop: "{{ proxmox_running_vms_info.stdout_lines }}"
when: shutdown_vms
- name: update repos
- name: update repos
ansible.builtin.include_tasks:
file: update-repos.yml
- name: Update packages to Debian 11
ansible.builtin.apt:
name: "*"
state: latest
update_cache: true
notify:
- reboot server
- name: Fix problem upgrade PVE
ansible.builtin.lineinfile:
path: /usr/share/proxmox-ve/pve-apt-hook
search_string: "$cleanup->(0, 1);"
line: "# $cleanup->(0, 1);"
- name: flush handlers to reboot instantly
ansible.builtin.meta: flush_handlers
# - name: Exit if nothing to upgrade
# fail: msg="Only manual upgrade!"
- name: Upgrade Proxmox Virtual Environment Server on Debian 10
- name: Dist-Upgrade Proxmox Virtual Environment 6 to 7
ansible.builtin.apt:
update_cache: true
upgrade: dist
@ -70,24 +73,20 @@
notify:
- reboot server
- name: Remove useless packages from the cache
ansible.builtin.apt:
autoclean: true
- name: Remove dependencies that are no longer required and purge their configuration files
ansible.builtin.apt:
autoremove: true
purge: true
- name: flush handlers to reboot instantly
- name: flush handlers to reboot instantly
ansible.builtin.meta: flush_handlers
- name: check if proxmox pve role is installed
ansible.builtin.stat:
path: "{{ proxmox_pveversion }}"
register: pve_version_info
tags:
- backup
- name: Force ansible to regather facts for distribution
ansible.builtin.setup:
filter:
- 'ansible_distribution'
- 'ansible_distribution_release'
- 'ansible_distribution_major_version'
# - name: Set facts
# ansible.builtin.set_fact:
# ansible_distribution_release: bullseye
# ansible_distribution_major_version: 11
notify:
- reboot server

View File

@ -1,10 +1,14 @@
---
- name: perform tasks for Proxmox Virtual Environment
- name: perform tasks for Proxmox Virtual Environment 7
block:
- name: Run upgrade Debian 10
ansible.builtin.include_tasks:
file: upgrade-pve-Debian10.yml
when: ansible_distribution_release == "buster"
- name: include OS specific variables
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
vars:
params:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
paths:
- "vars"
- name: remove pve-enterprise subscription repo
ansible.builtin.file:

View File

@ -1,5 +1,5 @@
---
# when Debian 10 (buster) is detected, change repos to Debian 12 (bullseye)
# when Debian 10 (buster) is detected, change repos to Debian 11 (bullseye)
__deb_debian_repos:
- {
"line": "deb http://ftp.ru.debian.org/debian bullseye main contrib",