added initial vector state
This commit is contained in:
parent
54f9e7f8b9
commit
0974c47fcb
30
states/vector/config.sls
Normal file
30
states/vector/config.sls
Normal file
@ -0,0 +1,30 @@
|
||||
---
|
||||
{%- from "vector/map.jinja" import vector with context %}
|
||||
vector-default:
|
||||
file.managed:
|
||||
- name: /etc/default/vector
|
||||
- source: salt://vector/templates/vector.default.j2
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 600
|
||||
- template: jinja
|
||||
|
||||
vector-config-dir:
|
||||
file.directory:
|
||||
- name: /etc/vector
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 700
|
||||
# - watch_in:
|
||||
# - service: vector-service
|
||||
|
||||
vector-config-file:
|
||||
file.managed:
|
||||
- name: /etc/vector/vector.conf
|
||||
- source: salt://vector/templates/vector.toml.j2
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 600
|
||||
- template: jinja
|
||||
# - watch_in:
|
||||
# - service: vector-service
|
14
states/vector/defaults.yaml
Normal file
14
states/vector/defaults.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
vector:
|
||||
enabled: true
|
||||
install_dir: /usr/local/apps
|
||||
release_dir: /usr/local/apps/releases
|
||||
mirror: https://github.com/vectordotdev/vector/releases/download
|
||||
version: 0.32.1
|
||||
os: linux
|
||||
arch: amd64
|
||||
variant: gnu
|
||||
config:
|
||||
sources: {}
|
||||
transforms: {}
|
||||
sinks: {}
|
5
states/vector/init.sls
Normal file
5
states/vector/init.sls
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
include:
|
||||
- .install
|
||||
- .config
|
||||
#- .service
|
29
states/vector/install.sls
Normal file
29
states/vector/install.sls
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
{%- from "vector/map.jinja" import vector with context %}
|
||||
vector-archive-extract:
|
||||
archive.extracted:
|
||||
- name: {{ vector.release_dir }}/vector-{{ vector.version }}
|
||||
- source: {{ vector.mirror }}/v{{ vector.version }}/vector-{{ vector.version }}-{{ vector.arch }}-unknown-{{ vector.os }}-{{ vector.variant }}.tar.gz
|
||||
- skip_verify: true
|
||||
- enforce_toplevel: false
|
||||
- options: >
|
||||
--strip 2
|
||||
- if_missing: {{ vector.release_dir }}/vector-{{ vector.version }}/bin/vector
|
||||
# - watch_in:
|
||||
# - service: vector-service
|
||||
|
||||
vector-binary-symlink:
|
||||
file.symlink:
|
||||
- name: /usr/local/bin/vector
|
||||
- target: {{ vector.release_dir }}/vector-{{ vector.version }}/bin/vector
|
||||
- force: true
|
||||
- require:
|
||||
- archive: vector-archive-extract
|
||||
# - watch_in:
|
||||
# - service: vector-service
|
||||
|
||||
vector-cleanup:
|
||||
software.cleanup:
|
||||
- name: vector
|
||||
- path: {{ vector.release_dir }}
|
||||
- version: "v{{ vector.version }}"
|
3
states/vector/kernelmap.yaml
Normal file
3
states/vector/kernelmap.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
Linux:
|
||||
os: "linux"
|
14
states/vector/map.jinja
Normal file
14
states/vector/map.jinja
Normal file
@ -0,0 +1,14 @@
|
||||
{%- import_yaml "vector/defaults.yaml" as default_settings -%}
|
||||
|
||||
{%- import_yaml "vector/kernelmap.yaml" as kernelmap -%}
|
||||
{%- import_yaml "vector/osarchmap.yaml" as osarchmap -%}
|
||||
|
||||
{%- set defaults = salt['grains.filter_by'](default_settings,
|
||||
default='vector',
|
||||
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
|
||||
merge=salt['grains.filter_by'](kernelmap, grain='kernel')
|
||||
)
|
||||
)
|
||||
-%}
|
||||
|
||||
{%- set vector = salt['pillar.get']('vector', default=defaults, merge=True) -%}
|
21
states/vector/osarchmap.yaml
Normal file
21
states/vector/osarchmap.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
amd64:
|
||||
arch: "x86_64"
|
||||
|
||||
x86_64:
|
||||
arch: "x86_64"
|
||||
|
||||
arm64:
|
||||
arch: "aarch64"
|
||||
|
||||
aarch64:
|
||||
arch: "arm64"
|
||||
|
||||
armv6l:
|
||||
arch: "armv7"
|
||||
|
||||
armv7l:
|
||||
arch: "armv7"
|
||||
|
||||
armhf:
|
||||
arch: "armv7"
|
16
states/vector/service.sls
Normal file
16
states/vector/service.sls
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
{%- from "vector/map.jinja" import vector with context %}
|
||||
vector-service-file:
|
||||
file.managed:
|
||||
- name: /etc/systemd/system/vector.service
|
||||
- source: salt://vector/templates/vector.service.j2
|
||||
- user: root
|
||||
- group: root
|
||||
- template: jinja
|
||||
- watch_in:
|
||||
- service: vector-service
|
||||
|
||||
vector-service:
|
||||
service.running:
|
||||
- name: vector
|
||||
- enable: true
|
4
states/vector/templates/vector.default.j2
Normal file
4
states/vector/templates/vector.default.j2
Normal file
@ -0,0 +1,4 @@
|
||||
# /etc/default/vector
|
||||
# This file can theoretically contain a bunch of environment variables
|
||||
# for Vector. See https://vector.dev/docs/setup/configuration/#environment-variables
|
||||
# for details.
|
24
states/vector/templates/vector.service.j2
Normal file
24
states/vector/templates/vector.service.j2
Normal file
@ -0,0 +1,24 @@
|
||||
{%- from "vector/map.jinja" import vector with context -%}
|
||||
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
|
||||
[Unit]
|
||||
Description=A lightweight, ultra-fast tool for building observability pipelines
|
||||
Documentation=https://vector.dev
|
||||
After=network-online.target
|
||||
Requires=network-online.target
|
||||
|
||||
[Service]
|
||||
User=vector
|
||||
Group=vector
|
||||
ExecStartPre=/usr/bin/vector validate
|
||||
ExecStart=/usr/bin/vector
|
||||
ExecReload=/usr/bin/vector validate
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=always
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
EnvironmentFile=-/etc/default/vector
|
||||
# Since systemd 229, should be in [Unit] but in order to support systemd <229,
|
||||
# it is also supported to have it here.
|
||||
StartLimitInterval=10
|
||||
StartLimitBurst=5
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
25
states/vector/templates/vector.toml.j2
Normal file
25
states/vector/templates/vector.toml.j2
Normal file
@ -0,0 +1,25 @@
|
||||
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
|
||||
{%- from "vector/map.jinja" import vector with context %}
|
||||
|
||||
{% macro cfg(value) -%}
|
||||
{% if value -%}
|
||||
{% for paramname, paramvalue in value.items() -%}
|
||||
{{ ' ' }}{{ paramname }} = {% if paramvalue is sameas True or paramvalue is sameas False %}{{ paramvalue|string|lower }}{% elif paramvalue is iterable and paramvalue is not string %}[{{ paramvalue|join(",") }}]{% else %}"{{ paramvalue }}"{% endif %}
|
||||
{% endfor %}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% for name, value in vector.config.sources.items() -%}
|
||||
[sources.{{ name }}]
|
||||
{{ cfg(value) }}
|
||||
{% endfor %}
|
||||
|
||||
{% for name, value in vector.config.transforms.items() -%}
|
||||
[transforms.{{ name }}]
|
||||
{{ cfg(value) }}
|
||||
{% endfor -%}
|
||||
|
||||
{% for name, value in vector.config.sinks.items() -%}
|
||||
[sinks.{{ name }}]
|
||||
{{ cfg(value) }}
|
||||
{% endfor -%}
|
Loading…
Reference in New Issue
Block a user