#volumr_clone and default()

1 messages · Page 1 of 1 (latest)

glass quest
#

I've got a play that I'm trying to feed a varible that is either assigned by the admin or a default dynamically created snapshot name.

Example:

parent_snapshot: "{{ parent_snapshot | default(latest_daily_snapshot) }}"

Where the parent_snapshot var is being left blank so it exercises the default to assure it works.
The error, in essence whines that there is no snapshot name given, where the default should be feeding it 'daily.2024-07-23_0010' via a variable.

Seen below.

      - name: Gather Snapshot_Volume nonsense
        netapp.ontap.na_ontap_rest_info:
          hostname: "{{ g_hostname }}"
          username: "{{ g_username }}"
          password: "{{ g_password }}"
          gather_subset:
          https: true
          validate_certs: false
          use_rest: Always
          use_python_keys: true
          hal_linking: false
          gather_subset:
            - storage/volumes/snapshots
          owning_resource:
            volume_name: "{{ parent_volume }}"
            svm_name: "{{ parent_vserver }}"
          validate_certs: false
        register: results_snapshot
        no_log: false
        
      - ansible.builtin.set_fact:
          daily_snapshots: "{{daily_snapshots + [item.name] }}"
        loop: "{{ results_snapshot.ontap_info.storage_volumes_snapshots.records }}"
      - ansible.builtin.set_fact:
          latest_daily_snapshot: "{{ daily_snapshots | select('match', snapshot_date ) }}"

      - name: create volume clone
        na_ontap_volume_clone:
          state: "{{ state }}"
          parent_vserver: "{{ parent_vserver }}"
          parent_volume: "{{ parent_volume }}"
          vserver: "{{ vserver_properties['name'] }}"
          name: "{{ desired_name }}"
          space_reserve: none
          parent_snapshot: "{{ parent_snapshot | default(latest_daily_snapshot) }}"
          hostname: "{{ g_hostname }}"
          username: "{{ g_username }}"
          password: "{{ g_password }}"
          https: true
          validate_certs: false
hasty isle