I am trying to run command on remote host from another remote host using 'delegate_to' and both hosts are linux.
Connection is successful when sshing directly on each server, but not from Ansible. Here is what I have so far:
- hosts: server1
gather_facts: no
tasks:
- name: test
delegate_to: server2
vars:
ansible_user: "user1"
ansible_ssh_pass: "password"
ansible_ssh_common_args: "-o StricHostKeyChecking=no -o ConnectTimeout=300"
shell: "hostname"
The "server2" ip address is stored in a variable, too, within the playbook, not in the inventory. Incrementing the connection timeout doesn't work. I'm getting
[Errno 110] Connection timed out
What else should I check?
ansible all -m ping
) or have you just made a direct SSH connection? If so, have you checked that you are definitely using the same credentials since you seem to be setting them directly in the playbook, rather than in config files? – Calum Halpindelegate_to
doesn't mean thatserver1
will run the task onserver2
. It means the controller (your local machine) will run the task onserver2
usingserver1
's facts. – Calum Halpin