proxmox-upgrade/roles/proxmox-upgrade/tasks/upgrade-pve.yml

85 lines
2.7 KiB
YAML
Executable File

---
- name: perform tasks for Proxmox Virtual Environment
block:
- name: Run upgrade Debian 10
ansible.builtin.include_tasks:
file: upgrade-pve-Debian10.yml
when: ansible_distribution_release == "buster"
- 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
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 to make sure we are at version "{{ proxmox_pve_min_version }}" or higher
ansible.builtin.apt:
name: "*"
state: latest
update_cache: true
notify:
- reboot server
- name: flush handlers to reboot instantly
ansible.builtin.meta: flush_handlers
- name: get Proxmox Virtual Environment version
ansible.builtin.command:
cmd: "{{ proxmox_pveversion }}"
register: proxmox_pveversion_info
changed_when: false
- name: define Proxmox Virtual Environment version
ansible.builtin.set_fact:
proxmox_pve_version: "{{ proxmox_pveversion_info.stdout | regex_search('pve-manager\/(\\d+\\.\\d+-\\d+)') | split('/') | last }}"
- name: update packages to make sure we are at version "{{ proxmox_pve_min_version }}" or higher
ansible.builtin.apt:
name: "*"
state: latest
update_cache: true
when: proxmox_pve_version <= proxmox_pve_min_version
# backup configuration
- name: create backup of configuration
community.general.archive:
path: /etc
dest: "{{ backup_path }}proxmox-pve-backup-{{ ansible_date_time.date }}.tar.gz"
mode: 600
format: gz
tags:
- backup
# shutdown 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
ansible.builtin.command:
cmd: "{{ proxmox_qm_manager }} shutdown {{ item }} {{ proxmox_shutdown_vms_opts }}"
loop: "{{ proxmox_running_vms_info.stdout_lines }}"
when: shutdown_vms
# update repos
- name: update repos
ansible.builtin.include_tasks:
file: update-repos.yml
# do dist-upgrade
- name: upgrade Proxmox Virtual Environment Server
ansible.builtin.apt:
update_cache: true
upgrade: dist
notify:
- reboot server