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.