-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcreate_volume.yaml
More file actions
96 lines (84 loc) · 2.92 KB
/
create_volume.yaml
File metadata and controls
96 lines (84 loc) · 2.92 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Title: create_volume.yaml
---
- name: Playbook to create a volumes 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
#
# Give default values to optional variables if they are not defined
- name: Set security_style to unix if not provide.
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
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: 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 }}"
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