Software Development Kit (SDK) and API Discussions

ansible makes ssh connection instead of zapi/rest

jhelms
980 Views

I created a playbook to do shelf firmware updates, but it keeps failing and says the host is unreachable.  But the debug output clearly shows that it connected to the ONTAP cluster via ssh and then tried to run a bourne shell instead of using a zapi or rest call:

 

<72.32.19.224> ESTABLISH SSH CONNECTION FOR USER: myuser
<72.32.19.224> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="myuser"' -o ConnectTimeout=10 -o ControlPath=/home/john0839/.ansible/cp/e15ac7f1e5 72.32.19.224 '/bin/sh -c '"'"'echo ~myuser && sleep 0'"'"''
<72.32.19.224> (255, '\r\r\nLast login time: 7/17/2023 11:38:14\r\r\nUnsuccessful login attempts since last login: 2\r\r\n\x07\r\nError: "/bin/sh" is not a recognized command\r\n\r\n', '')
fatal: [c-1645000-954872-lab]: UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ",
"unreachable": true

 

The playbook is a very simple shelf fw update (sorry, indention is lost with a paste):

 

---
- hosts: all
gather_facts: false
collections:
- netapp.ontap
name: ONTAP shelf firmware upgrade
tasks:
- name: shelf firmware upgrade
na_ontap_firmware_upgrade:
state: present
firmware _type: shelf
package_url: "{{ 'http://mirror.somedomain.com/storagecenter/NetApp/AllPlatforms/all_shelf_fw_16MAY2023.zip' }}"
hostname: "{{ inventory_hostname }}"
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
https: true
validate_certs: false

 

 

1 ACCEPTED SOLUTION

jhelms
959 Views

Looks like I left out one very important line in the playbook:

 

connection: local

 

"The solution is the task option “connection: local” along with an inventory file containing your cluster names."

 

Many thanks to David Blackwell, wherever he is now.

 

John

View solution in original post

2 REPLIES 2

jhelms
959 Views

I found this thread indicating that I have to specify the cluster in the playbook and can't use an inventory file:

 

https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Ansible-Ontap-not-reachable-when-running-the-playbooks/td-p/437640

 

This defeats the purpose of using ansible to manage a large environment.  And this post indicates that an inventory file CAN be used:

 

https://netapp.io/2019/07/17/running-a-playbook-against-multiple-ontap-clusters/

jhelms
960 Views

Looks like I left out one very important line in the playbook:

 

connection: local

 

"The solution is the task option “connection: local” along with an inventory file containing your cluster names."

 

Many thanks to David Blackwell, wherever he is now.

 

John

Public