-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook_napalm.yml
80 lines (68 loc) · 2.02 KB
/
playbook_napalm.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
---
# test playbook
- name: Prepare dirs
hosts: citest
gather_facts: no
connection: local
tasks:
- name: Remove old config
file: path={{ playbook_dir }}/compiled/{{ inventory_hostname }} state=absent
register: baseconfdir
tags: build
changed_when: False
- name: Create empty
file: >
path={{ playbook_dir }}/compiled/{{ inventory_hostname }} state=directory
tags: build
changed_when: False
- name: Remove old log directory
file: path={{ playbook_dir }}/logs/{{ inventory_hostname }} state=absent
register: baselogdir
tags: build
changed_when: False
- name: Create empty log dir
file: path={{ playbook_dir }}/logs/{{ inventory_hostname }} state=directory
tags: build
changed_when: False
- name: Static configs directory
file: path={{ playbook_dir }}/staticfiles state=directory
register: basestaticdir
tags: build
changed_when: False
- name: Generate configs for vyos
hosts: citest
gather_facts: no
connection: local
tags: build
roles:
- system
- bgp
- name: Assemble and Generate configuration
hosts: citest
connection: local
gather_facts: no
tags: compile
tasks:
- name: Assemble configuration
assemble: >
src={{ playbook_dir }}/compiled/{{ inventory_hostname }}
dest={{ playbook_dir }}/compiled/{{ inventory_hostname }}/running.conf
changed_when: False
- name: Provision configuration to devices
hosts: [cijun, civyos]
connection: local
gather_facts: no
tags: deploy
tasks:
- name: Install new configuration
napalm_install_config:
hostname: "{{ ansible_ssh_host }}"
username: "{{ ansible_ssh_user }}"
password: "{{ ansible_ssh_password | default('vagrant') }}"
dev_os: "{{ os }}"
optional_args: "{'port':{{ansible_ssh_port}}}"
config_file: "compiled/{{inventory_hostname}}/running.conf"
replace_config: true
commit_changes: false
get_diffs: true
diff_file: "logs/{{inventory_hostname}}/{{inventory_hostname}}.diff"