This repository has been archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
pb_configure_healthbot.yml
74 lines (60 loc) · 2.21 KB
/
pb_configure_healthbot.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
---
- name: create directories on your laptop
hosts: healthbot_server
gather_facts: no
tasks:
- name: create directories on your laptop
local_action:
module: file
path: "{{playbook_dir}}/{{item}}"
state: directory
with_items:
- ansible_output
- name: render healthbot configuration for devices, and update healthbot candidate configuration
hosts: junos_devices
gather_facts: no
tasks:
- name: render healthbot configuration for devices
local_action:
module: template
src: "{{playbook_dir}}/templates/devices.j2"
dest: "{{playbook_dir}}/ansible_output/device_{{ name }}"
- name: make rest calls to healthbot to add devices
local_action:
module: uri
url: "https://{{ hostvars['healthbot_server']['ansible_host'] }}:8080/api/v1/device/{{name}}/"
method: POST
user: "{{ hostvars['healthbot_server']['authuser'] }}"
password: "{{ hostvars['healthbot_server']['authpwd'] }}"
HEADER_Content-Type: "application/json"
HEADER_Accept: "application/json"
force_basic_auth: yes
validate_certs: no
body: "{{ lookup('file','{{playbook_dir}}/ansible_output/device_{{name}}') }}"
body_format: json
- name: commit candidate configuration and verify running configuration
hosts: healthbot_server
gather_facts: no
tasks:
- name: make rest call to healthbot to commit configuration
local_action:
module: uri
url: "https://{{ansible_host}}:8080/api/v1/configuration"
method: POST
user: "{{ authuser }}"
password: "{{ authpwd }}"
HEADER_Accept: "application/json"
force_basic_auth: yes
validate_certs: no
- name: make rest call to healthbot to get devices name
local_action:
module: uri
url: "https://{{ansible_host}}:8080/api/v1/devices/"
method: GET
user: "{{ authuser }}"
password: "{{ authpwd }}"
HEADER_Content-Type: "application/json"
HEADER_Accept: "application/json"
force_basic_auth: yes
validate_certs: no
dest: "{{playbook_dir}}/ansible_output/healthbot_running_config_for_devices.json"