run ssh commands on vxworks with ansible

Viewed 389

I have some old equipment that I manage and it is running VXWorks. I am able to ssh into it and run commands, but the commands and/or the prompts are not standard. I would like to use ansible to automate some of the tasks that I do. I am not sure what module to use for this.

  1. Is there a way to just ssh into a box and start running commands with Ansible for non Linux boxes?
  2. Is there a way to download files via scp/sftp with Ansible for non Linux boxes?
  3. How can I get the raw output. The commands I run are generally show commands and I need to see the output of the commands.
1 Answers

Is there a way to just ssh into a box and start running commands with Ansible for non Linux boxes?

That's what Ansible's raw module is for: it's a minimal wrapper for ssh <somehost> <somecommand>.

Is there a way to download files via scp/sftp with Ansible for non Linux boxes?

If the remote system supports scp or sftp, your Ansible playbooks can just run the appropriate scp/sftp command on your local system. E.g.,

- hosts: localhost
  tasks:
    - name: copy a file from the remote system
      command: scp myserver:somefile.txt .

How can I get the raw output. The commands I run are generally show commands and I need to see the output of the commands.

When you run a command in a playbook, you can register the result, and for raw tasks that registered variable will have stdout and stderr attributes containing the output from the command. For example:

- hosts: myserver
  gather_facts: false
  tasks:
    - name: demonstrate the raw module
      raw: date
      register: date

    - debug:
        var: date.stdout

The output from that playbook will include:

TASK [demonstrate the raw module] ************************************************************************************************************************************************************
changed: [myserver]

TASK [debug] *********************************************************************************************************************************************************************************
ok: [myserver] => {
    "date.stdout": "Fri Dec 18 09:09:34 PM EST 2020\r\n"
}

The gather_facts: false part is critical, because that prevents Ansible from trying to implicitly run the setup module on your target host.

Related