-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpb.cso.delete.site.yml
55 lines (51 loc) · 2.21 KB
/
pb.cso.delete.site.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
---
### ---------------------------------------------------------------------------
### CREATE AN SDWAN SITE IN CSO
### ---------------------------------------------------------------------------
- hosts: localhost
connection: local
gather_facts: False
become: False
vars_files:
- "cso/variables/cso_auth.yml"
tasks:
### ---------------------------------------------------------------------------
### VALIDATE THAT ANSIBLE CONTROL MACHINE IS RUNNING A RECENT ANSIBLE VERSION
### ---------------------------------------------------------------------------
- name: "Check ansible version >=2.7.8"
assert:
msg: "Ansible must be v2.7.8 or higher"
that:
- ansible_version.string is version("2.7.8", ">=")
### ---------------------------------------------------------------------------
### BUILD AUTHENTICATION PAYLOAD FOR CSO
### ---------------------------------------------------------------------------
- name: "Create a JSON payload with username and password for our auth task"
template:
src: cso/templates/cso_auth.j2
dest: cso/payload/auth.json
mode: 0640
### ---------------------------------------------------------------------------
### RECEIVE AUTH TOKEN FROM CSO
### ---------------------------------------------------------------------------
- name: "Login to CSO and retrieve AUTH token"
uri:
url: "{{ cso.baseurl }}/v3/auth/tokens"
method: POST
body: "{{ lookup('file','cso/payload/auth.json') }}"
return_content: yes
status_code: 201
body_format: json
register: login
- name: "Setting the AUTH token based on the headers received from the previous step"
set_fact:
token: "{{ login.x_subject_token }}"
### ---------------------------------------------------------------------------
### CREATE THE SITE
### ---------------------------------------------------------------------------
- name: Create a SD-WAN site
cso_site:
site_name: "redtail"
type: sdwan
state: absent
token: "{{ token }}"