Page MenuHomeVyOS Platform

Re-instate (vyos.vyos.vyos_command) module parameter support for answer, prompt
Open, Requires assessmentPublicBUG

Description

  • CUSTOMER MESSAGE START ----

$ ansible-galaxy collection list | grep -i vyos
vyos.vyos 6.0.0
$ ansible-playbook -u admin -i ../inventory.ini site.yaml
...
$ ansible-playbook -u admin -i ../inventory.ini site.yaml
TASK [Add VyOS 1.4.4-hyper-v if it's not present] ***********************************
task path: ~/ansible_vyos/tasks/update.yaml:52
[ERROR]: Task failed: Action failed: Unsupported parameters for (vyos.vyos.vyos_command) module: answer, prompt. Supported parameters include: commands, interval, match, retries, wait_for (waitfor).
Origin: ~/ansible_vyos/tasks/update.yaml:52:7
50 # set environment variable TERM to dumb to
51 # trigger skipping the progress bar
52 - name: Add VyOS 1.4.4-hyper-v if it's not present

^ column 7

fatal: [vyos-bit]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (vyos.vyos.vyos_command) module: answer, prompt. Supported parameters include: commands, interval, match, retries, wait_for (waitfor)."}
$ cat tasks/update.yaml
...

  1. set environment variable TERM to dumb to
    1. trigger skipping the progress bar
    2. name: Add VyOS 1.4.4-hyper-v if it's not present when: system_images.stdout_lines | select("search", "1.4.4") | list | length == 0 vyos.vyos.vyos_command: commands:
      • "TERM=dumb && add system image http://remote.server.org//VyOS/vyos-1.4.4-hyperv-amd64.iso" prompt:
      • "What would you like to name this image"
      • "Would you like to set the new image as the default one for boot"
      • "An active configuration was found. Would you like to copy it to the new image"
      • "Would you like to copy SSH host keys" answer:
      • "1.4.4"
      • "Yes"
      • "Yes"
      • "Yes" vars: ansible_command_timeout: 180

...
yet the prompt and answer parameters are still in the current documentation: https://docs.ansible.com/projects/ansible/latest/collections/vyos/vyos/vyos_command_module.html#notes
which stands If a command sent to the device requires answering a prompt, it is possible to pass a dict containing command, answer and prompt. See examples.
I suspect this got lost in the, big announced, 6.0.0 release. https://blog.vyos.io/vyos-ansible-collection-6.0.0-release
I am open to any other Ansible solutions to update/upgrade. It’s been a troubled road for two years now https://forum.vyos.io/t/add-system-image-http-with-ansible/12784

Details

Version
6.0.0
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Bug (incorrect behavior)

Event Timeline

This does not look like a bug but rather as the module mis-use:

The module syntax is different as per vyos.vyos.vyos_command module – Run one or more commands on VyOS devices — Ansible Community Documentation , Namely, commands accept a dictionary of command, prompt and answer

The above is not multi-line, hence one command, one set of prompt/asnwer

I tested with the playbook:

---
- name: Testing all the modules
  hosts: vyos_lab
  gather_facts: false
  tasks:
    - name: Test answer & prompt
      vyos.vyos.vyos_command:
        commands:
          - command: reboot
            prompt: "Are you sure you want to reboot this system (target15x)? [y/N] "
            answer: N
      vars:
        ansible_command_timeout: 20
        ansible_connection: ansible.netcommon.network_cli

Which did not result in error message as per the bug report, but the prompt had to be precisely what the target system outputs, or the run will wait and time out, not being able to parse the output and match