Software Development Kit (SDK) and API Discussions

Unexpected error with Ansible connecting to Ontap 9.3

matthias_beck
13,492 Views

Hello together,

 

I try to get Ansible running against a cDOT 9.3 system.

 

ansible 2.5.3
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Aug 4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

 

I have cloned the git repository and copied the files to the appropriate path.

 

Playbook:

---

- name: NetApp Test
  hosts: localhost
  connection: local

  vars:
      netapp_username: admin
      netapp_cluster: FQDN of cluster

  vars_prompt:
  - name: "netapp_password"
    prompt: "Password"

# Create standard roles on NetApp cDot systems
  tasks:
    - name: User_Role_Manager
      na_ontap_user_role:
        state: present
        name: NetAppAdminSupp
        command_directory_name: DEFAULT
        access_level: readonly
        https: yes
        vserver: " {{ netapp_cluster }}"
        hostname: "{{ netapp_cluster }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"

When I run this playbook, I get the following unexpected error:

 

ansible-playbook role_test.yml
Password:

PLAY [NetApp Test] ******************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************
ok: [localhost]

TASK [User_Role_Manager] ************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: netapp_lib.api.zapi.zapi.NaApiError: NetApp API failed. Reason - Unexpected error:
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_0ZJewB/ansible_module_na_ontap_user_role.py\", line 209, in <module>\n    main()\n  File \"/tmp/ansible_0ZJewB/ansible_module_na_ontap_user_role.py\", line 206, in main\n    v.apply()\n  File \"/tmp/ansible_0ZJewB/ansible_module_na_ontap_user_role.py\", line 185, in apply\n    netapp_utils.ems_log_event(\"na_ontap_user_role\", self.server)\n  File \"/tmp/ansible_0ZJewB/ansible_modlib.zip/ansible/module_utils/netapp.py\", line 205, in ems_log_event\n  File \"/usr/lib/python2.7/site-packages/netapp_lib/api/zapi/zapi.py\", line 282, in invoke_successfully\n    result = self.invoke_elem(na_element, enable_tunneling)\n  File \"/usr/lib/python2.7/site-packages/netapp_lib/api/zapi/zapi.py\", line 264, in invoke_elem\n    raise NaApiError('Unexpected error', e.message)\nnetapp_lib.api.zapi.zapi.NaApiError: NetApp API failed. Reason - Unexpected error:\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
        to retry, use: --limit @/git/role_test.retry

PLAY RECAP **************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1

Does anyone have an idea?

 

Regards

Matthias

13 REPLIES 13

dblackwe
13,353 Views

Hello Matthis,

 

This is most likely because you have not authorized http traffic on your cluster yet.  The current version of the modules (which you are using) are http traffic by default.  They can do https by adding 'https: true" to all your tasks, but unless you are using your own certs, this will fail.  The fix to allow self-signed certs is done, just waitng approval to release.  In the mean time here is how you can activate http.

 

cluster:> set -priv advanced

cluster*:>system services web modify -http-enable true

 

Also we are quicker to respond and help on our NetApp.io channels.  Head over to www.netapp.io/slack to get an invite to our slack workspace and join the #configurationmgmt channel.

 

Hope this helps and happy ansibeing.  

matthias_beck
13,336 Views

Hey,

 

Thank you for your respond.

 

I checked teh cluster and I can see, that we have http already enabled.

 

And for https, I have to wait for the release, because we are using certificates which are signed by our CA.

 

Unfortunately, slack is blocked at our proxy server 😞

 

Regards

Matthias

J_curl
13,138 Views

I have the same issue.  9.3P4. HTTP enabled.  netapp_lib.api.zapi.zapi.NaApiError: NetApp API failed. Reason - Unexpected error:

apaug
12,613 Views

Where do I put

https: true in tasks

my Syntax:

tasks:
  https: true
- name: Create Vol
na_cdot_volume:
state: absent
name: ansibletest
aggregate_name: aggr2_sas_fp_node2
size: 1
size_unit: gb
vserver: ho-0001-wnas03t
hostname: "{{ netapp_hostname }}"
username: "{{ netapp_username }}"
password: "{{ netapp_password }}"

 

Do help

dblackwe
12,553 Views

First, if you join us on Slack (get an invite at www.netapp.io/slack) you can get much quicker responses.

 

Second, in your example it goes with the actual module run.

 

tasks:
- name: Create Vol
  na_ontap_volume:  (do not use the na_cdot modules, they are all depreciated and mostly broken)
    state: absent
    name: ansibletest
    aggregate_name: aggr2_sas_fp_node2
    size: 1
    size_unit: gb
    vserver: ho-0001-wnas03t
    hostname: "{{ netapp_hostname }}"
    username: "{{ netapp_username }}"
    password: "{{ netapp_password }}"

    https: true

   validate_certs: false

apaug
12,510 Views

Getting an error:

 

ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.

The error appears to have been in '/home/kkund/volume_create.yml': line 10, column 6, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

tasks:
- name: Create Volume
^ here

 

dblackwe
12,489 Views

Did you copy the whole line after na_ontap_volume?  That part in () was just there as a note for you, it shouldn't be there.

apaug
10,948 Views

I did not copy the text inside the brackets.

This is my playbook:

tasks:
   - name: Create Volume
     na_ontap_volume:
       state: absent
       name: ansibletest1
       aggregate_name: aggr2_sas_fp_node2
       size: 1
       size_unit: gb
       vserver: ho-0001-wnas03t
       hostname: "{{ netapp_hostname }}"
       username: "{{ netapp_username }}"
       password: "{{ netapp_password }}"
       https: true
       validate_certs: false

 

And the error as mentioned previously

dblackwe
10,946 Views

This module was added with Ansible 2.6.  We have even more updates in 2.7 which released Oct 4th.  If you are using a lower version, please update.

apaug
10,942 Views

Thank You!!


@dblackwe wrote:

This module was added with Ansible 2.6.  We have even more updates in 2.7 which released Oct 4th.  If you are using a lower version, please update.


 

chandra1044
9,059 Views

Please try using the task module as netapp.ontap.na_ontap_volume or add below line under hosts

collections:

  - netapp.ontap

 

Hoping you have installed netapp.ontap collection from ansible-galaxy

dblackwe
13,124 Views
If you have https:true and are using self-signed certs, you also need to bypass certificate validation with validate_certs: false

J_curl
13,036 Views

This fixed it for me.  

 


@dblackwe wrote:
If you have https:true and are using self-signed certs, you also need to bypass certificate validation with validate_certs: false

 

Public