#na_ontap_volume module has problem with passed variable

1 messages · Page 1 of 1 (latest)

wary shard
#

on the module, if I specify:

        percent_snapshot_space: "{( snapshot_percent }}"

Then it produces error. The variable is set at AWX, passed as -e variables.
output:

TASK [show types of each var] **************************************************
task path: /runner/project/create_vol.yml:20
ok: [localhost] => {
    "msg": "sizegb  → int\nsnapshot_percent → int\nis_encrypted → bool\nvol_type → AnsibleUnicode\n"
}
TASK [create the volume] *******************************************************
task path: /runner/project/create_vol.yml:38
fatal: [localhost]: FAILED! => {"changed": false, "msg": "argument 'percent_snapshot_space' is of type <class 'str'> and we were unable to convert to int: <class 'str'> cannot be converted to an int"}

But, as you can see from first task, "snapshot_percent" is passed in as int. Even set below did not work.

    percent_snapshot_space: "{{ snapshot_percent | int }}"

However, if I specify number directly:

        percent_snapshot_space: 10

The playbook runs fine.
I am out of clues.

#

I think there is a bug here. Even if I define the variable in the same playbook (not passing with -e), it still complains.

lucid star
#

@wary shard Could you try upgrading your collection version?
I just tested below 2 syntaxes and both worked fine under 22.14.0 collection version:
percent_snapshot_space: 60
percent_snapshot_space: "60"

wary shard
#

I am running 22.14.0. The playbook works when you define:
percent_snapshot_space: 60
It fails when you set:

vars:
  snapshot_percent: 60

...
na_ontap_volume:
  ...
  percent_snapshot_space: "{{ snapshot_percent }}"

any variable passed to percent_snapshot_space will fail, either defined in playbook or pass with -e.

agile radish
#

Does it behave the same outside of AWX?

wary shard
#

yes

agile radish
#

Interesting. It works fine for me.

This is in my vars file:
vol_percent_snapshot_space: 5

This is a snippet from my playbook:

- name: Create the volume.
  netapp.ontap.na_ontap_volume:
    state: present
    password: "{{ netapp_password }}"
    vserver: "{{ vserver }}"
    aggregate_name: "{{ vol_aggr }}"
    name: "{{ vol_name }}"
    size: "{{ vol_size | int }}"
    size_unit: "{{ vol_size_unit }}"
    percent_snapshot_space: "{{ vol_percent_snapshot_space | int }}"
lucid star
# lucid star <@811447393752318014> Could you try upgrading your collection version? I just te...

@wary shard The error is not reproducible! Passing int or str directly worked as well as passing a variable to the parameter.
Could you enable the REST API tracing and share /tmp/ontap_apis.log content that shows the calls being sent to REST and the responses/errors received?
Could you also share the play you're using?

GitHub

Ansible collection to support NetApp ONTAP configuration. - ansible-collections/netapp.ontap

pearl girder
#

I don't see anyone mentioning this but there's a typo in your @wary shard first post, it says:
percent_snapshot_space: "{( snapshot_percent }}"

Note the perenthesis in there, it should be {{ }} instead of {( }}.

analog wasp
#

also, just for information purposes, the modules themselves do not know if you used a variable or if you used direct text. The information is converted before being passed.