-
Notifications
You must be signed in to change notification settings - Fork 7
Add more ansible examples #279
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
5
commits into
main
Choose a base branch
from
add_more_ansible_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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
81 changes: 81 additions & 0 deletions
81
Infrastructure_as_Code/Ansible/Volume_Management/clone_volume.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,81 @@ | ||
| # Title: clone_volume.yaml | ||
|
|
||
| --- | ||
| - name: Playbook to clone a volume in 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: | ||
| - 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_profile to "default" if not provided. | ||
| 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 |
73 changes: 73 additions & 0 deletions
73
Infrastructure_as_Code/Ansible/Volume_Management/create_cifs_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,73 @@ | ||
| # Title: create_cifs_share.yaml | ||
|
|
||
| --- | ||
| - 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_profile to "default" if not provided. | ||
| 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 |
78 changes: 78 additions & 0 deletions
78
Infrastructure_as_Code/Ansible/Volume_Management/create_cifs_unix_symlink_mapping.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,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_profile to "default" if not provided. | ||
| 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 |
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
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.