Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
21 changes: 14 additions & 7 deletions Infrastructure_as_Code/Ansible/Volume_Management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ 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\_snapshot.yaml
- delete\_snapshot.yaml
- create\_volume.yaml
- delete\_volume.yaml
- create\_volume\_and\_share.yaml
- delete\_volume\_and\_share.yaml
| Playbook Name | Description |
| clone_volume.yaml | Clones an existing volume.|
| create_cifs_share.yaml | Creates a new CIFS share on an existing volume.|
| create_cifs_unix_symlink_mapping.yaml | Creates a CIFS symlink mapping. |
| create_snapshot.yaml | Creates a snapshot of an existing volume.|
| create_volume.yaml | Creates a new volume.|
Comment thread
kcantrel marked this conversation as resolved.
| 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.|
Comment thread
kcantrel marked this conversation as resolved.
Outdated
| delete_cifs_share.yaml | Deletes an existing CIFS share.|
| delete_snapshot.yaml | Deletes an existing snapshot.|
| delete_volume.yaml | Deletes an existing volume.|
| delete_volume_and_share.yaml | Deletes an existing volume and its associated CIFS share.|
| set_volume_autosize.yaml | Sets the autosize policy on an existing volume.|
| set_volume_efficiency.yaml | Enables or disables ONTAP efficiencies on an existing volume.|

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Title: clone_volume.yaml

---
- name: Playbook to clones a volume in an FSx for ONTAP file system.
Comment thread
kcantrel marked this conversation as resolved.
Outdated
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:
- clone_volume_name
- volume_name
- vserver
- secret_name
- fsxn_hostname
#
# Give default values to optional variables if they are 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.
Comment thread
kcantrel marked this conversation as resolved.
Outdated
set_fact:
aws_profile: "default"
when: aws_profile 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: Set junction path to "/<clone_volume_name>" if not provided.
set_fact:
junction_path: "/{{ clone_volume_name }}"
when: junction_path is not defined

- name: Create the clone
netapp.ontap.na_ontap_volume_clone:
state: present
name: "{{ clone_volume_name }}"
parent_volume: "{{ volume_name }}"
parent_vserver: "{{ parent_vserver if parent_vserver is defined else omit }}"
parent_snapshot: "{{ parent_snapshot if parent_snapshot is defined else omit }}"
vserver: "{{ vserver }}"
junction_path: "{{ junction_path }}"
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,73 @@
# Title: create_a_cifs_share
Comment thread
kcantrel marked this conversation as resolved.
Outdated

---
- name: Playbook to create a CIFS share
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:
- share_path
- share_name
- vserver
- secret_name
- fsxn_hostname
#
# Give default values to optional variables if they are 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.
Comment thread
kcantrel marked this conversation as resolved.
Outdated
set_fact:
aws_profile: "default"
when: aws_profile 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 CIFS Share
netapp.ontap.na_ontap_cifs:
state: present
name: "{{ share_name }}"
path: "{{ share_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,78 @@
# Title: create_cifs_unix_symlink_mapping.yaml

---
- name: Playbook to create a CIFS unix symlink mapping.
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:
- unix_path
- share_name
- cifs_path
- cifs_server
- vserver
- secret_name
- fsxn_hostname
#
# Give default values to optional variables if they are 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.
Comment thread
kcantrel marked this conversation as resolved.
Outdated
set_fact:
aws_profile: "default"
when: aws_profile 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 CIFS unix symlink mapping.
netapp.ontap.na_ontap_cifs_unix_symlink_mapping:
state: present
vserver: "{{ vserver }}"
unix_path: "{{ unix_path }}"
share_name: "{{ share_name }}"
cifs_path: "{{ cifs_path }}"
cifs_server: "{{ cifs_server }}"
locality: "{{ locality if locality is defined else 'local'}}"
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
Expand Up @@ -25,21 +25,6 @@
- fsxn_hostname
#
# Give default values to optional variables if they are not defined
- name: Set security_style to unix if not provided.
set_fact:
security_style: "unix"
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
Expand All @@ -50,11 +35,6 @@
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: Ensure that aws_region has been provided if use_lambda is true.
fail:
msg: "aws_region must be defined when use_lambda is true."
Expand All @@ -76,6 +56,26 @@
password: "{{ lookup('amazon.aws.aws_secret', '{{ secret_name }}.password', nested=true) }}"
no_log: true

- name: Set security_style to unix if not provide.
Comment thread
kcantrel marked this conversation as resolved.
Outdated
set_fact:
security_style: "unix"
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 junction path to "/<volume_name>" if not provided.
set_fact:
junction_path: "/{{ volume_name }}"
when: junction_path is not defined

- name: Create the volume
netapp.ontap.na_ontap_volume:
state: present
Expand Down
Loading
Loading