I want to pin down Elasticsearch version from changing during OS upgrade.
Getting the below error
FAILED! => {"changed": true, "cmd": ["do-release-upgrade", "-f",
"DistUpgradeViewNonInteractive"], "delta": "0:00:03.862558", "end":
"2022-11-24 20:03:37.481173", "msg": "non-zero return code", "rc": 1,
"start": "2022-11-24 20:03:33.618615", "stderr": "", "stderr_lines":
[], "stdout": "Checking for a new Ubuntu release\nPlease install all
available updates for your release before upgrading.", "stdout_lines":
["Checking for a new Ubuntu release", "Please install all available
updates for your release before upgrading."]}
Below is my Ansible Playbook
- block:
- debug:
msg: "This server is running Ubuntu 18.04 LTS and will be upgraded to 20.04 LTS."
- name: "Excluding Elasticsearch version from being upgraded"
dpkg_selections:
name: elasticsearch
selection: hold
- 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: "Check if a reboot is needed on all servers"
register: reboot_required_file
stat:
path: /var/run/reboot-required
# get_md5: no
- name: "Reboot the server if kernel updated"
reboot:
msg: "Reboot initiated by Ansible for kernel updates"
connect_timeout: 5
reboot_timeout: 300
pre_reboot_delay: 0
post_reboot_delay: 30
test_command: uptime
when: reboot_required_file.stat.exists
- name: "Run do-release-upgrade non-interactively.
command: do-release-upgrade -f DistUpgradeViewNonInteractive
- name: Reboot the server.
reboot:
- name: "Removing elasticsearch from Hold"
dpkg_selections:
name: elasticsearch
selection: install
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version == '18.04'