Automated vyos image install

Hi all! I’ve been trying to do an automated vyos install using Ansible. I’m installing vyos-1.4-rolling-202106190417-amd64.iso in a virtual machine in ESXi so i’ll be using the vm_shell module to do the install as there wasn’t an easy way for me to ssh into the live cd boot.

To make my life easier, and debug issues faster, I’m simplifying it by trying to automate the image install using a vbash script inside the vyos live cd. Once I’ve got it to work, I’ll be able to easily convert it to an Ansible playbook.

Here is the vbash script:

#!/bin/vbash
printf  "%\n" "" "" "" "y" "" "" "" "vyos" "vyos" "" | sudo -k -S /opt/vyatta/sbin/install-image

A few notes about this script:

  • sourcing /opt/vyatta/etc/functions/script-template isn’t necessary because install image isn’t part of it
  • i had to find and use the actual install-image command since install image is just an alias to that
  • the printf line was taken from another post about automating but that post only involved upgrading
  • similar commands ive tried which also don’t work: grouping using { echo ""; echo ""; } | sudo... and using a oneline printf "\n\n\ny\n\n\vyos\n\vyos\n\n" | sudo...

The issue I’m having is it gets stuck at the admin password portion of the install. I figured the password prompt wasn’t reading stdout so using sudo -S would allow it to work but it doesn’t.

I’ve tried adding: --username vyos --password vyos to the istall-image command just in case but it doesn’t help. I was also seeing if there was a parameter to just use the default vyos/vyos creds so it wouldn’t ask me but I couldn’t find anything.

I’m attaching a screenshot of where it gets stuck.

I feel like i’m really close… I just need some ideas! Thanks!

Hi @totoro,

Perhaps you should try this method?:
https://docs.vyos.io/en/latest/automation/cloud-init.html

An example of automated installation with ansible responses
Require “python3-expect”

I’m using vmware ESXi so i don’t think it’s possible to use the expect module the same way you’re using it for KVM. I’m not sure there’s an equivalent to virsh console.

Yes I think i’m forced to. I was hoping i didn’t have to.

I don’t actually think this is going to work. It seems that cloud-init will just do post configuration after installation. I need the install to be automated, not the configuration.

Just deploy it from .ova