0

Ansible inventory netapp.ontap

I just started to test my first playbooks in Ansible but unfortunately I already fail while setting up an inventory. I am trying to use the module na_ontap_ssh_command (netapp.ontap collection) to run the version command on a NetApp cluster.

The playbook works for a single cluster but as soon as I try to set up an inventory file it does not work.

This works:

---
- hosts: localhost
  collections:
    - netapp.ontap
  name: Cluster ONTAP Version
  vars:
    login: &login
      hostname: cluster1
      username: "{{ netapp_username }}"
      password: "{{ netapp_password }}"
      validate_certs: true
  vars_files:
    - secret.yml

 
  tasks:

  - name: cli Command
    netapp.ontap.na_ontap_ssh_command:
      command: version
      <<: *login
    register: cluster_version

  - name: Print Output
    debug:
      var: cluster_version['stdout_lines_filtered']

I tried to set up the playbook and inventory file according to https://netapp.io/2019/07/17/running-a-playbook-against-multiple-ontap-clusters/ but it does not work:

inventory.yml
cluster1
cluster2
---
- hosts: all
  gather_facts: false
  collections:
    - netapp.ontap
  name: Cluster ONTAP Version
  vars:
   login: &login
      hostname: "{{ inventory_hostname }}"
      username: "{{ netapp_username }}"
      password: "{{ netapp_password }}"
      validate_certs: true
  vars_files:
    - secret.yml

  tasks:
  - name: Version CLI Command
    netapp.ontap.na_ontap_ssh_command:  
      command: version
      <<: *login
    connection: local
    register: cluster_version
    
  - name: Print Output
    debug:
      var: cluster_version['stdout_lines_filtered']

Error message I get is: "the python paramiko module is required" But paramiko is installed and works for a single cluster.

Can anyone please help how to set up an inventory for netapp.ontap modules?

0 Answers0