-
Notifications
You must be signed in to change notification settings - Fork 7
Added CIFS Share Ansible and Terraform examples. #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kcantrel
wants to merge
6
commits into
main
Choose a base branch
from
add_cifs_share_create_examples
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+419
−27
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c0a332a
Added CIFS Share examples.
kcantrel 0a67e67
terraform-docs: automated action
github-actions[bot] 662f119
Added CIFS Share examples.
kcantrel c8f9d4c
terraform-docs: automated action
github-actions[bot] a843ae6
Added CIFS Share examples.
kcantrel dabc788
Added CIFS Share examples.
kcantrel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
Infrastructure_as_Code/Ansible/Volume_Management/create_volume_and_share.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
kcantrel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - 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 | ||
113 changes: 113 additions & 0 deletions
113
Infrastructure_as_Code/Ansible/Volume_Management/delete_volume_and_share.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
kcantrel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.