Last active
September 23, 2024 18:14
-
-
Save mlesaout/d8e5046a584a4b9edface0a5b83a4921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: legacyservers | |
gather_facts: yes | |
become: yes | |
tasks: | |
# Use a block to perform tasks conditionally—only if running Ubuntu 18.04. | |
- block: | |
- debug: | |
msg: 'This server is running Ubuntu 18.04 LTS and will be upgraded to 20.04 LTS.' | |
# Now would be a good time to take a backup if you can trigger an | |
# automated backup! | |
- name: Remove the EOL message of the day if one exists. | |
file: | |
path: "{{ item }}" | |
state: absent | |
with_items: | |
- /etc/update-motd.d/99-esm | |
- /run/motd.dynamic | |
- name: Upgrade all packages to the latest version | |
apt: update_cache=yes upgrade=full | |
- name: Ensure update-manager-core is installed. | |
apt: name=update-manager-core state=present | |
- name: Run do-release-upgrade non-interactively. | |
command: do-release-upgrade -f DistUpgradeViewNonInteractive | |
- name: Reboot the server. | |
reboot: | |
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04' | |
# After the playbook is finished, it's a good idea to confirm all the servers | |
# are actually upgraded. Run something like: | |
# ansible [group] -a "lsb_release -a" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment