forked from LO3Energy/ansible-graylog-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graylog_streams_create.yaml
72 lines (64 loc) · 2.12 KB
/
graylog_streams_create.yaml
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
- hosts: localhost
gather_facts: no
become: true
vars:
graylog_fqdn: "localhost"
graylog_port: "9000"
graylog_user: "admin"
graylog_password: "admin"
graylog_streams:
- gelf
- syslog
- bal
- cloudwatch
tasks:
- name: List streams
graylog_streams:
action: list
allow_http: true
protocol: http
graylog_fqdn: "{{ graylog_fqdn }}"
graylog_port: "{{ graylog_port }}"
graylog_user: "{{ graylog_user }}"
graylog_password: "{{ graylog_password }}"
- name: Get stream id from stream name query
graylog_streams:
action: query_streams
allow_http: true
protocol: http
graylog_fqdn: "{{ graylog_fqdn }}"
graylog_port: "{{ graylog_port }}"
graylog_user: "{{ graylog_user }}"
graylog_password: "{{ graylog_password }}"
stream_name: "{{ item }}"
loop: "{{ graylog_streams }}"
register: streams
- name: "Print matching streams"
ansible.builtin.debug:
msg: "Stream Name: {{ item.invocation.module_args.stream_name }}, Stream ID: {{ item.json.stream_id }}"
with_items: "{{ streams.results }}"
- name: Create stream
graylog_streams:
action: create
protocol: http
graylog_fqdn: "{{ graylog_fqdn }}"
graylog_port: "{{ graylog_port }}"
graylog_user: "{{ graylog_user }}"
graylog_password: "{{ graylog_password }}"
allow_http: true
title: "{{ item.invocation.module_args.stream_name }}"
description: "test stream2 for ansible-graylog-module"
matching_type: "AND"
remove_matches_from_default_stream: False
with_items: "{{ streams.results }}"
when: item.json.stream_id == "0"
- name: Start streams
graylog_streams:
action: start_stream
protocol: http
graylog_fqdn: "{{ graylog_fqdn }}"
graylog_port: "{{ graylog_port }}"
graylog_user: "{{ graylog_user }}"
graylog_password: "{{ graylog_password }}"
stream_id: "{{ item.json.stream_id }}"
with_items: "{{ streams.results }}"