From 2f62aaf91f792355692e4e9d42a6a7cf61c06bf5 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Wed, 6 Dec 2023 04:10:43 +0100 Subject: [PATCH] updated vector state --- states/vector/config.sls | 24 +++++++++++------------ states/vector/defaults.yaml | 2 +- states/vector/init.sls | 2 +- states/vector/install.sls | 10 +++++----- states/vector/templates/vector.service.j2 | 9 ++++----- states/vector/templates/vector.yaml.j2 | 4 ++++ 6 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 states/vector/templates/vector.yaml.j2 diff --git a/states/vector/config.sls b/states/vector/config.sls index 5a10111..b46b7fe 100644 --- a/states/vector/config.sls +++ b/states/vector/config.sls @@ -4,27 +4,27 @@ vector-default: file.managed: - name: /etc/default/vector - source: salt://vector/templates/vector.default.j2 - - user: root - - group: root + - user: vector + - group: vector - mode: 600 - template: jinja vector-config-dir: file.directory: - name: /etc/vector - - user: root - - group: root + - user: vector + - group: vector - mode: 700 - # - watch_in: - # - service: vector-service + - 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 + - name: /etc/vector/vector.yaml + - source: salt://vector/templates/vector.yaml.j2 + - user: vector + - group: vector - mode: 600 - template: jinja - # - watch_in: - # - service: vector-service + - watch_in: + - service: vector-service diff --git a/states/vector/defaults.yaml b/states/vector/defaults.yaml index 990f2ee..5170f23 100644 --- a/states/vector/defaults.yaml +++ b/states/vector/defaults.yaml @@ -4,7 +4,7 @@ vector: install_dir: /usr/local/apps release_dir: /usr/local/apps/releases mirror: https://github.com/vectordotdev/vector/releases/download - version: 0.32.1 + version: 0.34.1 os: linux arch: amd64 variant: gnu diff --git a/states/vector/init.sls b/states/vector/init.sls index d1963eb..383c46b 100644 --- a/states/vector/init.sls +++ b/states/vector/init.sls @@ -2,4 +2,4 @@ include: - .install - .config - #- .service + - .service diff --git a/states/vector/install.sls b/states/vector/install.sls index d45c01c..ffa3576 100644 --- a/states/vector/install.sls +++ b/states/vector/install.sls @@ -9,8 +9,8 @@ vector-archive-extract: - options: > --strip 2 - if_missing: {{ vector.release_dir }}/vector-{{ vector.version }}/bin/vector - # - watch_in: - # - service: vector-service + - watch_in: + - service: vector-service vector-binary-symlink: file.symlink: @@ -19,11 +19,11 @@ vector-binary-symlink: - force: true - require: - archive: vector-archive-extract - # - watch_in: - # - service: vector-service + - watch_in: + - service: vector-service vector-cleanup: software.cleanup: - name: vector - path: {{ vector.release_dir }} - - version: "v{{ vector.version }}" + - version: "{{ vector.version }}" diff --git a/states/vector/templates/vector.service.j2 b/states/vector/templates/vector.service.j2 index 5098818..12fde3a 100644 --- a/states/vector/templates/vector.service.j2 +++ b/states/vector/templates/vector.service.j2 @@ -9,16 +9,15 @@ Requires=network-online.target [Service] User=vector Group=vector -ExecStartPre=/usr/bin/vector validate -ExecStart=/usr/bin/vector -ExecReload=/usr/bin/vector validate +ExecStartPre=/usr/local/bin/vector validate +ExecStart=/usr/local/bin/vector +ExecReload=/usr/local/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 diff --git a/states/vector/templates/vector.yaml.j2 b/states/vector/templates/vector.yaml.j2 new file mode 100644 index 0000000..5ab5cc6 --- /dev/null +++ b/states/vector/templates/vector.yaml.j2 @@ -0,0 +1,4 @@ +{%- from "vector/map.jinja" import vector with context -%} +--- +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} +{{ vector.config|yaml(False) }}