#Ansible when condition to create volume
1 messages · Page 1 of 1 (latest)
- name: Create Volumes
netapp.ontap.na_ontap_volume:
state: present
<<: *login
name: "{{ item.name }}"
is_infinite: False
aggregate_name: "{{ aggr_name }}"
size: "{{ item.sizeGB }}"
size_unit: gb
volume_security_style: ntfs
space_guarantee: none
type: RW
snapshot_policy: "{{ item.policy }}"
export_policy: default
percent_snapshot_space: 60
junction_path: "{{ item.junctionpath }}"
vserver: "{{ cifs_svm }}"
compression: True
efficiency_policy: default
wait_for_completion: True
with_items: "{{ volume_policy_path }}"
ignore_errors: True
delegate_to: localhost
i need a when condtion if item.name is not present in the netapp
you don't actually need that. The ansible modules are idempotent. If that volume exists with those settings it does nothing. If it exists and some settings are different it changes them to match. if it doesn't exist it creates with those settings. No errors if things are already how they need to be.