Software Development Kit (SDK) and API Discussions

Issues with ansible netapp module na_ontap_volume to create volume on Ontap

HimanshuRajpal
4,163 Views

Hi Netapp Support Team,

 

I have been trying to use ansible netapp module na_ontap_volume to create volume on Ontap. Tried to scenarios, both failing with different error messages.

Could you please help me with this, don’t what’s going wrong here?

 

Scenario 1:

 

[ansible@server ~]$ cat ansible_vol.yaml

hostname: 'x.x.x.x'

username: 'xxxxxx'

password: 'xxxxxxxx'

vserver: 'xxxx_xxx_xxx'

aggr: 'xxxx_xxxxx_xxxx'

vol_name: 'ansibleVol'

[ansible@server ~]$ cat volume_lifecycle.yaml

---

- hosts: localhost

  collections:

    - netapp.ontap

  name: Volume Lifecycle

  vars_files:

    /home/ansible/ansible_vol.yaml

  tasks:

  - name: Volume Create

    na_ontap_volume:

      state: present

      name: “{{ vol_name }}”

      vserver: “{{ vserver }}”

      aggregate_name: “{{ aggr }}”

      size: 10

      size_unit: gb

      policy: default

      junction_path: “/{{ vol_name }}”

      hostname: “{{ hostname }}”

      username: “{{ username }}”

      password: “{{ password }}”

      https: True

      validate_certs: false

[ansible@server ~]$ ansible-playbook volume_lifecycle.yaml --extra-vars "@ansible_vol.yaml"

[WARNING]: No inventory was parsed, only implicit localhost is available

 

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

 

 

PLAY [Volume Lifecycle] ***************************************************************************************************************************************************************************************

 

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************

ok: [localhost]

 

TASK [Volume Create] ******************************************************************************************************************************************************************************************

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:UnicodeEncodeError('latin-1', '“x.x.x.x”:443', 0, 1, 'ordinal not in range(256)')

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error fetching volume “ansibleVol” : NetApp API failed. Reason - Unexpected error:UnicodeEncodeError('latin-1', '“x.x.x.x”:443', 0, 1, 'ordinal not in range(256)')"}

 

PLAY RECAP ****************************************************************************************************************************************************************************************************

localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

 

[ansible@server ~]$

 

 

Scenario 2:

 

[ansible@server ~]$ cat ansible_vol.yaml

hostname: ‘x.x.x.x’

username: 'xxxxxxx'

password: 'xxxxx@xxx@'

vserver: 'xxxxx_xxx_xxx'

aggr: 'xxxx_xxxx_xxxx'

vol_name: 'ansibleVol'

size: 10

[ansible@server ~]$ cat volume_lifecycle.yaml

---

- hosts: localhost

  collections:

    - netapp.ontap

  name: Volume Lifecycle

  vars_files:

    /home/ansible/ansible_vol.yaml

  tasks:

  - name: Volume Create

    na_ontap_volume:

      state: present

      name: “{{ vol_name }}”

      vserver: “{{ vserver }}”

      aggregate_name: “{{ aggr }}”

      size: “{{ size }}”

      size_unit: gb

      policy: default

      junction_path: “/{{ vol_name }}”

      hostname: “{{ hostname }}”

      username: “{{ username }}”

      password: “{{ password }}”

      https: True

      validate_certs: false

[ansible@server ~]$ ansible-playbook volume_lifecycle.yaml --extra-vars "@ansible_vol.yaml"

[WARNING]: No inventory was parsed, only implicit localhost is available

 

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

 

 

PLAY [Volume Lifecycle] ***************************************************************************************************************************************************************************************

 

TASK [Gathering Facts] ****************************************************************************************************************************************************************************************

ok: [localhost]

 

TASK [Volume Create] ******************************************************************************************************************************************************************************************

fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument size is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"}

 

PLAY RECAP ****************************************************************************************************************************************************************************************************

localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

 

[ansible@server ~]$

 

 

Regards

Himanshu Rajpal

1 ACCEPTED SOLUTION

JohnChampion
4,102 Views

You'll get help faster through the Slack channel - go to netapp.io and click on the "Slack" icon (top-right) to get the invite.  Ansible is supported through Slack - on the #configurationmgmt channel.

 

Try adding "  | int" to the end of your size: setting perhaps?  

 

size: “{{ size | int }}”

 

 

View solution in original post

3 REPLIES 3

JohnChampion
4,103 Views

You'll get help faster through the Slack channel - go to netapp.io and click on the "Slack" icon (top-right) to get the invite.  Ansible is supported through Slack - on the #configurationmgmt channel.

 

Try adding "  | int" to the end of your size: setting perhaps?  

 

size: “{{ size | int }}”

 

 

HimanshuRajpal
4,062 Views

Thanks for your response. I will move this communication to Slack channel

 

However, I already tried size: “{{ size | int}}” but no luck. See below.

 

[ansible@server ~]$ cat volume_lifecycle.yaml
---
- hosts: localhost
collections:
- netapp.ontap
name: Volume Lifecycle
vars_files:
/home/ansible/ansible_vol.yaml
tasks:
- name: Volume Create
na_ontap_volume:
state: present
name: “{{ vol_name }}”
vserver: “{{ vserver }}”
aggregate_name: “{{ aggr }}”
size: “{{ size | int}}”
size_unit: gb
policy: default
junction_path: “/{{ vol_name }}”
hostname: “{{ hostname }}”
username: “{{ username }}”
password: “{{ password }}”
https: True
validate_certs: false
[ansible@server ~]$ cat ansible_vol.yaml
hostname: 'x.x.x.x'
username: 'xxxxxxx'
password: 'xxxxxx@xxx'
vserver: 'xxxxxxxx'
aggr: 'xxx_xxx_xxxx'
vol_name: 'ansibleVol'
size: 10
[ansible@server ~]$

 

[ansible@server ~]$ ansible-playbook volume_lifecycle.yaml --extra-vars "@ansible_vol.yaml"
[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


PLAY [Volume Lifecycle] ***************************************************************************************************************************************************************************************

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

TASK [Volume Create] ******************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument size is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"}

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

[ansible@server ~]$

MarktheSpark
1,885 Views

Hello,

Just in case anyone else stumbles over this problem again, I'll post the solution here.

The issue lies with the quotation mark characters that present in the exmple code at https://netapp.io/2018/10/11/getting-started-with-netapp-and-ansible-first-playbook-example/.

When you copy and paste this into your editor, VSCode for me, those quotation mark characters are copied as unicode characters U+201C and U+201D. Assible doesn't seem to like these so produces the error you reported above.

The solution is to replace these with normal quotation marks, unicode U+0022.

Hope that helps anyone else that is falling at the first hurdle on their NetApp with Ansible journey!.

Public