Can you ssh to the host with the creds you're providing Ansible?

On Sunday, August 15, 2021 at 12:20:06 PM UTC-4 [email protected] wrote:

> Below is the command to run Ansible Playbook:
>
> ANSIBLE_SCP_IF_SSH=y ansible-playbook -v -i 
> /web/aes/admin/playbooks/PB_BAU/ccc_vel.hosts 
> /web/aes/admin/playbooks/PB_BAU/cccvel_restart.yml -e ENV=$SH_ENV -e 
> ACTION=$SH_ACTION --tags $3 -e instance_name=$Instance
> Here is the playbook code:
>
> - hosts: "{{ENV}}_*"
>   user: "{{USER}}"
>   gather_facts: yes
>   pre_tasks:
>
>        - name: Check if all hosts are reachable
>          fail:
>            msg: >
>              [REQUIRED] ALL hosts to be reachable, so flagging {{ 
> inventory_hostname }} as failed,
>               because host {{ item }} has no facts, meaning it is 
> UNREACHABLE.
>          when: hostvars[item].ansible_facts is not defined
>          with_items: "{{ ansible_play_hosts }}"
>          run_once: true
>          tags: checkserver
>
>
>        - debug:
>            msg: "This message means all hosts are reachable"
>          tags: checkserver
>
>   tasks:
>        - name: "Ping {{ENV}} vel Servers"
>          ping:
>
>   roles:
>     - { role: BL, when: USER == 'dias' and 'Business' in instance_name }
> I get Data could not be sent to remote host \"server17.mybank.com\". Make 
> sure this host can be reached over ssh: Connection timed out during banner 
> exchange\r\nConnection to 192.168.41.239 port 22 timed out\r\n error.
>
> TASK [Check if all hosts are reachable] 
> ****************************************
> [0;36mskipping: [server17.mybank.com] => (item=server17.mybank.com)  => 
> {"ansible_loop_var": "item", "changed": false, "item": "
> server17.mybank.com", "skip_reason": "Conditional result was False"}[0m
>
> TASK [debug] 
> *******************************************************************
> [0;32mok: [server17.mybank.com] => {[0m
> [0;32m    "msg": "This message means all hosts are reachable"[0m
> [0;32m}[0m
>
> TASK [BL : Starting BL Services in "stg" environment] 
> **************************
> [1;31mfatal: [server17.mybank.com]: UNREACHABLE! => {"changed": false, 
> "msg": "Data could not be sent to remote host \"server17.mybank.com\". 
> Make sure this host can be reached over ssh: Connection timed out during 
> banner exchange\r\nConnection to 192.168.41.239 port 22 timed out\r\n", 
> "unreachable": true}[0m
> [0;33mchanged: [server17.mybank.com] => {"changed": true, "cmd": "source 
> ~/.profile; sh ~/startbusinesslogicservices.sh", "delta": "0:00:16.058674", 
> "end": "2021-08-15 08:53:14.706432", "rc": 0, "start": "2021-08-15 
> 08:52:58.647758", "stderr": "", "stderr_lines": [], "stdout": "Starting 
> Apache... Please wait... \n\n\nApache started successfully... \nonline 
>
> .....
> .....
> .....
> I'm using Ansible version 2.10
>
> As you can see despite the error the role's task seems to have triggered 
> and the services tried to start.
>
> Can you please suggest the exact fix for this issue please?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3a3a2767-cb4e-4ec4-aea4-2108111a569en%40googlegroups.com.

Reply via email to