Skip to content

Commit 1b4b9a5

Browse files
committed
Added new samples
1 parent 8d43e7d commit 1b4b9a5

9 files changed

Lines changed: 622 additions & 38 deletions

Infrastructure_as_Code/Ansible/Volume_Management/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@ node to have network connectivity to the FSx for ONTAP file system. For more inf
77
Workload Factory Link, please refer to the [NetApp Workload Factory documentation](https://docs.netapp.com/us-en/workload-fsx-ontap/links-overview.html).
88

99
The list of playbooks included in this folder is as follows:
10-
- create\_snapshot.yaml
11-
- delete\_snapshot.yaml
12-
- create\_volume.yaml
13-
- delete\_volume.yaml
14-
- create\_volume\_and\_share.yaml
15-
- delete\_volume\_and\_share.yaml
10+
| Playbook Name | Description |
11+
| clone_volume.yaml | Clones an existing volume.|
12+
| create_cifs_share.yaml | Creates a new CIFS share on an existing volume.|
13+
| create_cifs_unix_symlink_mapping.yaml | Creates a CIFS symlink mapping. |
14+
| create_snapshot.yaml | Creates a snapshot of an existing volume.|
15+
| create_volume.yaml | Creates a new volume.|
16+
| create_volume_and_share.yaml | Creates a new volume with a CIFS share that points to it. It also sets autosize to grow and enables ONTAP efficiencies.|
17+
| delete_cifs_share.yaml | Deletes an existing CIFS share.|
18+
| delete_snapshot.yaml | Deletes an existing snapshot.|
19+
| delete_volume.yaml | Deletes an existing volume.|
20+
| delete_volume_and_share.yaml | Deletes an existing volume and its associated CIFS share.|
21+
| set_volume_autosize.yaml | Sets the autosize policy on an existing volume.|
22+
| set_volume_efficiency.yaml | Enables or disables ONTAP efficiencies on an existing volume.|
1623

1724
## Requirements
1825
- Ansible 2.9 or later. Installation instructions can be found [here](https://docs.ansible.com/ansible/latest/installation_guide/index.html)
19-
- NetApp ONTAP Ansible collection.
26+
- NetApp ONTAP Ansible collection. Version 2.17.14 or later.
2027
- AWS Ansible collection.
2128
- 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.
2229

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Title: clone_volume.yaml
2+
3+
---
4+
- name: Playbook to clones a volume in an FSx for ONTAP file system.
5+
hosts: localhost
6+
collections:
7+
- netapp.ontap
8+
- amazon.aws
9+
gather_facts: false
10+
vars_files:
11+
- variables.yaml
12+
vars:
13+
use_lambda: false
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+
- clone_volume_name
22+
- volume_name
23+
- vserver
24+
- secret_name
25+
- fsxn_hostname
26+
#
27+
# Give default values to optional variables if they are not defined
28+
- name: Set use_lambda to true if lambda_function_name is provided.
29+
set_fact:
30+
use_lambda: true
31+
when: lambda_function_name is defined
32+
33+
- name: Set aws_provide to "default" if not provided.
34+
set_fact:
35+
aws_profile: "default"
36+
when: aws_profile is not defined
37+
38+
- name: Ensure that aws_region has been provided if use_lambda is true.
39+
fail:
40+
msg: "aws_region must be defined when use_lambda is true."
41+
when: use_lambda and aws_region is not defined
42+
43+
- name: Set aws_region to "" if not set at this point.
44+
set_fact:
45+
aws_region: ""
46+
when: aws_region is not defined
47+
48+
- name: Set lambda_function_name to "" if not set at this point.
49+
set_fact:
50+
lambda_function_name: ""
51+
when: lambda_function_name is not defined
52+
53+
- name: Get username and password from AWS secret.
54+
set_fact:
55+
username: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.username', nested=true) }}"
56+
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
57+
no_log: true
58+
59+
- name: Set junction path to "/<clone_volume_name>" if not provided.
60+
set_fact:
61+
junction_path: "/{{ clone_volume_name }}"
62+
when: junction_path is not defined
63+
64+
- name: Create the clone
65+
netapp.ontap.na_ontap_volume_clone:
66+
state: present
67+
name: "{{ clone_volume_name }}"
68+
parent_volume: "{{ volume_name }}"
69+
parent_vserver: "{{ parent_vserver if parent_vserver is defined else omit }}"
70+
parent_snapshot: "{{ parent_snapshot if parent_snapshot is defined else omit }}"
71+
vserver: "{{ vserver }}"
72+
junction_path: "{{ junction_path }}"
73+
use_lambda: "{{ use_lambda }}"
74+
lambda_config:
75+
aws_profile: "{{ aws_profile }}"
76+
aws_region: "{{ aws_region }}"
77+
function_name: "{{ lambda_function_name }}"
78+
hostname: "{{ fsxn_hostname }}"
79+
username: "{{ username }}"
80+
password: "{{ password }}"
81+
validate_certs: false
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Title: create_a_cifs_share
2+
3+
---
4+
- name: Playbook to create a CIFS share
5+
hosts: localhost
6+
collections:
7+
- netapp.ontap
8+
- amazon.aws
9+
gather_facts: false
10+
vars_files:
11+
- variables.yaml
12+
vars:
13+
use_lambda: false
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+
- share_path
22+
- share_name
23+
- vserver
24+
- secret_name
25+
- fsxn_hostname
26+
#
27+
# Give default values to optional variables if they are not defined
28+
- name: Set use_lambda to true if lambda_function_name is provided.
29+
set_fact:
30+
use_lambda: true
31+
when: lambda_function_name is defined
32+
33+
- name: Set aws_provide to "default" if not provided.
34+
set_fact:
35+
aws_profile: "default"
36+
when: aws_profile is not defined
37+
38+
- name: Ensure that aws_region has been provided if use_lambda is true.
39+
fail:
40+
msg: "aws_region must be defined when use_lambda is true."
41+
when: use_lambda and aws_region is not defined
42+
43+
- name: Set aws_region to "" if not set at this point.
44+
set_fact:
45+
aws_region: ""
46+
when: aws_region is not defined
47+
48+
- name: Set lambda_function_name to "" if not set at this point.
49+
set_fact:
50+
lambda_function_name: ""
51+
when: lambda_function_name is not defined
52+
53+
- name: Get username and password from AWS secret.
54+
set_fact:
55+
username: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.username', nested=true) }}"
56+
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
57+
no_log: true
58+
59+
- name: Create CIFS Share
60+
netapp.ontap.na_ontap_cifs:
61+
state: present
62+
name: "{{ share_name }}"
63+
path: "{{ share_path }}"
64+
vserver: "{{ vserver }}"
65+
use_lambda: "{{ use_lambda }}"
66+
lambda_config:
67+
aws_profile: "{{ aws_profile }}"
68+
aws_region: "{{ aws_region }}"
69+
function_name: "{{ lambda_function_name }}"
70+
hostname: "{{ fsxn_hostname }}"
71+
username: "{{ username }}"
72+
password: "{{ password }}"
73+
validate_certs: false
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Title: create_cifs_unix_symlink_mapping.yaml
2+
3+
---
4+
- name: Playbook to create a CIFS unix symlink mapping.
5+
hosts: localhost
6+
collections:
7+
- netapp.ontap
8+
- amazon.aws
9+
gather_facts: false
10+
vars_files:
11+
- variables.yaml
12+
vars:
13+
use_lambda: false
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+
- unix_path
22+
- share_name
23+
- cifs_path
24+
- cifs_server
25+
- vserver
26+
- secret_name
27+
- fsxn_hostname
28+
#
29+
# Give default values to optional variables if they are not defined
30+
- name: Set use_lambda to true if lambda_function_name is provided.
31+
set_fact:
32+
use_lambda: true
33+
when: lambda_function_name is defined
34+
35+
- name: Set aws_provide to "default" if not provided.
36+
set_fact:
37+
aws_profile: "default"
38+
when: aws_profile is not defined
39+
40+
- name: Ensure that aws_region has been provided if use_lambda is true.
41+
fail:
42+
msg: "aws_region must be defined when use_lambda is true."
43+
when: use_lambda and aws_region is not defined
44+
45+
- name: Set aws_region to "" if not set at this point.
46+
set_fact:
47+
aws_region: ""
48+
when: aws_region is not defined
49+
50+
- name: Set lambda_function_name to "" if not set at this point.
51+
set_fact:
52+
lambda_function_name: ""
53+
when: lambda_function_name is not defined
54+
55+
- name: Get username and password from AWS secret.
56+
set_fact:
57+
username: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.username', nested=true) }}"
58+
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
59+
no_log: true
60+
61+
- name: Create the CIFS unix symlink mapping.
62+
netapp.ontap.na_ontap_cifs_unix_symlink_mapping:
63+
state: present
64+
vserver: "{{ vserver }}"
65+
unix_path: "{{ unix_path }}"
66+
share_name: "{{ share_name }}"
67+
cifs_path: "{{ cifs_path }}"
68+
cifs_server: "{{ cifs_server }}"
69+
locality: "{{ locality if locality is defined else 'local'}}"
70+
use_lambda: "{{ use_lambda }}"
71+
lambda_config:
72+
aws_profile: "{{ aws_profile }}"
73+
aws_region: "{{ aws_region }}"
74+
function_name: "{{ lambda_function_name }}"
75+
hostname: "{{ fsxn_hostname }}"
76+
username: "{{ username }}"
77+
password: "{{ password }}"
78+
validate_certs: false

0 commit comments

Comments
 (0)