├── README.md └── ontap ├── add_network_lif_to_svm.yml ├── assign_disks_to_node.yml ├── create_export_rule.yml ├── create_mulitple_aggregates.yml ├── create_or_delete_broadcast_domain.yml ├── enable_autosupport.yml ├── enable_iscsi_service_on_svm.yml ├── list_all_cifs_servers_on_cluster.yml ├── list_all_lifs_created_on_specific_vserver.yml ├── list_all_luns_on_cluster.yml ├── list_all_nodes_in_cluster.yml ├── list_volumes_in_svm.yml ├── look_up_aggr_name_and_node_for_root_aggregates.yml ├── lookup_volume_export_policy.yml ├── loop_through_multiple_volume_creates.yml ├── lun_and_volume_create.yml ├── report_specific_aggregate_free_space.yml ├── select_aggregate_by_usable_space_and_disk_type.yml ├── single_volume_used_free_total_space_report.yml ├── single_volume_used_space_report.yml └── verify_snapshot_policy_exists_or_list_options.yml /README.md: -------------------------------------------------------------------------------- 1 | ************************************************************************************* 2 | All content shared on this site, including but not limited to Ansible Playbooks 3 | and Terraform Configurations, is provided as a courtesy. Contributors to this 4 | site cannot lay claim of ownership to any content, the same applies to users. 5 | Contributions are intended to serve as examples that can be used in whole or 6 | part. Although not prohibited, these examples are shared with the expectations 7 | that they will not be sold or packaged for resale. Usage of material on this 8 | site is on an "at will" basis. Content posted on this site is not warranted or 9 | supported. Users are responsible for determining the suitability of material 10 | posted here for their purposes. 11 | ************************************************************************************* 12 | -------------------------------------------------------------------------------- /ontap/add_network_lif_to_svm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Create interface for vserver 9 | na_ontap_interface: 10 | state: present 11 | interface_name: "{{ lif_name }}" 12 | home_port: "{{ port }}" 13 | home_node: "{{ node }}" 14 | role: "data" 15 | admin_status: up 16 | is_auto_revert: true 17 | address: "{{ address }}" 18 | netmask: "{{ netmask }}" 19 | vserver: "{{ vserver }}" 20 | hostname: "{{ hostname }}" 21 | username: "{{ username }}" 22 | password: "{{ password }}" 23 | https: true 24 | validate_certs: false 25 | -------------------------------------------------------------------------------- /ontap/assign_disks_to_node.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Assign unowned disks 9 | na_ontap_disks: 10 | node: "{{ node }}" 11 | disk_count: "{{ count }}" 12 | https: true 13 | validate_certs: false 14 | hostname: "{{ hostname }}" 15 | username: "{{ username }}" 16 | password: "{{ password }}" 17 | -------------------------------------------------------------------------------- /ontap/create_export_rule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Setup rules 9 | na_ontap_export_policy_rule: 10 | state: present 11 | name: "{{ policy }}" 12 | vserver: "{{ vserver }}" 13 | client_match: "{{ client_match }}" 14 | ro_rule: "{{ ro_rule }}" 15 | rw_rule: "{{ rw_rule }}" 16 | super_user_security: "{{ su_rule }}" 17 | hostname: "{{ hostname }}" 18 | username: "{{ username }}" 19 | password: "{{ password }}" 20 | https: true 21 | validate_certs: false 22 | -------------------------------------------------------------------------------- /ontap/create_mulitple_aggregates.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Create Aggrs 9 | na_ontap_aggregate: 10 | state: "{{ state }}" 11 | name: "{{ item.name }}" 12 | nodes: "{{ item.node }}" 13 | disk_count: 26 14 | raid_size: 26 15 | #disk_type: FCAL 16 | https: true 17 | validate_certs: false 18 | hostname: "{{ hostname }}" 19 | username: "{{ username }}" 20 | password: "{{ password }}" 21 | with_items: 22 | - { name: "aggr1", node: "vsim-01" } 23 | - { name: "aggr2", node: "vsim-01" } 24 | - { name: "aggr3", node: "vsim-02" } 25 | - { name: "aggr4", node: "vsim-02" } 26 | -------------------------------------------------------------------------------- /ontap/create_or_delete_broadcast_domain.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Create bcast 9 | na_ontap_broadcast_domain: 10 | state: "{{ state }}" 11 | broadcast_domain: demo 12 | mtu: 9000 13 | ipspace: Default 14 | ports: vsim-01:a0a,vsim-01:a0a-100,vsim-02:a0a,vsim-02:a0a-100 15 | https: true 16 | validate_certs: false 17 | hostname: "{{ hostname }}" 18 | username: "{{ username }}" 19 | password: "{{ password }}" 20 | -------------------------------------------------------------------------------- /ontap/enable_autosupport.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Enable autosupport 9 | na_ontap_autosupport: 10 | hostname: "{{ hostname }}" 11 | username: "{{ username }}" 12 | password: "{{ password }}" 13 | https: "{{ https }}" 14 | validate_certs: "{{ validate_certs }}" 15 | state: present 16 | node_name: "{{ node_name }}" 17 | transport: https 18 | noteto: "{{ recipients_emails }}" 19 | mail_hosts: "{{ mail_servers }}" 20 | support: False 21 | post_url: "url/1.0/post" 22 | -------------------------------------------------------------------------------- /ontap/enable_iscsi_service_on_svm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | gather_facts: false 4 | collections: 5 | - netapp.ontap 6 | tasks: 7 | - name: Create iscsi service 8 | na_ontap_iscsi: 9 | state: present 10 | service_state: started 11 | vserver: "{{ vserver }}" 12 | hostname: "{{ hostname }}" 13 | username: "{{ username }}" 14 | password: "{{ password }}" 15 | https: true 16 | validate_certs: false 17 | -------------------------------------------------------------------------------- /ontap/list_all_cifs_servers_on_cluster.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather facts 9 | na_ontap_info: 10 | state: info 11 | gather_subset: cifs_server_info 12 | hostname: "{{ hostname }}" 13 | username: "{{ username }}" 14 | password: "{{ password }}" 15 | https: true 16 | validate_certs: false 17 | register: ontap_info 18 | - debug: 19 | msg: "{{ item }}" 20 | loop: "{{ ontap_info.ontap_info.cifs_server_info|list }}" 21 | -------------------------------------------------------------------------------- /ontap/list_all_lifs_created_on_specific_vserver.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather facts 9 | na_ontap_info: 10 | state: info 11 | gather_subset: net_interface_info 12 | vserver: "{{ vserver }}" 13 | hostname: "{{ hostname }}" 14 | username: "{{ username }}" 15 | password: "{{ password }}" 16 | https: true 17 | validate_certs: false 18 | register: ontap_info 19 | - debug: 20 | msg: "{{ ontap_info.ontap_info.net_interface_info[item] }}" 21 | loop: "{{ ontap_info.ontap_info.net_interface_info|list }}" 22 | -------------------------------------------------------------------------------- /ontap/list_all_luns_on_cluster.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | collections: 5 | - netapp.ontap 6 | vars: 7 | state: present 8 | tasks: 9 | - name: Gather facts 10 | na_ontap_info: 11 | state: info 12 | gather_subset: lun_info 13 | hostname: "{{ hostname }}" 14 | username: "{{ username }}" 15 | password: "{{ password }}" 16 | https: true 17 | validate_certs: false 18 | register: ontap_info 19 | - debug: 20 | msg: "{{ item }}" 21 | loop: "{{ ontap_info.ontap_info.lun_info|list }}" 22 | -------------------------------------------------------------------------------- /ontap/list_all_nodes_in_cluster.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather facts 9 | na_ontap_info: 10 | state: info 11 | gather_subset: cluster_node_info 12 | hostname: "{{ hostname }}" 13 | username: "{{ username }}" 14 | password: "{{ password }}" 15 | https: true 16 | validate_certs: false 17 | register: ontap_info 18 | - debug: 19 | msg: "{{ item }}" 20 | loop: "{{ ontap_info.ontap_info.cluster_node_info|list }}" 21 | -------------------------------------------------------------------------------- /ontap/list_volumes_in_svm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather facts 9 | na_ontap_info: 10 | state: info 11 | gather_subset: volume_info 12 | hostname: "{{ hostname }}" 13 | vserver: "{{ vserver }}" 14 | username: "{{ username }}" 15 | password: "{{ password }}" 16 | https: true 17 | validate_certs: false 18 | register: netapp_info 19 | - debug: 20 | msg: "{{ netapp_info.ontap_info.volume_info[item].volume_id_attributes.name }}" 21 | loop: "{{ netapp_info.ontap_info.volume_info|list }}" 22 | -------------------------------------------------------------------------------- /ontap/look_up_aggr_name_and_node_for_root_aggregates.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather aggregate facts 9 | na_ontap_info: 10 | gather_subset: aggregate_info 11 | hostname: "{{ hostname }}" 12 | username: "{{ username }}" 13 | password: "{{ password }}" 14 | https: "{{ https }}" 15 | validate_certs: "{{ validate_certs }}" 16 | register: netapp_info 17 | - debug: 18 | msg: "{{ item }} is on {{ netapp_info.ontap_info.aggregate_info[item].aggr_ownership_attributes.home_name }}" 19 | with_items: "{{ netapp_info.ontap_info.aggregate_info }}" 20 | when: netapp_info.ontap_info.aggregate_info[item].aggr_raid_attributes.is_root_aggregate == 'true' 21 | -------------------------------------------------------------------------------- /ontap/lookup_volume_export_policy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | vars_files: 8 | cred.yml 9 | vars: 10 | state: present 11 | volname: vol1 12 | vserver: ansible_vserver 13 | tasks: 14 | - name: Gather facts 15 | na_ontap_info: 16 | state: info 17 | gather_subset: volume_info 18 | hostname: "{{ hostname }}" 19 | vserver: "{{ vserver }}" 20 | query: 21 | volume-attributes: 22 | volume-id-attributes: 23 | name: '"{{ volname }}"' 24 | username: "{{ username }}" 25 | password: "{{ password }}" 26 | https: "{{ https }}" 27 | validate_certs: "{{ validate_certs }}" 28 | register: netapp_info 29 | - set_fact: 30 | policy: "{{ netapp_info.ontap_info.volume_info[item].volume_export_attributes.policy }}" 31 | with_items: "{{ netapp_info.ontap_info.volume_info }}" 32 | - debug: 33 | msg: "{{ policy }}" 34 | -------------------------------------------------------------------------------- /ontap/loop_through_multiple_volume_creates.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | collections: 4 | - netapp.ontap 5 | gather_facts: false 6 | name: Loop of volume creation 7 | tasks: 8 | - name: Create Volumes 9 | na_ontap_volume: 10 | state: present 11 | name: "{{ item.volume }}" 12 | size: "{{ item.volume_size }}" 13 | size_unit: "{{ item.volume_size_unit }}" 14 | vserver: "{{ item.vserver }}" 15 | aggregate_name: "{{ item.aggregate_name }}" 16 | hostname: "{{ hostname }}" 17 | username: "{{ netapp_username }}" 18 | password: "{{ netapp_password }}" 19 | https: true 20 | validate_certs: false 21 | loop: 22 | - { volume: 'volume1', volume_size: '10', volume_size_unit: 'mb', vserver: 'vserver_name', aggregate_name: 'aggr1' } 23 | - { volume: 'volume2', volume_size: '20', volume_size_unit: 'mb', vserver: 'vserver_name', aggregate_name: 'aggr2' } 24 | - { volume: 'volume3', volume_size: '30', volume_size_unit: 'mb', vserver: 'vserver_name', aggregate_name: 'aggr1' } 25 | - { volume: 'volume4', volume_size: '40', volume_size_unit: 'mb', vserver: 'vserver_name', aggregate_name: 'aggr2' } 26 | - { volume: 'volume5', volume_size: '50', volume_size_unit: 'mb', vserver: 'vserver_name', aggregate_name: 'aggr1' } 27 | -------------------------------------------------------------------------------- /ontap/lun_and_volume_create.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | collections: 5 | - netapp.ontap 6 | tasks: 7 | - name: Create volume 8 | na_ontap_volume: 9 | state: present 10 | name: "{{ volname }}" 11 | aggregate_name: "{{ aggr }}" 12 | size: "{{ size }}" 13 | size_unit: gb 14 | junction_path: "/{{ volname }}" 15 | space_guarantee: "none" 16 | vserver: "{{ vserver }}" 17 | hostname: "{{ hostname }}" 18 | username: "{{ username }}" 19 | password: "{{ password }}" 20 | https: true 21 | validate_certs: false 22 | - name: Create LUN 23 | na_ontap_lun: 24 | state: "{{ state }}" 25 | vserver: "{{ vserver }}" 26 | name: "{{ volname }}_01" 27 | flexvol_name: "{{ volname }}" 28 | size: "{{ size }}" 29 | size_unit: gb 30 | ostype: "{{ ostype }}" 31 | space_reserve: False 32 | https: true 33 | validate_certs: false 34 | hostname: "{{ hostname }}" 35 | username: "{{ username }}" 36 | password: "{{ password }}" 37 | -------------------------------------------------------------------------------- /ontap/report_specific_aggregate_free_space.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather aggregate facts 9 | na_ontap_info: 10 | gather_subset: aggregate_info 11 | hostname: "{{ hostname }}" 12 | query: 13 | aggr-attributes: 14 | aggregate-name: '"{{ aggr }}"' 15 | username: "{{ username }}" 16 | password: "{{ password }}" 17 | https: "{{ https }}" 18 | validate_certs: "{{ validate_certs }}" 19 | register: netapp_info 20 | - set_fact: 21 | aggr_free: "{{ netapp_info.ontap_info.aggregate_info[aggr].aggr_space_attributes.size_available | int / 1024 / 1024 / 1024 }}" 22 | - debug: 23 | msg: "{{ aggr_free }}" 24 | -------------------------------------------------------------------------------- /ontap/select_aggregate_by_usable_space_and_disk_type.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Select Aggregate 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather aggregate facts 9 | na_ontap_info: 10 | gather_subset: aggregate_info 11 | hostname: "{{ hostname }}" 12 | query: 13 | aggr-attributes: 14 | aggr-raid-attributes: 15 | aggregate-type: "{{ aggr_type }}" 16 | username: "{{ username }}" 17 | password: "{{ password }}" 18 | https: "{{ https }}" 19 | validate_certs: "{{ validate_certs }}" 20 | register: netapp_info 21 | - set_fact: 22 | aggr_name: "{{ item }}" 23 | with_items: "{{ netapp_info.ontap_info.aggregate_info }}" 24 | when: 25 | - aggr_name is not defined 26 | - "{{ netapp_info.ontap_info.aggregate_info[item].aggr_space_attributes.size_available | int / 1024 / 1024 / 1024 }} > {{ size }}" 27 | - netapp_info.ontap_info.aggregate_info[item].aggr_space_attributes.percent_used_capacity < used_cap 28 | - debug: 29 | msg: "{{ aggr_name }}" 30 | -------------------------------------------------------------------------------- /ontap/single_volume_used_free_total_space_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather facts 9 | na_ontap_info: 10 | state: info 11 | gather_subset: volume_info 12 | hostname: "{{ hostname }}" 13 | vserver: "{{ vserver }}" 14 | query: 15 | volume-attributes: 16 | volume-id-attributes: 17 | name: '"{{ volname }}"' 18 | username: "{{ username }}" 19 | password: "{{ password }}" 20 | https: "{{ https }}" 21 | validate_certs: "{{ validate_certs }}" 22 | register: netapp_info 23 | - set_fact: 24 | used_space: "{{ (netapp_info.ontap_info.volume_info[item].volume_space_attributes.size_used | int / 1024 / 1024 / 1024) | round }}" 25 | free_space: "{{ (netapp_info.ontap_info.volume_info[item].volume_space_attributes.size_available | int / 1024 / 1024 / 1024) | round }}" 26 | total_space: "{{ (netapp_info.ontap_info.volume_info[item].volume_space_attributes.size_total | int / 1024 / 1024 / 1024) | round }}" 27 | with_items: "{{ netapp_info.ontap_info.volume_info }}" 28 | - debug: 29 | msg: "{{ used_space }}:{{ free_space }}:{{ total_space}}" 30 | -------------------------------------------------------------------------------- /ontap/single_volume_used_space_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | gather_facts: false 5 | collections: 6 | - netapp.ontap 7 | tasks: 8 | - name: Gather facts 9 | na_ontap_info: 10 | state: info 11 | gather_subset: volume_info 12 | hostname: "{{ hostname }}" 13 | vserver: "{{ vserver }}" 14 | query: 15 | volume-attributes: 16 | volume-id-attributes: 17 | name: '"{{ volname }}"' 18 | username: "{{ username }}" 19 | password: "{{ password }}" 20 | https: "{{ https }}" 21 | validate_certs: "{{ validate_certs }}" 22 | register: netapp_info 23 | - debug: 24 | msg: "{{ (netapp_info.ontap_info.volume_info[item].volume_space_attributes.size_used | int / 1024 / 1024 / 1024) | round }}" 25 | with_items: "{{ netapp_info.ontap_info.volume_info }}" 26 | -------------------------------------------------------------------------------- /ontap/verify_snapshot_policy_exists_or_list_options.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | name: Setup ONTAP 4 | collections: 5 | - netapp.ontap 6 | vars: 7 | state: present 8 | tasks: 9 | - name: Gather facts 10 | na_ontap_info: 11 | gather_subset: snapshot_policy_info,cluster_identity_info 12 | hostname: "{{ hostname }}" 13 | username: "{{ username }}" 14 | password: "{{ password }}" 15 | https: "{{ https }}" 16 | validate_certs: "{{ validate_certs }}" 17 | register: netapp_info 18 | - set_fact: 19 | cluster_name: "{{ item }}" 20 | with_items: "{{ netapp_info.ontap_info.cluster_identity_info }}" 21 | no_log: True 22 | - set_fact: 23 | good_policy: true 24 | with_items: "{{ netapp_info.ontap_info.snapshot_policy_info }}" 25 | when: 26 | - netapp_info.ontap_info.snapshot_policy_info[item].vserver_name == vserver or netapp_info.ontap_info.snapshot_policy_info[item].vserver_name == cluster_name 27 | - netapp_info.ontap_info.snapshot_policy_info[item].policy == snap_policy 28 | no_log: True 29 | - debug: 30 | msg: "No policy with that name" 31 | when: good_policy is not defined 32 | - debug: 33 | msg: "{{ netapp_info.ontap_info.snapshot_policy_info[item].policy }}" 34 | with_items: "{{ netapp_info.ontap_info.snapshot_policy_info }}" 35 | when: 36 | - good_policy is not defined 37 | - netapp_info.ontap_info.snapshot_policy_info[item].vserver_name == vserver or netapp_info.ontap_info.snapshot_policy_info[item].vserver_name == cluster_name 38 | - meta: end_play 39 | when: 40 | - good_policy is not defined 41 | - debug: 42 | msg: "{{ snap_policy }} is a good policy" 43 | --------------------------------------------------------------------------------