Home > OS >  Ansible - do-release-upgrade without prompts
Ansible - do-release-upgrade without prompts

Time:12-10

On Ubuntu I want to upgrade the OS with the command "do-release-upgrade" via Ansible, but it has prompts that can not be avoided.

Is there a way to use Ansible which answers the prompts to the user who runs the Ansible script?

We have several servers that can not be accessed with SSH, but with Ansible they can.

Servers are on Ubuntu 16.04 and all of servers need to be upgraded to Ubuntu 20.04.

In this process there are a lot of unavoidable prompts.

CodePudding user response:

Is there a way to use ansible playbook which will open possibility to answer on shell script prompt by user who runs ansible script?

You can use the expect module. Example:

- name: Upgrading Software
  expect:
    command: do-release-upgrade
    responses:
      'First Question in the prompt' : 'y'
      'Second Question in the prompt' : 'y'

However, you want to execute the do-release-upgrade without prompts.

- command: do-release-upgrade -f DistUpgradeViewNonInteractive

Please note:

  • Ensure to have a back-up in place before upgrading
  • Ensure all packages are latest version
  • Ensure update-manager-core is installed
  • Ensure to reboot the machine after the do-release-upgrade

Also, please read my first comment. Since you do not have an SSH connection to the machine, it's really hard to debug and see what is going on if something went wrong.

  • Related