working version
parent
656d1e1f69
commit
181c9de09b
|
|
@ -9,7 +9,7 @@ shutdown_vms: true
|
||||||
use_enterprise_repos: false
|
use_enterprise_repos: false
|
||||||
|
|
||||||
# download created backups? (boolean)
|
# download created backups? (boolean)
|
||||||
download_backups: true
|
download_backups: false
|
||||||
|
|
||||||
# where to save backups?
|
# where to save backups?
|
||||||
backup_path: "/var/backups"
|
backup_path: "/var/backups"
|
||||||
|
|
@ -18,7 +18,7 @@ backup_path: "/var/backups"
|
||||||
proxmox_pveversion: "/usr/bin/pveversion"
|
proxmox_pveversion: "/usr/bin/pveversion"
|
||||||
proxmox_backup_manager: "/usr/sbin/proxmox-backup-manager"
|
proxmox_backup_manager: "/usr/sbin/proxmox-backup-manager"
|
||||||
proxmox_qm_manager: "/usr/sbin/qm"
|
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_pbs_min_version: "2.4.2"
|
||||||
proxmox_get_vms_cmd: "qm list |grep running |awk '{print $1}'"
|
proxmox_get_vms_cmd: "qm list |grep running |awk '{print $1}'"
|
||||||
proxmox_shutdown_vms_opts: "--forceStop 1"
|
proxmox_shutdown_vms_opts: "--forceStop 1"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
ansible.builtin.find:
|
ansible.builtin.find:
|
||||||
path: /etc
|
path: /etc
|
||||||
patterns: '*.dpkg-dist'
|
patterns: '*.dpkg-dist'
|
||||||
recurse: yes
|
recurse: true
|
||||||
register: dpkg_dist_files
|
register: dpkg_dist_files
|
||||||
|
|
||||||
- name: please check following new configuration files and apply your changes, files could be deleted after that.
|
- 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!"
|
msg: "Server is already on newest version, stopping here!"
|
||||||
when: ansible_distribution_release == proxmox_newest_deb_relase
|
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
|
- name: gather facts and check prerequisites
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: prepare.yml
|
file: prepare.yml
|
||||||
|
|
@ -28,7 +17,31 @@
|
||||||
tags:
|
tags:
|
||||||
- backup
|
- 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:
|
ansible.builtin.include_tasks:
|
||||||
file: upgrade-pve.yml
|
file: upgrade-pve.yml
|
||||||
when: is_pve_role
|
when: is_pve_role
|
||||||
|
|
|
||||||
|
|
@ -37,3 +37,16 @@
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: Stopping because there is not enough free space! There should be at least 5GB free of space.
|
msg: Stopping because there is not enough free space! There should be at least 5GB free of space.
|
||||||
when: space_free_gb > '5'
|
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
|
- name: perform tasks for Proxmox Virtual Environment 6
|
||||||
ansible.builtin.file:
|
block:
|
||||||
path: "{{ proxmox_pve_enterprise_list }}"
|
- name: include OS specific variables
|
||||||
state: absent
|
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
|
||||||
when: use_enterprise_repos == false
|
vars:
|
||||||
|
params:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||||
|
paths:
|
||||||
|
- "vars"
|
||||||
|
|
||||||
- name: make sure that pve-no-subscription repos are active
|
- name: remove pve-enterprise subscription repo
|
||||||
ansible.builtin.apt_repository:
|
ansible.builtin.file:
|
||||||
repo: "{{ item.line }}"
|
path: "{{ proxmox_pve_enterprise_list }}"
|
||||||
state: present
|
state: absent
|
||||||
update_cache: false
|
when: use_enterprise_repos == false
|
||||||
loop: "{{ __deb_proxmox_pve_repos | selectattr('release', '==', ansible_distribution_release) }}"
|
|
||||||
|
|
||||||
- name: Update packages on Debian 10
|
- name: make sure that pve-no-subscription repos are active
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt_repository:
|
||||||
name: "*"
|
repo: "{{ item.line }}"
|
||||||
state: latest
|
state: present
|
||||||
update_cache: true
|
update_cache: false
|
||||||
notify:
|
loop: "{{ __deb_proxmox_pve_repos | selectattr('release', '==', ansible_distribution_release) }}"
|
||||||
- reboot server
|
|
||||||
|
|
||||||
- name: flush handlers to reboot instantly
|
- name: Update packages on Debian 10
|
||||||
ansible.builtin.meta: flush_handlers
|
ansible.builtin.apt:
|
||||||
|
name: "*"
|
||||||
|
state: latest
|
||||||
|
update_cache: true
|
||||||
|
notify:
|
||||||
|
- reboot server
|
||||||
|
|
||||||
- name: create backup of configuration
|
- name: flush handlers to reboot instantly
|
||||||
community.general.archive:
|
ansible.builtin.meta: flush_handlers
|
||||||
path: /etc
|
|
||||||
dest: "{{ backup_path }}proxmox-pve-backup-{{ ansible_date_time.date }}.tar.gz"
|
|
||||||
mode: 600
|
|
||||||
format: gz
|
|
||||||
tags:
|
|
||||||
- backup
|
|
||||||
|
|
||||||
- name: get running virtual maschines
|
- name: create backup of configuration
|
||||||
ansible.builtin.shell:
|
community.general.archive:
|
||||||
cmd: "{{ proxmox_get_vms_cmd }}"
|
path: /etc
|
||||||
register: proxmox_running_vms_info
|
dest: "{{ backup_path }}proxmox-pve-backup-{{ ansible_date_time.date }}.tar.gz"
|
||||||
changed_when: false
|
mode: 600
|
||||||
|
format: gz
|
||||||
|
tags:
|
||||||
|
- backup
|
||||||
|
|
||||||
- name: shutting down virtual maschines
|
- name: get running virtual maschines
|
||||||
ansible.builtin.command:
|
ansible.builtin.shell:
|
||||||
cmd: "{{ proxmox_qm_manager }} shutdown {{ item }} {{ proxmox_shutdown_vms_opts }}"
|
cmd: "{{ proxmox_get_vms_cmd }}"
|
||||||
loop: "{{ proxmox_running_vms_info.stdout_lines }}"
|
register: proxmox_running_vms_info
|
||||||
when: shutdown_vms
|
changed_when: false
|
||||||
|
|
||||||
- name: update repos
|
- name: shutting down virtual maschines
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.command:
|
||||||
file: update-repos.yml
|
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
|
- name: update repos
|
||||||
ansible.builtin.apt:
|
ansible.builtin.include_tasks:
|
||||||
name: "*"
|
file: update-repos.yml
|
||||||
state: latest
|
|
||||||
update_cache: true
|
|
||||||
notify:
|
|
||||||
- reboot server
|
|
||||||
|
|
||||||
- name: flush handlers to reboot instantly
|
- name: Fix problem upgrade PVE
|
||||||
ansible.builtin.meta: flush_handlers
|
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
|
- name: Dist-Upgrade Proxmox Virtual Environment 6 to 7
|
||||||
# fail: msg="Only manual upgrade!"
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
upgrade: dist
|
||||||
|
force: true
|
||||||
|
notify:
|
||||||
|
- reboot server
|
||||||
|
|
||||||
- name: Upgrade Proxmox Virtual Environment Server on Debian 10
|
- name: flush handlers to reboot instantly
|
||||||
ansible.builtin.apt:
|
ansible.builtin.meta: flush_handlers
|
||||||
update_cache: true
|
|
||||||
upgrade: dist
|
|
||||||
force: true
|
|
||||||
notify:
|
|
||||||
- reboot server
|
|
||||||
|
|
||||||
- name: Remove useless packages from the cache
|
- name: Force ansible to regather facts for distribution
|
||||||
ansible.builtin.apt:
|
ansible.builtin.setup:
|
||||||
autoclean: true
|
filter:
|
||||||
|
- 'ansible_distribution'
|
||||||
|
- 'ansible_distribution_release'
|
||||||
|
- 'ansible_distribution_major_version'
|
||||||
|
|
||||||
- name: Remove dependencies that are no longer required and purge their configuration files
|
# - name: Set facts
|
||||||
ansible.builtin.apt:
|
# ansible.builtin.set_fact:
|
||||||
autoremove: true
|
# ansible_distribution_release: bullseye
|
||||||
purge: true
|
# ansible_distribution_major_version: 11
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
- reboot server
|
- reboot server
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
---
|
---
|
||||||
- name: perform tasks for Proxmox Virtual Environment
|
- name: perform tasks for Proxmox Virtual Environment 7
|
||||||
block:
|
block:
|
||||||
- name: Run upgrade Debian 10
|
- name: include OS specific variables
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_vars: "{{ lookup('ansible.builtin.first_found', params) }}"
|
||||||
file: upgrade-pve-Debian10.yml
|
vars:
|
||||||
when: ansible_distribution_release == "buster"
|
params:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||||
|
paths:
|
||||||
|
- "vars"
|
||||||
|
|
||||||
- name: remove pve-enterprise subscription repo
|
- name: remove pve-enterprise subscription repo
|
||||||
ansible.builtin.file:
|
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:
|
__deb_debian_repos:
|
||||||
- {
|
- {
|
||||||
"line": "deb http://ftp.ru.debian.org/debian bullseye main contrib",
|
"line": "deb http://ftp.ru.debian.org/debian bullseye main contrib",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue