add vector role

This commit is contained in:
2025-11-08 12:26:28 +00:00
parent ca51d33568
commit d4ce6e21f0
7 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
---
vector_setup:
config_path: /etc/vector/vector.yaml
vector_config:
hostname: ""
journald:
enbled: true
loki:
address: ""

View File

@@ -0,0 +1,6 @@
---
- name: Restart Service
become: true
ansible.builtin.service:
name: vector
state: restarted

View File

@@ -0,0 +1,9 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.1
galaxy_tags: []
dependencies: []

View File

@@ -0,0 +1,25 @@
---
- name: Install Vector via official script
ansible.builtin.shell: bash -c "$(curl -L https://setup.vector.dev)"
args:
creates: /usr/bin/vector
- name: Install Vector
ansible.builtin.apt:
name: vector
state: present
- name: Deploy config
become: true
ansible.builtin.template:
src: templates/vector.yaml.j2
dest: "{{ vector_setup.config_path }}"
owner: root
notify:
- Restart Service
- name: Enable and start Vector service
ansible.builtin.systemd:
name: vector
enabled: yes
state: started

View File

@@ -0,0 +1,34 @@
sources:
journald:
type: journald
transforms:
tag_journald:
type: remap
inputs:
- journald
source: |
.source = "journald"
.unit = ._SYSTEMD_UNIT
.process = ._COMM
.priority = .PRIORITY
.host = "{{ vector_config.hostname }}"
sinks:
loki:
type: loki
inputs:
- tag_journald
endpoint: "{{ vector_config.loki.address }}"
healthcheck:
enabled: false
encoding:
codec: json
labels:
{% raw %}
host: "{{ .host }}"
source: "{{ .source }}"
unit: "{{ .unit }}"
process: "{{ .process }}"
priority: "{{ .priority }}"
{% endraw %}

View File

@@ -0,0 +1,6 @@
- name: Vector Install
hosts:
- all
roles:
- role: vector