Software Development Kit (SDK) and API Discussions

Issues with ansible netapp module na_ontap_volume to create volume on Ontap

HimanshuRajpal
2,058 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
1,997 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

2 REPLIES 2

JohnChampion
1,998 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
1,967 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 ~]$

Public