-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcreate_snapshot.yaml
More file actions
72 lines (63 loc) · 2.22 KB
/
create_snapshot.yaml
File metadata and controls
72 lines (63 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Title: snapshot_volume.yaml
---
- name: Playbook to create a snapshot on a volume on an FSx for ONTAP file system.
hosts: localhost
collections:
- netapp.ontap
- amazon.aws
gather_facts: false
vars:
use_lambda: false
vars_files:
- variables.yaml
tasks:
- name: Ensure required variables are set.
fail:
msg: "Required variable '{{ item }}' has not been provided."
when: vars[item] is undefined
loop:
- volume_name
- snapshot_name
- vserver
- fsxn_hostname
- secret_name
- 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 its default value of '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 snapshot on volume
netapp.ontap.na_ontap_snapshot:
state: present
volume: "{{ volume_name }}"
vserver: "{{ vserver }}"
snapshot: "{{ snapshot_name }}"
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