working version
parent
656d1e1f69
commit
181c9de09b
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,93 +1,92 @@
|
|||
---
|
||||
- name: remove pve-enterprise subscription repo
|
||||
ansible.builtin.file:
|
||||
path: "{{ proxmox_pve_enterprise_list }}"
|
||||
state: absent
|
||||
when: use_enterprise_repos == false
|
||||
- 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: 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: remove pve-enterprise subscription repo
|
||||
ansible.builtin.file:
|
||||
path: "{{ proxmox_pve_enterprise_list }}"
|
||||
state: absent
|
||||
when: use_enterprise_repos == false
|
||||
|
||||
- name: Update packages on Debian 10
|
||||
ansible.builtin.apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify:
|
||||
- reboot server
|
||||
- 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: flush handlers to reboot instantly
|
||||
ansible.builtin.meta: flush_handlers
|
||||
- name: Update packages on Debian 10
|
||||
ansible.builtin.apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify:
|
||||
- reboot server
|
||||
|
||||
- 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
|
||||
- name: flush handlers to reboot instantly
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: get running virtual maschines
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ proxmox_get_vms_cmd }}"
|
||||
register: proxmox_running_vms_info
|
||||
changed_when: false
|
||||
- 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
|
||||
|
||||
- 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: get running virtual maschines
|
||||
ansible.builtin.shell:
|
||||
cmd: "{{ proxmox_get_vms_cmd }}"
|
||||
register: proxmox_running_vms_info
|
||||
changed_when: false
|
||||
|
||||
- name: update repos
|
||||
ansible.builtin.include_tasks:
|
||||
file: update-repos.yml
|
||||
- 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 packages to Debian 11
|
||||
ansible.builtin.apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
update_cache: true
|
||||
notify:
|
||||
- reboot server
|
||||
- name: update repos
|
||||
ansible.builtin.include_tasks:
|
||||
file: update-repos.yml
|
||||
|
||||
- name: flush handlers to reboot instantly
|
||||
ansible.builtin.meta: flush_handlers
|
||||
- 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: Exit if nothing to upgrade
|
||||
# fail: msg="Only manual upgrade!"
|
||||
- name: Dist-Upgrade Proxmox Virtual Environment 6 to 7
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: dist
|
||||
force: true
|
||||
notify:
|
||||
- reboot server
|
||||
|
||||
- name: Upgrade Proxmox Virtual Environment Server on Debian 10
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
upgrade: dist
|
||||
force: true
|
||||
notify:
|
||||
- reboot server
|
||||
- name: flush handlers to reboot instantly
|
||||
ansible.builtin.meta: flush_handlers
|
||||
|
||||
- name: Remove useless packages from the cache
|
||||
ansible.builtin.apt:
|
||||
autoclean: true
|
||||
- name: Force ansible to regather facts for distribution
|
||||
ansible.builtin.setup:
|
||||
filter:
|
||||
- 'ansible_distribution'
|
||||
- 'ansible_distribution_release'
|
||||
- 'ansible_distribution_major_version'
|
||||
|
||||
- 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
|
||||
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: Set facts
|
||||
# ansible.builtin.set_fact:
|
||||
# ansible_distribution_release: bullseye
|
||||
# ansible_distribution_major_version: 11
|
||||
|
||||
notify:
|
||||
- reboot server
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue