forked from llima3000/ansibledevops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigGSLB.yml
157 lines (149 loc) · 4.96 KB
/
configGSLB.yml
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
#ansible-playbook configGSLB.yml -e "controller=10.10.29.250"
- hosts: localhost
connection: local
vars:
controller: 10.91.55.10
username: admin
password: Avi123$%
api_version: 17.2.7
sitename: site01
domain: gslb.teste.com
gslb_controller: 10.91.55.10
gslb_fullname: "Gslb Service User"
gslb_username: gslb
gslb_password: Gslb2018
vmware_cloud_name: "vmwarecloud"
vs_name: VS-GSLB
port_num: 53
vs_ip: 10.91.30.11
app_profile_name: System-DNS
vrf_name: VRF-GSLB
tenant_name: admin
vmwarecloudname: vmwarecloud
service_engine_name: SEGGSLB
vip_network_address: 10.91.30.0
vip_netmask_bits: 24
network_name: PG-1030
roles:
- role: avinetworks.avisdk
tasks:
# Configure GSLB VS and site
- name: "Check if user {{ gslb_username }} exists on Avi"
avi_api_session:
username: "{{ username }}"
password: "{{ password }}"
controller: "{{ controller }}"
api_version: "{{ api_version }}"
http_method: get
path: user
params:
name: "{{ gslb_username }}"
register: user_exists
- name: Existing User
debug: msg="{{ user_exists}}"
- name: "If user {{ gslb_username }} doesn't exist create it on Avi"
avi_api_session:
username: "{{ username }}"
password: "{{ password }}"
controller: "{{ controller }}"
api_version: "{{ api_version }}"
http_method: post
path: user
data:
name: "{{ gslb_username}}"
username: "{{ gslb_username }}"
password: "{{ gslb_password}}"
access:
- role_ref: "/api/role?name=System-Admin"
tenant_ref: "/api/tenant?name={{ tenant_name }}"
user_profile_ref: "/api/useraccountprofile?name=No-Lockout-User-Account-Profile"
when: user_exists.obj.count == 0
- name: Create GSLB VS "{{ vs_name }}"
avi_virtualservice:
controller: "{{ controller }}"
username: "{{ username }}"
password: "{{ password }}"
api_version: "{{ api_version }}"
name: "{{ vs_name }}"
services:
- port: "{{ port_num }}"
application_profile_ref: '/api/applicationprofile?name={{ app_profile_name }}'
vrf_context_ref: "/api/vrfcontext/?name={{ vrf_name }}"
tenant_ref: "/api/tenant/?name={{ tenant_name }}"
cloud_ref: "/api/cloud?name={{ vmwarecloudname }}"
se_group_ref: "/api/serviceenginegroup/?name={{ service_engine_name }}"
vip:
-
vip_id: 0
subnet:
mask: "{{ vip_netmask_bits }}"
ip_addr:
type: V4
addr: "{{ vip_network_address }}"
ip_address:
type: V4
addr: "{{ vs_ip }}"
network_ref: '/api/network/?name={{ network_name }}'
discovered_networks:
-
subnet:
-
mask: "{{ vip_netmask_bits }}"
ip_addr:
type: V4
addr: "{{ vip_network_address }} "
network_ref: '/api/network/?name={{ network_name }}'
- name: Get VS info "{{ vs_name }}"
avi_api_session:
username: "{{ username }}"
password: "{{ password }}"
controller: "{{ controller }}"
api_version: "{{ api_version }}"
http_method: get
path: virtualservice
params:
name: "{{ vs_name }}"
register: vs_info
- name: Get main Cluster Information using avi_api_session
avi_api_session:
username: "{{ username }}"
password: "{{ password }}"
controller: "{{ controller }}"
api_version: "{{ api_version }}"
http_method: get
path: cluster
register: cluster_info
- name: Create GSLB
avi_gslb:
username: "{{ username }}"
password: "{{ password }}"
controller: "{{ controller }}"
api_version: "{{ api_version }}"
sites:
- enabled: true
port: 443
member_type: GSLB_ACTIVE_MEMBER
cluster_uuid: "{{ cluster_info['obj'].uuid }}"
ip_addresses:
- type: V4
addr: "{{ gslb_controller }}"
dns_vses:
-
dns_vs_uuid: "{{ vs_info['obj']['results'][0]['uuid'] }}"
domain_names: []
name: "{{ sitename }}"
username: "{{ gslb_username }}"
password: "{{ gslb_password }}"
send_interval: 30
name: "{{ sitename }}"
dns_configs:
- domain_name: "{{ domain }}"
leader_cluster_uuid: "{{ cluster_info['obj'].uuid }}"
third_party_sites:
-
enabled: true
name: "{{ sitename }}_outside"
hm_proxies:
-
site_uuid: "{{ cluster_info['obj'].uuid }}"