forked from onedr0p/home-ops
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vector): add vector to some ansible roles
Signed-off-by: Devin Buhl <[email protected]>
- Loading branch information
Showing
14 changed files
with
182 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
pikvm: | ||
hosts: | ||
pikvm: | ||
ansible_host: 192.168.42.65 | ||
ansible_host: 192.168.1.80 | ||
ansible_user: root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
- name: Restart vector | ||
ansible.builtin.systemd: | ||
name: vector.service | ||
state: restarted | ||
enabled: true | ||
daemon_reload: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
- name: Create vector directories | ||
ansible.builtin.file: | ||
path: /etc/vector | ||
state: directory | ||
|
||
- name: Check current vector version | ||
ansible.builtin.command: "/usr/local/bin/vector --version" | ||
failed_when: false | ||
changed_when: false | ||
register: vector_version_check | ||
|
||
- name: Download and unarchive vector into temporary location | ||
ansible.builtin.unarchive: | ||
src: "{{ vector_download_url }}" | ||
dest: /tmp | ||
remote_src: true | ||
mode: 0755 | ||
when: > | ||
vector_version_check.stdout is not defined | ||
or vector_version not in vector_version_check.stdout | ||
register: vector_download_check | ||
|
||
- name: Move vector binary into place | ||
ansible.builtin.copy: | ||
src: /tmp/vector-armv7-unknown-linux-gnueabihf/bin/vector | ||
dest: /usr/local/bin/vector | ||
mode: 0755 | ||
remote_src: true | ||
when: > | ||
vector_version_check.stdout is not defined | ||
or vector_version not in vector_version_check.stdout | ||
notify: Restart vector | ||
|
||
- block: | ||
- name: Copy vector config | ||
ansible.builtin.template: | ||
src: vector.yaml.j2 | ||
dest: /etc/vector/vector.yaml | ||
mode: 0755 | ||
- name: Create vector systemd file | ||
ansible.builtin.template: | ||
src: vector.service.j2 | ||
dest: /etc/systemd/system/vector.service | ||
mode: 0644 | ||
notify: Restart vector |
12 changes: 12 additions & 0 deletions
12
ansible/pikvm/roles/vector.pikvm/templates/vector.service.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=Vector | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
TimeoutStartSec=0 | ||
User=root | ||
ExecStart=/usr/local/bin/vector --config /etc/vector/vector.yaml | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
data_dir: /tmp | ||
sources: | ||
journal_logs: | ||
type: journald | ||
journal_directory: /run/log/journal | ||
sinks: | ||
loki_journal_sink: | ||
type: loki | ||
inputs: | ||
- journal_logs | ||
endpoint: https://loki.{{ SECRET_PUBLIC_DOMAIN }} | ||
encoding: | ||
codec: json | ||
batch: | ||
max_bytes: 400000 | ||
out_of_order_action: rewrite_timestamp | ||
labels: | ||
hostname: "{{ '{{ name }}' }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# | ||
# SECRET* vars are encrypted with sops | ||
# | ||
|
||
# TODO: Renovate vector version in pikvm ansible | ||
vector_version: 0.18.1 | ||
vector_download_url: https://github.com/vectordotdev/vector/releases/download/v{{ vector_version }}/vector-{{ vector_version }}-armv7-unknown-linux-gnueabihf.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,10 @@ | |
state: restarted | ||
enabled: true | ||
daemon_reload: true | ||
|
||
- name: Restart vector | ||
ansible.builtin.systemd: | ||
name: "[email protected]" | ||
state: restarted | ||
enabled: true | ||
daemon_reload: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: Create vector directories | ||
ansible.builtin.file: | ||
path: "{{ item }}" | ||
state: directory | ||
loop: | ||
- "{{ containers_base_dir }}/apps/vector" | ||
- "{{ containers_base_dir }}/data/vector" | ||
|
||
- block: | ||
- name: Create vector docker compose file | ||
ansible.builtin.template: | ||
src: vector/docker-compose.yml.j2 | ||
dest: "{{ containers_base_dir }}/apps/vector/docker-compose.yml" | ||
mode: 0755 | ||
- name: Create vector config | ||
ansible.builtin.template: | ||
src: vector/vector.yaml.j2 | ||
dest: "{{ containers_base_dir }}/apps/vector/vector.yaml" | ||
mode: 0755 | ||
- name: Create vector systemd service file | ||
ansible.builtin.template: | ||
src: "[email protected]" | ||
dest: "/etc/systemd/system/[email protected]" | ||
mode: 0644 | ||
notify: Restart vector |
23 changes: 23 additions & 0 deletions
23
ansible/storage/roles/apps.storage/templates/vector/docker-compose.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
version: "3.8" | ||
|
||
services: | ||
vector: | ||
image: docker.io/timberio/vector:0.18.1-debian | ||
container_name: vector | ||
restart: unless-stopped | ||
network_mode: host | ||
command: | ||
- --config=/etc/vector/vector.yaml | ||
volumes: | ||
- "{{ containers_base_dir }}/apps/vector/vector.yaml:/etc/vector/vector.yaml:ro" | ||
- vector-data:/vector-data-dir | ||
- /var/log:/var/log:ro | ||
|
||
volumes: | ||
vector-data: | ||
driver: local | ||
driver_opts: | ||
type: none | ||
o: bind | ||
device: "{{ containers_base_dir }}/data/vector" |
19 changes: 19 additions & 0 deletions
19
ansible/storage/roles/apps.storage/templates/vector/vector.yaml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
data_dir: /vector-data-dir | ||
sources: | ||
journal_logs: | ||
type: journald | ||
journal_directory: /var/log/journal | ||
sinks: | ||
loki_journal_sink: | ||
type: loki | ||
inputs: | ||
- journal_logs | ||
endpoint: https://loki.{{ SECRET_PUBLIC_DOMAIN }} | ||
encoding: | ||
codec: json | ||
batch: | ||
max_bytes: 400000 | ||
out_of_order_action: rewrite_timestamp | ||
labels: | ||
hostname: "{{ '{{ name }}' }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ sinks: | |
tls: | ||
verify_certificate: false | ||
labels: | ||
hostname: valetudo | ||
hostname: "{{ name }}" |