Add opnsense integration and webhook for eda
This commit is contained in:
32
playbooks/opnsense.yml
Normal file
32
playbooks/opnsense.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
- name: Get info on the existing host entries
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
module_defaults:
|
||||
group/ansibleguy.opnsense.all:
|
||||
firewall: '{{ lookup("env","OPNSENSE_HOST") }}'
|
||||
api_key: '{{ lookup("env","OPNSENSE_API_KEY") }}'
|
||||
api_secret: '{{ lookup("env","OPNSENSE_API_SECRET") }}'
|
||||
api_port: 8443
|
||||
|
||||
ansibleguy.opnsense.unbound_host:
|
||||
match_fields: ['description']
|
||||
|
||||
ansibleguy.opnsense.list:
|
||||
target: 'unbound_host'
|
||||
|
||||
tasks:
|
||||
- name: Listing hosts # noqa args[module]
|
||||
ansibleguy.opnsense.list:
|
||||
target: 'unbound_host'
|
||||
register: existing_entries
|
||||
|
||||
- name: Printing entries
|
||||
ansible.builtin.debug:
|
||||
var: existing_entries.data
|
||||
|
||||
- name: Generate csv from template
|
||||
ansible.builtin.template:
|
||||
src: ../templates/hosts.j2
|
||||
mode: "0644"
|
||||
dest: "/data/output.csv"
|
||||
25
rulebooks/netbox_listener.yml
Normal file
25
rulebooks/netbox_listener.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: Listen for Netbox Events
|
||||
hosts: all
|
||||
sources:
|
||||
- name: Netbox Listener
|
||||
ansible.eda.webhook:
|
||||
port: 9102
|
||||
host: 0.0.0.0
|
||||
rules:
|
||||
- name: Run Template
|
||||
condition:
|
||||
all:
|
||||
- true
|
||||
actions:
|
||||
- print_event:
|
||||
pretty: true
|
||||
# - run_job_template:
|
||||
# name: Demo - Clean Log Directory
|
||||
# organization: OYS
|
||||
# job_args:
|
||||
# extra_vars:
|
||||
# alertmanager_annotations: "{{ event.alert.annotations }}"
|
||||
# alertmanager_generator_url: "{{ event.alert.generatorURL }}"
|
||||
# event_mountpoint: "{{ event.alert.labels.mountpoint }}"
|
||||
# alertmanager_instance: "{{ event.alert.labels.instance }}"
|
||||
4
templates/hosts.j2
Normal file
4
templates/hosts.j2
Normal file
@@ -0,0 +1,4 @@
|
||||
hostname, domain, description, enabled, mx, mxprio, prio, record_type, server, value, uuid
|
||||
{% for i in existing_entries.data %}
|
||||
{{ i.hostname }},{{ i.domain }},{{ i.description }},{{ i.enabled }},{{ i.mx }},{{ i.mxprio }},{{ i.prio }},{{ i.record_type }},{{ i.server }},{{ i.value }},{{ i.uuid }}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user