I have to execute some shell commands remotely (via SSH) from Ansible, but without external hosts file.
Host information is actually current "item" from the loop, so I have to execute some commands remotely while in this loop (for each item). I already have a loop, but I'm not sure about the code for ssh.
Username and password are variables from Ansible Tower that I can call in this task i.e. "{{username}}" and "{{password}}"
- name: Connect to remote servers via SSH
hosts: "{{item}}"
gather_facts: no
connection: ssh
tasks:
- name: Run command on remote server
command: uptime
register: uptime_output
Is this code correct and where do I put credentials in it?
Thanks.