#Add schedule to snapshot policy
1 messages · Page 1 of 1 (latest)
So hat do you mean by add Schedule if they are are present?
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.
@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.
This implies that I have to query which scheldules are in it each time and to rebuild the variables of that policy every time i want to add one.
That's why I asked if it would be possible to extend this module. I think that would make sense.
I think it would also be advantageous to use a dict for the schedules instead of 3 separate lists.
Yes, as mentioned state parameter for this module deals with creation/modification or deletion of snapshot policy. As it can't be used to signify whether one wants to add or remove the schedules, the only way left is to provide the intended list in module input and let the module take care of which schedules to add, which ones to remove, which ones to modify.
Maybe i dont understand it fully.
You are saying that the module is perfect lie it is now, and that there is no room for extension or improvement?
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.
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
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.