49 lines
1.7 KiB
YAML
49 lines
1.7 KiB
YAML
---
|
|
# tasks file for ensure_os_upgrade - Ubuntu
|
|
- name: Ensure update-manager-core is installed
|
|
when:
|
|
- ansible_facts["system"] == 'Linux'
|
|
- ansible_facts["distribution"] == 'Ubuntu'
|
|
- ensure_os_upgrade is defined
|
|
ansible.builtin.apt:
|
|
name: update-manager-core
|
|
state: present
|
|
|
|
- name: Configure Ubuntu Release Upgrade Prompt
|
|
when:
|
|
- ansible_facts["system"] == 'Linux'
|
|
- ansible_facts["distribution"] == 'Ubuntu'
|
|
- ensure_os_upgrade is defined
|
|
- ensure_os_upgrade.target_version is defined
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/update-manager/release-upgrades
|
|
regexp: '^Prompt='
|
|
line: "Prompt={{ 'lts' if ensure_os_upgrade.target_version.endswith('.04') else 'normal' }}"
|
|
|
|
- name: Execute Ubuntu Release Upgrade
|
|
when:
|
|
- ansible_facts["system"] == 'Linux'
|
|
- ansible_facts["distribution"] == 'Ubuntu'
|
|
- ensure_os_upgrade is defined
|
|
- ensure_os_upgrade.target_version is defined
|
|
- ansible_facts["distribution_version"] != ensure_os_upgrade.target_version
|
|
ansible.builtin.command: do-release-upgrade -f DistUpgradeViewNonInteractive
|
|
environment:
|
|
DEBIAN_FRONTEND: noninteractive
|
|
DPKG_OPTIONS: '-o Dpkg::Options::="--force-confnew" -o Dpkg::Options::="--force-confdef"'
|
|
|
|
- name: Reboot Ubuntu After Upgrade
|
|
when:
|
|
- ansible_facts["system"] == 'Linux'
|
|
- ansible_facts["distribution"] == 'Ubuntu'
|
|
- ensure_os_upgrade is defined
|
|
- ensure_os_upgrade.target_version is defined
|
|
- ansible_facts["distribution_version"] != ensure_os_upgrade.target_version
|
|
ansible.builtin.reboot:
|
|
msg: "Rebooting for OS Upgrade"
|
|
connect_timeout: 5
|
|
reboot_timeout: 1800
|
|
pre_reboot_delay: 5
|
|
post_reboot_delay: 15
|
|
test_command: whoami
|