-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
100 lines (85 loc) · 2.4 KB
/
playbook.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
---
# 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: device config
hosts: civyos
gather_facts: no
tags: deploy
tasks:
- name: Push vyos config
template: >
src=compiled/{{ inventory_hostname }}/running.conf
dest=/var/tmp/running.conf
register: configpush
- name: Push config
template: >
src=templates/vyos_load_config.j2
dest=/var/tmp/vyos_load_config.sh mode=0755
- name: Apply configuration
command: /var/tmp/vyos_load_config.sh
when: not inventory_hostname == "localhost" and configpush.changed
- name: Push Juniper config
hosts: cijun
roles:
- Juniper.junos
connection: local
gather_facts: no
tags: deploy
tasks:
- name: PUSH CONFIG
junos_install_config: >
host={{ansible_ssh_host}}
port={{ansible_ssh_port}}
user={{ ansible_ssh_user }}
passwd={{ ansible_ssh_password }}
file=compiled/{{inventory_hostname}}/running.conf
overwrite=true
logfile=logs/{{inventory_hostname}}/{{inventory_hostname}}.log
diffs_file=logs/{{inventory_hostname}}/{{inventory_hostname}}.diff