-
Notifications
You must be signed in to change notification settings - Fork 0
/
01-playbook_dev_deploy.yml
109 lines (99 loc) · 3.08 KB
/
01-playbook_dev_deploy.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
---
- name: Ensure Configs directory is Created
connection: local
hosts: localhost
gather_facts: False
tasks:
- file:
path: "{{ playbook_dir }}/configs/"
state: directory
- name: Building DEV Network
connection: local
hosts: all
gather_facts: False
vars:
cml_file: "configs/cml_dev-network.yaml"
tasks:
- name: Generating NXOS Configuration Files
template:
src="{{ playbook_dir }}/templates/nxos/nxos_main.j2"
dest="{{ playbook_dir }}/configs/{{ inventory_hostname }}.cfg"
when: ansible_network_os == 'nxos'
- name: Generating IOS Configuration Files
template:
src="{{ playbook_dir }}/templates/ios/ios_main.j2"
dest="{{ playbook_dir }}/configs/{{ inventory_hostname }}.cfg"
when: ansible_network_os == 'ios'
- name: Generating CML Topology File
template:
src="{{ playbook_dir }}/templates/cml/cml_base_lab.j2"
dest="{{ cml_file }}"
delegate_to: localhost
- name: Preparing CML DEV Network
hosts: localhost
gather_facts: False
vars:
# cml_host: "10.10.20.161"
# cml_user: "developer"
# cml_pass: "C1sco12345"
cml_lab: "dev-network"
cml_file: "configs/cml_dev-network.yaml"
tasks:
- name: Importing Dev Network Topology file to CML
virl_lab:
# host: "{{ cml_host }}"
# user: "{{ cml_user }}"
# password: "{{ cml_pass }}"
host: "{{ hostvars['cml_host'].ansible_host }}"
user: "{{ hostvars['cml_host'].ansible_user }}"
password: "{{ hostvars['cml_host'].ansible_password }}"
lab: "{{ cml_lab }}"
state: present
file: "{{ cml_file }}"
register: results
no_log: False
- name: Bringing Up CML DEV Network
connection: local
hosts: all
gather_facts: False
vars:
cml_host: "10.10.20.161"
cml_user: "developer"
cml_pass: "C1sco12345"
cml_lab: "dev-network"
tasks:
- name: Starting DEV Network Devices
virl_node:
name: "{{ inventory_hostname }}"
# host: "{{ cml_host }}"
# user: "{{ cml_user }}"
# password: "{{ cml_pass }}"
host: "{{ hostvars['cml_host'].ansible_host }}"
user: "{{ hostvars['cml_host'].ansible_user }}"
password: "{{ hostvars['cml_host'].ansible_password }}"
lab: "{{ cml_lab }}"
state: started
image_definition: ""
config: ""
register: result_start
delegate_to: localhost
no_log: True
- name: Waiting DEV Network Devices to Start
wait_for:
timeout: 5
- name: Waiting until Devices are ready
virl_lab_facts:
# host: "{{ cml_host }}"
# user: "{{ cml_user }}"
# password: "{{ cml_pass }}"
host: "{{ hostvars['cml_host'].ansible_host }}"
user: "{{ hostvars['cml_host'].ansible_user }}"
password: "{{ hostvars['cml_host'].ansible_password }}"
lab: "{{ cml_lab }}"
register: result
until: result.virl_facts.nodes[item].state == "BOOTED"
loop: "{{ ansible_play_hosts }}"
retries: 60
delay: 10
delegate_to: localhost
no_log: True