We've started using ansible in our environment for the purpose of creating volumes in our NetApp (FAS500f) and hopefully doing the same on our other NetApp. The question is, we sometimes have to create a high number of volumes, and we were hoping to use Ansible to batch create volumes using a loop. But when i create a loop, it tries to name the volume with each item in the loop.
below my yaml file:
- hosts: localhost
name: Create NFS Volumes for uas as VMware Datastore
vars:
hostname: x.x.x.x
username: *********
password: *********
vol_name: "{{ item }}"
item:
- HM0_STCL02_N01_PER_FLEXVOL006
- HM0_STCL02_N01_PER_FLEXVOL007
- HM0_STCL02_N01_PER_FLEXVOL007
#junction_name: /HM0_STCL02_N01_PER_FLEXVOL006
collections:- netapp.ontap
tasks: - name: Volume Create
netapp.ontap.na_ontap_volume:
state: present
name: "{{ vol_name }}"
is_infinite: False
aggregate_name: HM0_STCL02_N01_SSD_CAP_1
size: 6
size_unit: tb
user_id: 0
group_id: 0
space_guarantee: none
tiering_policy: auto
export_policy: EQ-Flexpod
percent_snapshot_space: 16
vserver: HM0_STCL02_N01_FLEX_NFS
wait_for_completion: True
#junction_path: "{{ junction_name }}"
validate_certs: false
use_rest: always
hostname: "{{ hostname }}"
username: "{{ username }}"
password: "{{ password }}"
- netapp.ontap
the error message:
"msg": "Error creating volume ['HM0_STCL02_N01_PER_FLEXVOL006', 'HM0_STCL02_N01_PER_FLEXVOL007', 'HM0_STCL02_N01_PER_FLEXVOL007']: calling: storage/volumes: got {'message': 'Volume name: The first character must be a letter or underscore.', 'code': '917887', 'target': 'name'}."
}
Is it possible to loop volume creation? perhaps i'm using the wrong approach.
thank you.