Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Infrastructure_as_Code/Ansible/Volume_Management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ node to have network connectivity to the FSx for ONTAP file system. For more inf
Workload Factory Link, please refer to the [NetApp Workload Factory documentation](https://docs.netapp.com/us-en/workload-fsx-ontap/links-overview.html).

The list of playbooks included in this folder is as follows:
- create\_volume.yaml
- delete\_volume.yaml
- create\_snapshot.yaml
- delete\_snapshot.yaml
- create\_volume.yaml
- delete\_volume.yaml
- create\_volume\_and\_share.yaml
- delete\_volume\_and\_share.yaml

## Requirements
- Ansible 2.9 or later. Installation instructions can be found [here](https://docs.ansible.com/ansible/latest/installation_guide/index.html)
Expand All @@ -28,11 +30,11 @@ Each playbook requires various variables to be set in order to run.
| volume\_name| All | Yes | None | The name of the volume you want to act on.|
| lambda\_function\_name| All | No | None | The name of the Workload Factory Link Lambda function to use when issuing API calls to the FSx for ONTAP file system.|
| aws\_region | All | No | None | The AWS region where the Lambda function resides.|
| volume\_size| create\_volume | Yes | None | The size, in MiBs, of the volume to create.|
| security\_style | create\_volume | No | UNIX | The security style to use when creating the volume. Valid options are UNIX or NTFS.|
| aggr | create\_volume | No | aggr1 | The name of the aggregate to create the volume on.|
| volume\_type | create\_volume | No | RW | The type of volume to create. Valid options are RW and DP.|
| junction\_path | create\_volume | No | `/<volume_name>` | The junction path to use when creating the volume.|
| volume\_size| create\_volume\* | Yes | None | The size, in MiBs, of the volume to create.|
| security\_style | create\_volume\* | No | UNIX | The security style to use when creating the volume. Valid options are UNIX or NTFS.|
| aggr | create\_volume\* | No | aggr1 | The name of the aggregate to create the volume on.|
| volume\_type | create\_volume\* | No | RW | The type of volume to create. Valid options are RW and DP.|
| junction\_path | create\_volume\* | No | `/<volume_name>` | The junction path to use when creating the volume.|
| snapshot\_name | create\_snapshot | Yes | None | The name of the snapshot to create.|

A convenient way to set all the required variable is to put them into a file named `variables.yaml`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
- volume_size
- vserver
- secret_name
- fsxn_hostname
#
# Give default values to optional variables if they are not defined
- name: Set security_style to unix if not provide.
- name: Set security_style to unix if not provided.
set_fact:
security_style: "unix"
when: security_style is not defined
Expand All @@ -44,7 +45,7 @@
use_lambda: true
when: lambda_function_name is defined

- name: Set aws_provide to "default" if not provided.
- name: Set aws_profile to "default" if not provided.
set_fact:
aws_profile: "default"
when: aws_profile is not defined
Expand Down Expand Up @@ -83,6 +84,7 @@
vserver: "{{ vserver }}"
aggregate_name: "{{ aggr }}"
junction_path: "{{ junction_path }}"
volume_security_style: "{{ security_style }}"
use_lambda: "{{ use_lambda }}"
lambda_config:
aws_profile: "{{ aws_profile }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Title: create_volume_and_share.yaml

---
- name: Playbook to create a volume and a CIFS share that points to it on an FSx for ONTAP file system.
hosts: localhost
collections:
- netapp.ontap
- amazon.aws
gather_facts: false
vars_files:
- variables.yaml
vars:
use_lambda: false

tasks:
- name: Ensure required variables are set.
fail:
msg: "Required variable {{item}} has not been provided."
when: vars[item] is undefined
loop:
- volume_name
- volume_size
- vserver
- secret_name
- fsxn_hostname
#
# Give default values to optional variables if they are not defined
- name: Set security_style to ntfs if not provided.
set_fact:
security_style: "ntfs"
when: security_style is not defined

- name: Set aggr to 'aggr1' if not provided.
set_fact:
aggr: "aggr1"
when: aggr is not defined

- name: Set volume_type to "rw" if not provided.
set_fact:
volume_type: "rw"
when: volume_type is not defined

- name: Set use_lambda to true if lambda_function_name is provided.
set_fact:
use_lambda: true
when: lambda_function_name is defined

- name: Set aws_profile to "default" if not provided.
set_fact:
aws_profile: "default"
when: aws_profile is not defined

- name: Set junction_path to "/<volume_name>" if not provided.
set_fact:
junction_path: "/{{ volume_name }}"
when: junction_path is not defined

- name: Set share_name to "<volume_name>" if not provided.
set_fact:
share_name: "{{ volume_name }}"
when: share_name is not defined

- name: Ensure that aws_region has been provided if use_lambda is true.
fail:
msg: "aws_region must be defined when use_lambda is true."
when: use_lambda and aws_region is not defined

- name: Set aws_region to "" if not set at this point.
set_fact:
aws_region: ""
when: aws_region is not defined

- name: Set lambda_function_name to "" if not set at this point.
set_fact:
lambda_function_name: ""
when: lambda_function_name is not defined

- name: Get username and password from AWS secret.
set_fact:
username: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.username', nested=true) }}"
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
no_log: true

- name: Create the volume
netapp.ontap.na_ontap_volume:
state: present
name: "{{ volume_name }}"
size: "{{ volume_size }}"
vserver: "{{ vserver }}"
aggregate_name: "{{ aggr }}"
junction_path: "{{ junction_path }}"
volume_security_style: "{{ security_style }}"
use_lambda: "{{ use_lambda }}"
lambda_config:
aws_profile: "{{ aws_profile }}"
aws_region: "{{ aws_region }}"
function_name: "{{ lambda_function_name }}"
type: "{{ volume_type }}"
size_unit: "mb"
hostname: "{{ fsxn_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: false

- name: Create CIFS Share
netapp.ontap.na_ontap_cifs:
state: present
name: "{{ share_name }}"
path: "{{ junction_path }}"
vserver: "{{ vserver }}"
use_lambda: "{{ use_lambda }}"
lambda_config:
aws_profile: "{{ aws_profile }}"
aws_region: "{{ aws_region }}"
function_name: "{{ lambda_function_name }}"
hostname: "{{ fsxn_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Title: delete_volume_and_share.yaml

---
- name: Playbook to delete a volume and a CIFS share that points to it on an FSx for ONTAP file system.
hosts: localhost
collections:
- netapp.ontap
- amazon.aws
gather_facts: false
vars_files:
- variables.yaml
vars:
use_lambda: false

tasks:
- name: Ensure required variables are set.
fail:
msg: "Required variable {{item}} has not been provided."
when: vars[item] is undefined
loop:
- volume_name
- vserver
- secret_name
- fsxn_hostname
#
# Give default values to optional variables if they are not defined
- name: Set security_style to ntfs if not provide.
set_fact:
security_style: "ntfs"
when: security_style is not defined

- name: Set aggr to 'aggr1' if not provided.
set_fact:
aggr: "aggr1"
when: aggr is not defined

- name: Set volume_type to "rw" if not provided.
set_fact:
volume_type: "rw"
when: volume_type is not defined

- name: Set use_lambda to true if lambda_function_name is provided.
set_fact:
use_lambda: true
when: lambda_function_name is defined

- name: Set aws_provide to "default" if not provided.
set_fact:
aws_profile: "default"
when: aws_profile is not defined

- name: Set junction_path to "/<volume_name>" if not provided.
set_fact:
junction_path: "/{{ volume_name }}"
when: junction_path is not defined

- name: Set share_name to "<volume_name>" if not provided.
set_fact:
share_name: "{{ volume_name }}"
when: share_name is not defined

- name: Ensure that aws_region has been provided if use_lambda is true.
fail:
msg: "aws_region must be defined when use_lambda is true."
when: use_lambda and aws_region is not defined

- name: Set aws_region to "" if not set at this point.
set_fact:
aws_region: ""
when: aws_region is not defined

- name: Set lambda_function_name to "" if not set at this point.
set_fact:
lambda_function_name: ""
when: lambda_function_name is not defined

- name: Get username and password from AWS secret.
set_fact:
username: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.username', nested=true) }}"
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
no_log: true

- name: Delete CIFS Share
netapp.ontap.na_ontap_cifs:
state: absent
name: "{{ share_name }}"
path: "{{ junction_path }}"
vserver: "{{ vserver }}"
use_lambda: "{{ use_lambda }}"
lambda_config:
aws_profile: "{{ aws_profile }}"
aws_region: "{{ aws_region }}"
function_name: "{{ lambda_function_name }}"
hostname: "{{ fsxn_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: false

- name: Delete the volume
netapp.ontap.na_ontap_volume:
state: absent
name: "{{ volume_name }}"
vserver: "{{ vserver }}"
aggregate_name: "{{ aggr }}"
use_lambda: "{{ use_lambda }}"
lambda_config:
aws_profile: "{{ aws_profile }}"
aws_region: "{{ aws_region }}"
function_name: "{{ lambda_function_name }}"
hostname: "{{ fsxn_hostname }}"
username: "{{ username }}"
password: "{{ password }}"
validate_certs: false
11 changes: 6 additions & 5 deletions Infrastructure_as_Code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ This folder contains code samples and automation scripts for FSx for NetApp ONTA
* [SnapMirror report](Ansible/snapmirror_report)
* [Volume Management](Ansible/Volume_Management)
* [CloudFormation](CloudFormation)
* [NetApp-FSxN-Custom-Resources-Samples](CloudFormation/NetApp-FSxN-Custom-Resources-Samples)
* [Deploy-fsx-ontap](CloudFormation/deploy-fsx-ontap)
* [Export FSx for ONTAP Configuration to CloudFormation](CloudFormation/Export-FSxN-CloudFormation)
* [deploy-fsx-ontap](CloudFormation/deploy-fsx-ontap)
* [NetApp-FSxN-Custom-Resources-Samples](CloudFormation/NetApp-FSxN-Custom-Resources-Samples)
* [Terraform](Terraform)
* [Deployment of FSx ONTAP with VPN for File Share Access](Terraform/deploy-fsx-ontap-fileshare-access)
* [Deployment of SQL Server on EC2 with FSx ONTAP](Terraform/deploy-fsx-ontap-sqlserver)
* [FSx ONTAP deployment using Terraform](Terraform/deploy-fsx-ontap)
* [FSx ONTAP Replication](Terraform/fsxn-replicate)
* [Deployment of SQL Server on EC2 with FSx ONTAP](Terraform/deploy-fsx-ontap-sqlserver)
* [Deployment of FSx ONTAP with VPN for File Share Access](Terraform/deploy-fsx-ontap-fileshare-access)
* [Miscellaneous FSx ONTAP operations using Terraform](Terraform/Miscellaneous)

## Author Information

Expand All @@ -31,4 +32,4 @@ is distributed on an _"AS IS"_ basis, without WARRANTIES or conditions of any ki

See the License for the specific language governing permissions and limitations under the License.

© 2024 NetApp, Inc. All Rights Reserved.
© 2026 NetApp, Inc. All Rights Reserved.
22 changes: 22 additions & 0 deletions Infrastructure_as_Code/Terraform/Miscellaneous/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Miscellaneous Terraform Examples
This subfolder contains various examples of how you can use Terraform to manage an FSx for ONTAP file system.

| Example | Description |
| --- | --- |
| [Create CIFS Share](create_cifs_share.tf) | This sample shows how to create a volume and a CIFS share that points to it on an FSx for ONTAP file system. |

## Author Information

This repository is maintained by the contributors listed on [GitHub](https://github.com/NetApp/FSx-ONTAP-samples-scripts/graphs/contributors).

## License

Licensed under the Apache License, Version 2.0 (the "License").

You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an _"AS IS"_ basis, without WARRANTIES or conditions of any kind, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

© 2024 NetApp, Inc. All Rights Reserved.
Loading
Loading