#Add schedule to snapshot policy

1 messages · Page 1 of 1 (latest)

kind bolt
#

Is it possible that you improve na_ontap_snapshot_policy.py so that it would be possible to add schedules if there are already schedules present?

fathom nebula
#

So hat do you mean by add Schedule if they are are present?

kind bolt
#

I will try to explain.
Schedule before running the task:

                         Number of Is
Policy Name              Schedules Enabled Comment
------------------------ --------- ------- ----------------------------------
snappol_sandrotest               1 true    -
    Schedule       Count  Prefix        SnapMirror Label    Retention Period
    -------------- -----  ------------- ------------------  ------------------
    ora-hourly         1  ora-hourly    -                   0 seconds

Schedule after i ran the task:

                         Number of Is
Policy Name              Schedules Enabled Comment
------------------------ --------- ------- ----------------------------------
snappol_sandrotest               1 true    -
    Schedule       Count  Prefix        SnapMirror Label    Retention Period
    -------------- -----  ------------- ------------------  ------------------
    backupshare-nightly
                       1  backupshare-nightly
                                        backupshare-nightly
                                                            0 seconds

What i really want is that bacupkshare-nightly would be added to my policy and not to replace the already existing schedule ora-hourly.
Similar to the cli commands snapshot policy add-schedule and snapshot policy remove-schedule would be prefect.

wise obsidian
#

@kind bolt In your scenario, the module usage would be like below:
schedule: ['ora-hourly', 'backupshare-nightly']
prefix: ['ora-hourly', 'backupshare-nightly']
count: [1,1]
snapmirror_label: ['ora-hourly', 'backupshare-nightly']

As the module na_ontap_snapshot_policy takes care of creation & deletion of snapshot policy along with modification of schedules, it is designed to expect all the schedules to be mentioned that need to exist inside the policy; it removes the schedules that are not mentioned in the input list and state: absent is used to delete the snapshot policy itself.

kind bolt
#

I think it would also be advantageous to use a dict for the schedules instead of 3 separate lists.

wise obsidian
kind bolt
fathom nebula
#

So the issue come down to how ansible works. Ansible is going to give you the infrastructure you write down on your playbook. If ora-hourly isn't there it will treat that as you want to delete.

If this was terraform that had the concept of a state, what you would do there would be to import the current state of the machine and then add to it. (https://spacelift.io/blog/ansible-vs-terraform)

You can break this into 2 tasks to get roughly the same results in ansible.

The first task call the na_ontap_rest_info modules to get the current state of the snapshot policy (https://docs.ansible.com/ansible/devel/collections/netapp/ontap/na_ontap_rest_info_module.html#ansible-collections-netapp-ontap-na-ontap-rest-info-module)

Then pass that info to the na_ontap_snapshot_policy with the new variables you want to add.

Spacelift

Ansible vs Terraform: what is the difference between the tools and which one to choose? See a detailed expert comparison and decide for yourself.

kind bolt
# fathom nebula So the issue come down to how ansible works. Ansible is going to give you the in...

Thank you. I don't really agree because I don't need to know the current status on the CLI to add or remove a schedule, but I guess I have to live with it.
Can you also explain me why the module sees snapmirror_label always as a change? I have not changed anything in the variables but module reports it as modify when i run it a second time.

      ontapi: null
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      prefix:
      - hourly
      - weekly
      - backupshare-nightly
      schedule:
      - hourly
      - weekly
      - backupshare-nightly
      snapmirror_label:
      - ''
      - ''
      - backupshare-nightly
      state: present
      use_rest: always
      username: automation
      validate_certs: false
      vserver: null
  modify:
    snapmirror_label:
    - ''
    - ''
    - backupshare-nightly
wise obsidian
# kind bolt Thank you. I don't really agree because I don't need to know the current status ...

The module takes care of the below mentioned commands and designed accordingly.

  • snapshot policy show/create/modify/delete
  • snapshot policy add-schedule/remove-schedule/modify-schedule
    The behavior that you mentioned would be possible if the module would have been designed only to take care of operations related to Snapshot copy policy schedules
    We'll look into the issue with modifying snapmirror_label and revert back.