forked from CiscoDevNet/ps-crn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.yml
66 lines (59 loc) · 1.75 KB
/
build.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
- name: Add host to topology
hosts: localhost
connection: local
gather_facts: no
tags:
- cull
vars:
include_groups: 'all'
exclude_groups: 'ha'
include_hosts: []
tasks:
- set_fact:
include_hosts: "{{ include_hosts|default([]) + groups[item] }}"
loop: "{{ include_groups.split(',') }}"
- set_fact:
exclude_hosts: "{{ exclude_hosts|default([]) + groups[item] }}"
loop: "{{ exclude_groups.split(',') | difference(include_groups.split(',')) }}"
- add_host:
name: "{{ item }}"
groups: virl_nodes
when: hostvars[item].virl is defined
loop: "{{ include_hosts | difference(exclude_hosts) }}"
- name: Generating day0 config
hosts: virl_nodes
gather_facts: no
tags:
- config
tasks:
- set_fact:
day0_config: "{{ lookup('template', virl.config_template) }}"
when: virl.config_template is defined
- hosts: localhost
connection: local
gather_facts: no
vars:
topo_file: topo.virl
topo_name: "{{ topo_file.split('.')[0] }}"
topo_id: "{{ lookup('password', '/dev/null length=4 chars=ascii_letters') }}"
session: "{{ lookup('env', 'VIRL_SESSION') | default('') }}"
tasks:
- block:
- name: Check for session id file
stat:
path: "{{ virl_sim_file }}"
register: stat_result
- name: Get the existing session ID
set_fact:
session: "{{lookup('file', virl_sim_file) }}"
when: stat_result.stat.exists
when: session == ""
- name: Skip if we have a session passed in
include_role:
name: ansible-virl
tasks_from: build
- name: Check on simulation {{ session }}
include_role:
name: ansible-virl
tasks_from: check
when: session != ""