Skip to content

Instantly share code, notes, and snippets.

@mlesaout
Last active April 1, 2024 05:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlesaout/d8e5046a584a4b9edface0a5b83a4921 to your computer and use it in GitHub Desktop.
Save mlesaout/d8e5046a584a4b9edface0a5b83a4921 to your computer and use it in GitHub Desktop.
---
- 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