|
| 1 | +# Ansible Volume Management samples |
| 2 | +This folder contains Ansible playbooks that can be used to manage volumes within a FSx for ONTAP file system. |
| 3 | + |
| 4 | +They have been configured to use the new `use_lambda` feature that allows it to leverage an Workload Factory Link |
| 5 | +to issue the API calls to the FSx for ONTAP file system which alleviates the requirement of the Ansible control |
| 6 | +node to have network connectivity to the FSx for ONTAP file system. For more information on how to set up a |
| 7 | +Workload Factory Link, please refer to the [NetApp Workload Factory documentation](https://docs.netapp.com/us-en/workload-fsx-ontap/links-overview.html). |
| 8 | + |
| 9 | +The list of playbooks included in this folder is as follows: |
| 10 | +- create\_volume.yaml |
| 11 | +- delete\_volume.yaml |
| 12 | +- create\_snapshot.yaml |
| 13 | +- delete\_snapshot.yaml |
| 14 | + |
| 15 | +## Requirements |
| 16 | +- Ansible 2.9 or later. Installation instructions can be found [here](https://docs.ansible.com/ansible/latest/installation_guide/index.html) |
| 17 | +- NetApp ONTAP Ansible collection. |
| 18 | +- AWS Ansible collection. |
| 19 | +- An AWS secret with the credentials necessary to run the required volume APIs against the FSx for ONTAP file system. The required format of the secret is described below. |
| 20 | + |
| 21 | +## Configuration |
| 22 | +Each playbook requires various variables to be set in order to run. |
| 23 | +| Variable | Used By Playbook | Required | Default | Description | |
| 24 | +|:-------- |:----------------:|:--------:|:-------:|:-----------| |
| 25 | +| fsxn\_hostname| All | Yes | None | The hostname, or IP address, of the FSxN where the volume resides.| |
| 26 | +| vserver | All | Yes | None | The name of the vserver where the volume resides.| |
| 27 | +| secret\_name | All | Yes | None | The name of the AWS secret that contains the credentials to authenticate with the FSx for ONTAP file system.| |
| 28 | +| volume\_name| All | Yes | None | The name of the volume you want to act on.| |
| 29 | +| 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.| |
| 30 | +| aws\_region | All | No | None | The AWS region where the Lambda function resides.| |
| 31 | +| volume\_size| create\_volume | Yes | None | The size, in MiBs, of the volume to create.| |
| 32 | +| security\_style | create\_volume | No | UNIX | The security style to use when creating the volume. Valid options are UNIX or NTFS.| |
| 33 | +| aggr | create\_volume | No | aggr1 | The name of the aggregate to create the volume on.| |
| 34 | +| volume\_type | create\_volume | No | RW | The type of volume to create. Valid options are RW and DP.| |
| 35 | +| junction\_path | create\_volume | No | `/<volume_name>` | The junction path to use when creating the volume.| |
| 36 | +| snapshot\_name | create\_snapshot | Yes | None | The name of the snapshot to create.| |
| 37 | + |
| 38 | +A convenient way to set all the required variable is to put them into a file named `variables.yaml`. |
| 39 | +All the playbooks will attempt to load this file and use any variables defined in it. Otherwise, |
| 40 | +you can set them by using the `--extra-vars` flag when running the playbook. An example `variables.yaml` |
| 41 | +file is included in this folder. |
| 42 | + |
| 43 | +## Authentication |
| 44 | +So that you don't have to hardcode secrets into the playbook, or variable files, all the playbooks |
| 45 | +will leverage an AWS Secrets Manager secret to retrieve the credentials for FSx for ONTAP file system. |
| 46 | + |
| 47 | +Each secret should have two `keys`: |
| 48 | +| Key | Value | |
| 49 | +| --- |:--- | |
| 50 | +| `username` | The username to use to authenticate with the FSx for ONTAP file system. | |
| 51 | +| `password` | The password to use to authenticate with the FSx for ONTAP file system. | |
| 52 | + |
| 53 | +Since this script leverages the AWS Ansible collection you will need to provide authentication credentials for it. |
| 54 | +You can read more about how to do that [here](https://docs.ansible.com/ansible/latest/collections/amazon/aws/docsite/aws_ec2_guide.html#authentication). |
| 55 | + |
| 56 | +## Example Run: |
| 57 | +Here is an example of running the `create_volume.yaml` playbook to create a new |
| 58 | +volume named `vol1` with a size of 1024 MiBs on the `fsx` vserver: |
| 59 | +```bash |
| 60 | +$ ansible-playbook create_volume.yaml --extra-vars "volume_name=vol1 volume_size=1024 vserver=fsx" |
| 61 | +[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' |
| 62 | + |
| 63 | +PLAY [Playbook to create a volumes on an FSx for ONTAP file system.] ******************************************************* |
| 64 | + |
| 65 | +TASK [Ensure required variables are set.] ********************************************************************************** |
| 66 | +skipping: [localhost] => (item=volume_name) |
| 67 | +skipping: [localhost] => (item=volume_size) |
| 68 | +skipping: [localhost] => (item=vserver) |
| 69 | +skipping: [localhost] => (item=secret_name) |
| 70 | +skipping: [localhost] |
| 71 | + |
| 72 | +TASK [Set security_style to unix if not provide.] ************************************************************************** |
| 73 | +ok: [localhost] |
| 74 | + |
| 75 | +TASK [Set aggr to 'aggr1' if not provided.] ******************************************************************************** |
| 76 | +ok: [localhost] |
| 77 | + |
| 78 | +TASK [Set volume_type to "rw" if not provided.] **************************************************************************** |
| 79 | +ok: [localhost] |
| 80 | + |
| 81 | +TASK [Set use_lambda to true if lambda_function_name is provided.] ********************************************************* |
| 82 | +ok: [localhost] |
| 83 | + |
| 84 | +TASK [Set aws_provide to "default" if not provided.] *********************************************************************** |
| 85 | +ok: [localhost] |
| 86 | + |
| 87 | +TASK [Set junction path to "/<volume_name>" if not provided.] ************************************************************** |
| 88 | +ok: [localhost] |
| 89 | + |
| 90 | +TASK [Ensure that aws_region has been provided if use_lambda is true.] ***************************************************** |
| 91 | +skipping: [localhost] |
| 92 | + |
| 93 | +TASK [Set aws_region to "" if not set at this point.] ********************************************************************** |
| 94 | +skipping: [localhost] |
| 95 | + |
| 96 | +TASK [Set lambda_function_name to "" if not set at this point.] ************************************************************ |
| 97 | +skipping: [localhost] |
| 98 | + |
| 99 | +TASK [Get username and password from AWS secret.] ************************************************************************** |
| 100 | +ok: [localhost] |
| 101 | + |
| 102 | +TASK [Create the volume] *************************************************************************************************** |
| 103 | +changed: [localhost] |
| 104 | + |
| 105 | +PLAY RECAP ***************************************************************************************************************** |
| 106 | +localhost : ok=8 changed=1 unreachable=0 failed=0 skipped=4 rescued=0 ignored=0 |
| 107 | +``` |
| 108 | +
|
| 109 | +The above example had a `variables.yaml` file with the following contents: |
| 110 | +```yaml |
| 111 | +fsxn_hostname: "10.0.0.13" |
| 112 | +lambda_function_name: "lambda-8nlmlCR" |
| 113 | +aws_region: "us-west-2" |
| 114 | +secret_name: "fsxn/default" |
| 115 | +``` |
| 116 | +## Author Information |
| 117 | +
|
| 118 | +This repository is maintained by the contributors listed on [GitHub](https://github.com/NetApp/FSx-ONTAP-samples-scripts/graphs/contributors). |
| 119 | +
|
| 120 | +## License |
| 121 | +
|
| 122 | +Licensed under the Apache License, Version 2.0 (the "License"). |
| 123 | +
|
| 124 | +You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0). |
| 125 | +
|
| 126 | +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. |
| 127 | +
|
| 128 | +See the License for the specific language governing permissions and limitations under the License. |
| 129 | +
|
| 130 | +© 2026 NetApp, Inc. All Rights Reserved. |
0 commit comments