-
Notifications
You must be signed in to change notification settings - Fork 8
/
playbook_napalm_commit.yml
95 lines (83 loc) · 2.42 KB
/
playbook_napalm_commit.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
---
# test playbook
- name: Prepare dirs
hosts: svpnprod
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: Check version of VyOS
hosts: svpnprod
gather_facts: no
tags: build
tasks:
- name: Check if FRR directory exists.
stat:
path: /etc/frr/
register: vyos_frr_daemon
- name: Generate configs for vyos
hosts: svpnprod
gather_facts: no
connection: local
tags: build
roles:
- system
- protocols
- policy
- ipsec
- nat
- firewall
- interfaces
- bgp
- name: Assemble and Generate configuration
hosts: svpnprod
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: [svpnprod]
connection: local
gather_facts: no
tags: deploy
tasks:
- name: Install new configuration
napalm_install_config:
hostname: "{{ ansible_ssh_host | default('vyos') }}"
username: "{{ ansible_ssh_user | default('vyos') }}"
password: "{{ ansible_ssh_password | default('vyos') }}"
dev_os: "{{ os }}"
optional_args: "{'port': {{ansible_ssh_port | default('22')}} }"
config_file: "compiled/{{inventory_hostname}}/running.conf"
replace_config: true
commit_changes: true
get_diffs: true
diff_file: "logs/{{inventory_hostname}}/{{inventory_hostname}}.diff"