-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathclean.yml
More file actions
65 lines (58 loc) · 1.73 KB
/
clean.yml
File metadata and controls
65 lines (58 loc) · 1.73 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
- name: Configure licensing
hosts: firewall:&virl_hosts
gather_facts: no
connection: network_cli
tasks:
- name: Deregister from smart account
asa_command:
commands:
- "license smart deregister"
ignore_errors: yes
- hosts: localhost
connection: local
gather_facts: no
vars:
virl_session: "{{ lookup('env', 'VIRL_SESSION') | default('') }}"
tasks:
- set_fact:
sim_id: "{{ virl_session if virl_session != '' else lookup('file', virl_sim_file, errors='ignore') | default('') }}"
# - name: Find previsouly created certs
# find:
# paths: "{{ viptela_cert_dir }}"
# patterns: '*.pem,*.key,*.csr,*.crt'
# register: find_results
#
# - name: Delete previsouly created certs
# file:
# path: "{{ item['path'] }}"
# state: absent
# with_items: "{{ find_results['files'] }}"
- name: Delete cert dir
file:
path: "{{ viptela_cert_dir }}"
state: absent
- name: Remove host from known_hosts
known_hosts:
name: "{{ hostvars[item].ansible_host }}"
state: absent
when: hostvars[item].ansible_host is defined
loop: "{{ groups.all }}"
- block:
- debug:
msg: "Deleting simulation: {{ sim_id }}"
- name: Destroy the simulation
uri:
url: "http://{{ virl_host }}:19399/simengine/rest/stop/{{ sim_id }}"
user: "{{ virl_username }}"
password: "{{ virl_password }}"
method: GET
return_content: yes
no_log: false # Don't show output as your password will be on the URI string
register: uri_results
ignore_errors: yes
delegate_to: localhost
when: sim_id != ""
- name: Delete Simulation ID File
file:
path: "{{ virl_sim_file }}"
state: absent