Skip to content

Commit

Permalink
Merge pull request #21 from gaetan-craft/add_yaml_configuration
Browse files Browse the repository at this point in the history
Add yaml configuration
  • Loading branch information
gaetanfl authored Jun 10, 2022
2 parents 027941d + c2c412b commit 8e2f6e3
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 1 deletion.
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) }}

0 comments on commit 8e2f6e3

Please sign in to comment.