#StorageGRID ILM policies in ansible

1 messages · Page 1 of 1 (latest)

crude gust
#

Hey *,
I'm trying to automate our ILM policies with ansible... As there does Not seem to be a labondemand on this, can anybody share examples? I have Problems to define the right Filters I think.

Filter for object size: >= 200KB EC, <200KB 2 copies
Tenant equals a, b or c and bucket ends with foo - do this....

If bucket ends with "backup", autodelete after x days - that's what I already have, I think

serene fog
#

Hi @crude gust , to automate ILM policies you can use na_sg_grid_ilm_rule module to add rules and na_sg_grid_ilm_policy module to apply policies. Here is the link for the netapp.storagegrid collection https://docs.ansible.com/ansible/devel/collections/netapp/storagegrid/index.html
Here i am sharing example task to automate the ILM policies that you have asked. Please let me know if any help needed.

- name: Create ILM rule for EC (object size >= 200KB) na_sg_grid_ilm_rule: api_url: "{{ grid_admin_base_url }}" auth_token: "{{ auth.json.data }}" validate_certs: false name: "EC for >=200KB" tenant_account_id: <your_tenant_account_id> reference_time: ingestTime ingest_behavior: balanced bucket_filter: operator: endsWith value: foo filters: - logicalOperator: "and" criteria: - metadataType: "system" metadataName: "objectSize" operator: "greaterThanOrEquals" value: {{ 200 * 1024 }} placements: - retention: after: 0 erasureCoded: - profileId: <your_ec_profile_id> poolId: <your_ec_pool_id> register: ec_rule

#

- name: Create ILM rule for 2 copies (<200KB) na_sg_grid_ilm_rule: api_url: "{{ grid_admin_base_url }}" auth_token: "{{ auth.json.data }}" validate_certs: false name: "2 copies for <200KB" tenant_account_id: <your_tenant_account_id> reference_time: ingestTime ingest_behavior: balanced bucket_filter: operator: endsWith value: foo filters: - logicalOperator: "and" criteria: - metadataType: "system" metadataName: "objectSize" operator: "lessThan" value: "{{ 200 * 1024 }}" placements: - retention: after: 0 replicated: - poolId: <your_replication_pool_id> copies: 2 register: two_copy_rule

#

- name: Create ILM policy tags: create na_sg_grid_ilm_policy: api_url: "{{ grid_admin_base_url }}" auth_token: "{{ auth.json.data }}" validate_certs: false name: "EC and 2 Copy Policy" state: present reason: "EC for >=200KB, 2 copies for <200KB, tenant a/b/c, bucket ends with foo" rules: - "{{ ec_rule.json.data.id }}" - "{{ two_copy_rule.json.data.id }}"

crude gust
#

Ah, that helps and saved me lots of trial and error.... Thank you very much!
Something like this should be in the documentation of the ansible module