Silent installation option

I wish to automate the installation of the latest rolling release on my test router. I.e. run a task-scheduler job to pull the latest version and reboot at some early hour in the morning.

The "add system image " requires interactive input. Is this some way around this or another route I should be taking here?

Hi @phillipmcmahon
If you have installed a box with vyos and need to upgrade, you can use “expect” scripts.
In this example vyos already installed and it’s upgrade procedure.
You need any linux with additional package “expect” and login to vyos by the key.
It’s for LTS, but can be adapted to rolling.

#!/usr/bin/env bash

remote_vyos_host=$1

expect <<EOF

  set timeout 180
  spawn ssh vyos@$remote_vyos_host

  expect "vyos*:~"  {send "add system image /home/vyos/vyos-1.2.5-amd64.iso\r"}
  expect "What would you like to name this image?" {send "\r"}
  expect "directory and config file?" {send "Yes\r"}
  expect "current configuration? (Yes/No)" {send "Yes\r"}
  expect "vyos*:~"  {send "reboot\r"}
  expect "Are you sure you want to reboot this system"  {send "y\r"}
  expect "vyos*:~" {send "\r"}
  exit 0

EOF

Let me know if you have any questions.

Thanks for this, I will give it go. It does include a dependency on an external machine which I would prefer to avoid.

For rolling what would need to be changed for this to work?

Is there a way to do this locally on the vyos installation?

Script for upgrade rolling release from local iso file located in /home/vyos.

#!/usr/bin/env bash

remote_vyos_host=$1

# Check that the ip address as the first argument is set
if [ $# -ne 1 ]; then
    echo "Usage: $0 <vyos_ip_adderss>"
    exit 1
fi

expect <<EOF

  set timeout 600
  spawn ssh vyos@$remote_vyos_host

  expect "vyos*:~"  {send "add system image /home/vyos/vyos-rolling-latest.iso\r"}
  expect "What would you like to name this image?"  {send "\r"}
  expect "directory and config file?" {send "Yes\r"}
  expect "current configuration? (Yes/No)" {send "Yes\r"}
  expect "vyos*:~"  {send "reboot\r"}
  expect "Are you sure you want to reboot this system"  {send "y\r"}
  expect "vyos*:~" {send "\r"}
  exit 0

EOF

./upgrade.sh x.x.x.x
Where x.x.x.x ip address that is accessible by ssh key for user “vyos”.

I don’t know another way to get around interactive questions without “expect” or “ansible” (interactive application).

Awesome, let me try this in that case.

Perhaps there could be an extension of the add system image that performs a quiet install with no prompts, of the answer to the prompts can be provided in the command line?

Hi @phillipmcmahon
Do you need upgrade or clean install?
Can you check that command (for upgrade)? It working on test node.
From local iso:

vyos@r-roll:~$ printf '%s\n' "" "Yes" "Yes"  | add system image  /home/vyos/vyos-rolling-latest.iso  && reboot now

From remote site:

vyos@r-roll:~$ printf '%s\n' "Yes" "" "Yes" "Yes" | add system image https://downloads.vyos.io/rolling/current/amd64/vyos-rolling-latest.iso && reboot now

1 Like

Sorry, didn’t get a notification that you had replied.

These are for upgrades and not clean installs. Will test out those commands tomorrow and get back to you.

How are your tests? Is this suitable for your case?

Tested and works fine, I used the remote site as that makes the process even simpler, reducing the need to move a local copy to my device.

Many thanks for the inventive solution!

I still think a native Vyos silent install option makes sense, but not critical.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.