Failed to connect to the host via ssh

Hello All,

So I’m trying to run a playbook to get my NetApp cluster version. I can SSH directly to the machine(s) I’m trying to test against in the host file, but ansible just won’t connect. I’m running this playbook through AWX. The credentials have been verified multiple times.

It’s always some simple solution, but I’m sure one of the many experts here can help!

Ansible 2.16
NetApp Collection 22.11.0

> ---
> - name: Get NetApp cluster version
>   hosts: all
>   gather_facts: no
>   collections:
>     - netapp.ontap
>   vars:
>     netapp_host: 'single'
>     netapp_username: "{{ netapp_username }}"
>     netapp_password: "{{ netapp_password }}"
>   tasks:
>     - name: Get cluster version
>       netapp.ontap.na_ontap_rest_info:
>         command: ['version']
>         hostname: "{{ netapp_host }}"
>         username: "{{ netapp_username }}"
>         password: "{{ netapp_password }}"
>         https: true
>         validate_certs: false
>       register: result
> 
>     - name: Display cluster version
>       debug:
>         var: result
> ...

The error:

fatal: [IP HERE]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: Warning: Permanently added ‘IP HERE’ (ECDSA) to the list of known hosts.”, “unreachable”: true}

1 Like

So it seems like the netapps don’t connect directly and connect more using the API.

so you need something like this:

hosts: all
connection: local

but, in the examples netapp.ontap/playbooks/examples/na_ontap_pb_upgrade_firmware_with_vars_file.yml at main · ansible-collections/netapp.ontap · GitHub it shows using:

hosts: localhost
1 Like

I got it to work with this playbook.

---
- name: Get NetApp cluster version
  hosts: localhost
  gather_facts: false
  collections:
    - netapp.ontap
  vars:
    login: &login
    netapp_host: '192.168.7.8'
    netapp_username: "{{ netapp_username }}"
    netapp_password: "{{ netapp_password }}"
  tasks:
    - name: Get cluster version
      netapp.ontap.na_ontap_rest_info:
        hostname: "{{ netapp_host }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"
        https: true
        validate_certs: false
        use_rest: true
        gather_subset:
          - ontap_system_version
        parameters:
          fields: "version"
      register: result

    - name: Display cluster version
      debug:
        var: result
...

Here is the output:

TASK [Get cluster version] *****************************************************
ok: [localhost]
TASK [Display cluster version] *************************************************
ok: [localhost] => {
    "result": {
        "changed": false,
        "failed": false,
        "ontap_info": {
            "cluster/software": {
                "_links": {
                    "self": {
                        "href": "/api/cluster/software"
                    }
                },
                "version": "9.14.1"
            }
        }
    }
}
PLAY RECAP *********************************************************************
localhost
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.