Skip to content

Commit b6e711d

Browse files
authored
Merge pull request #269 from NetApp/update_readme
Reorganize the IaC samples
2 parents 03fe678 + e524649 commit b6e711d

File tree

118 files changed

+661
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+661
-120
lines changed

.github/workflows/terraform-docs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ name: "Documentation: terraform-docs"
77
on:
88
pull_request:
99
paths:
10-
- 'Terraform/**'
10+
- 'Infrastructure_as_Code/Terraform/**'
1111
push:
1212
paths:
13-
- 'Terraform/**'
13+
- 'Infrastructure_as_Code/Terraform/**'
1414
branches:
1515
- main
1616

@@ -20,8 +20,8 @@ jobs:
2020
strategy:
2121
matrix:
2222
directory:
23-
- 'Terraform/deploy-fsx-ontap/module'
24-
- 'Terraform/deploy-fsx-ontap/standalone-module'
23+
- 'Infrastructure_as_Code/Terraform/deploy-fsx-ontap/module'
24+
- 'Infrastructure_as_Code/Terraform/deploy-fsx-ontap/standalone-module'
2525
steps:
2626
- name: Checkout pull request
2727
uses: actions/checkout@v3.5.0

.github/workflows/terraform.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ name: "Code Quality: Terraform"
77
on:
88
pull_request:
99
paths:
10-
- 'Terraform/**'
10+
- 'Infrastructure_as_Code/Terraform/**'
1111
push:
1212
paths:
13-
- 'Terraform/**'
13+
- 'Infrastructure_as_Code/Terraform/**'
1414
branches:
1515
- main
1616

@@ -21,8 +21,8 @@ jobs:
2121
strategy:
2222
matrix:
2323
directory:
24-
- 'Terraform/deploy-fsx-ontap/module'
25-
- 'Terraform/deploy-fsx-ontap/standalone-module'
24+
- 'Infrastructure_as_Code/Terraform/deploy-fsx-ontap/module'
25+
- 'Infrastructure_as_Code/Terraform/deploy-fsx-ontap/standalone-module'
2626
defaults:
2727
run:
2828
working-directory: ${{ matrix.directory }}
@@ -47,4 +47,4 @@ jobs:
4747
# run: terraform fmt -diff -check -no-color -recursive
4848

4949
- name: Validate Terraform configuration
50-
run: terraform validate
50+
run: terraform validate

Ansible/snapmirror_report/generate_report.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

Ansible/snapmirror_report/process_region.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Click here for more information on [Ansible](https://www.ansible.com/).
66

77
| Tool | Description |
88
| --- | --- |
9-
| [Inventory Report](./fsx_inventory_report) | Creates a report of all the FSxN file systems within an AWS account.|
10-
| [SnapMirror Report](./snapmirror_report) | Creates a report of all SnapMirror relationships within all the FSxN file systems within an AWS account.|
9+
| [Inventory Report](fsx_inventory_report) | Creates a report of all the FSxN file systems within an AWS account.|
10+
| [SnapMirror Report](snapmirror_report) | Creates a report of all SnapMirror relationships within all the FSxN file systems within an AWS account.|
11+
| [Volume Management](Volume_Management) | A collection of playbooks to manage volumes on FSxN file systems.|
1112

1213
## Author Information
1314

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Title: snapshot_volume.yaml
2+
3+
---
4+
- name: Playbook to create a snapshot on a volume on an FSx for ONTAP file system.
5+
hosts: localhost
6+
collections:
7+
- netapp.ontap
8+
- amazon.aws
9+
gather_facts: false
10+
vars:
11+
use_lambda: false
12+
vars_files:
13+
- variables.yaml
14+
15+
tasks:
16+
- name: Ensure required variables are set.
17+
fail:
18+
msg: "Required variable '{{ item }}' has not been provided."
19+
when: vars[item] is undefined
20+
loop:
21+
- volume_name
22+
- snapshot_name
23+
- vserver
24+
- fsxn_hostname
25+
- secret_name
26+
27+
- name: Set use_lambda to true if lambda_function_name is provided.
28+
set_fact:
29+
use_lambda: true
30+
when: lambda_function_name is defined
31+
32+
- name: Set aws_profile to its default value of 'default' if not provided.
33+
set_fact:
34+
aws_profile: "default"
35+
when: aws_profile is not defined
36+
37+
- name: Ensure that aws_region has been provided if use_lambda is true.
38+
fail:
39+
msg: "aws_region must be defined when use_lambda is true."
40+
when: use_lambda and aws_region is not defined
41+
42+
- name: Set aws_region to "" if not set at this point.
43+
set_fact:
44+
aws_region: ""
45+
when: aws_region is not defined
46+
47+
- name: Set lambda_function_name to "" if not set at this point.
48+
set_fact:
49+
lambda_function_name: ""
50+
when: lambda_function_name is not defined
51+
52+
- name: Get username and password from AWS secret
53+
set_fact:
54+
username: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.username', nested=true) }}"
55+
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
56+
no_log: true
57+
58+
- name: Create snapshot on volume
59+
netapp.ontap.na_ontap_snapshot:
60+
state: present
61+
volume: "{{ volume_name }}"
62+
vserver: "{{ vserver }}"
63+
snapshot: "{{ snapshot_name }}"
64+
use_lambda: "{{ use_lambda }}"
65+
lambda_config:
66+
aws_profile: "{{ aws_profile }}"
67+
aws_region: "{{ aws_region }}"
68+
function_name: "{{ lambda_function_name }}"
69+
hostname: "{{ fsxn_hostname }}"
70+
username: "{{ username }}"
71+
password: "{{ password }}"
72+
validate_certs: false

0 commit comments

Comments
 (0)