-
name: run emcli commands on the remote server
hosts: dbhosts
become: yes
become_user: oracletasks:
- name: run emcli login and logout
shell |
sudo ssh oracle@remote_server << EOF
echo “Hello”
EOF
- name: run emcli login and logout
I don’t think using the ansible.builtin.shell
module to execute tasks on target hosts that establish SSH connections to remote servers is the right strategy.
Ansible Connection
Ansible Inventory
Attempting an SSH connection during playbook execution could lead to issues that are external to Ansible.
I can assume that this approach stems from the fact that remote_server
is not directly reachable from the control node.
Perhaps the best solution would be to configure a jump host to connect to remote_server
.
Something like this :
[remote]
remote_server ansible_host=REMOTE_IP ansible_ssh_common_args='-o ProxyJump=jumphost_user@jumphost'