Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yaml configuration #21

Merged
merged 2 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
ansible-lint --version
- name: Test
run: |
cd roles/vector && molecule test
cd roles/vector && molecule test --all


33 changes: 33 additions & 0 deletions roles/vector/molecule/features/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Converge
hosts: all
tasks:
- name: "Include vector"
include_role:
name: "vector"
vars:
vector_template: vector.yaml.j2
vector_config_file: /etc/vector/vector.yaml
sources:
journald:
type: journald
current_boot_only: true
tcp:
type: socket
mode: tcp
address: 0.0.0.0:6000
encoding:
codec: json
transforms:
grok:
type: grok_parser
inputs:
- journald
pattern: '(?<capture>\\d+)%{GREEDYDATA}'
sinks:
console:
type: console
encoding:
codec: json
inputs:
- grok
33 changes: 33 additions & 0 deletions roles/vector/molecule/features/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
flake8
platforms:
- name: debian10
image: jrei/systemd-debian:10
privileged: true
command: /lib/systemd/systemd
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: rocky8
image: rockylinux:8
privileged: true
command: /usr/sbin/init
tmpfs:
- /run
- /tmp
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
provisioner:
name: ansible
verifier:
name: ansible
33 changes: 33 additions & 0 deletions roles/vector/molecule/features/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
- name: Verify
hosts: all
gather_facts: true
tasks:
- name: Install netstat
yum:
name:
- net-tools
- procps
state: present
when: ansible_os_family == 'RedHat'
- name: Install netstat
apt:
name:
- net-tools
- procps
state: present
update_cache: yes
when: ansible_os_family == 'Debian'
- name: Execute vector
command: vector --version
changed_when: false
register: vector_version_rc
- name: Check port 6000 is open
community.general.listen_ports_facts:
- name: Assert vector is installed
assert:
that:
- vector_version_rc is success
- 6000 in open_ports
vars:
open_ports: "{{ ansible_facts.tcp_listen | map(attribute='port') }}"
6 changes: 6 additions & 0 deletions roles/vector/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
mode: 0644
notify: restart vector

- name: Use the right config_file
lineinfile:
path: /etc/default/vector
line: "VECTOR_CONFIG={{ vector_config_file }}"
state: present

- name: Add vector user to docker group
user:
name: vector
Expand Down
7 changes: 7 additions & 0 deletions roles/vector/templates/vector.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ vector_general_config | default("") }}
sources:
{{ sources | to_nice_yaml | indent(2) }}
transforms:
{{ transforms | to_nice_yaml | indent(2) }}
sinks:
{{ sinks | to_nice_yaml | indent(2) }}