Files
homelab-infra/ansible/roles/vector/tasks/main.yml
T
karpenok 425d878ec7
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 2s
ansible-deploy / deploy (core-mon, ) (push) Successful in 9s
ansible-deploy / deploy (core-net, ) (push) Successful in 10s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 8s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 14s
ansible-deploy / deploy (rus-central, ) (push) Successful in 16s
fix(vector): pass --config-yaml to vector validate and remove default vector.toml
2026-11-18 11:47:04 +07:00

66 lines
2.1 KiB
YAML

---
- name: Проверить наличие старого Docker-контейнера Vector
ansible.builtin.stat:
path: "{{ vector_legacy_dir }}/compose.yaml"
register: vector_legacy_compose
- name: Остановить старый Docker-контейнер Vector
ansible.builtin.command: docker compose -f {{ vector_legacy_dir }}/compose.yaml down --remove-orphans
when: vector_legacy_compose.stat.exists
changed_when: true
- name: Удалить каталог старого Docker-контейнера Vector
ansible.builtin.file:
path: "{{ vector_legacy_dir }}"
state: absent
when: vector_legacy_compose.stat.exists
- name: Подключить APT-репозиторий Vector
ansible.builtin.shell: curl -1sLf 'https://setup.vector.dev' | bash
args:
creates: /etc/apt/sources.list.d/vector.list
- name: Установить нативный пакет Vector
ansible.builtin.apt:
name: vector
state: present
update_cache: true
- name: Выдать пользователю vector доступ к journald и docker
ansible.builtin.user:
name: vector
groups:
- systemd-journal
- docker
append: true
register: vector_user_groups
- name: Подготовить каталог данных Vector
ansible.builtin.file:
path: "{{ vector_data_dir }}"
state: directory
owner: vector
group: vector
mode: "0750"
- name: Удалить дефолтный vector.toml из пакета, если есть
ansible.builtin.file:
path: /etc/vector/vector.toml
state: absent
- name: Установить конфигурацию Vector
ansible.builtin.template:
src: vector.yaml.j2
dest: "{{ vector_config_path }}"
owner: root
group: vector
mode: "0640"
validate: "vector validate --no-environment --config-yaml %s"
register: vector_config
- name: Запустить и включить systemd-сервис Vector
ansible.builtin.systemd:
name: vector
enabled: true
state: "{{ 'restarted' if (vector_config is changed or vector_user_groups is changed) else 'started' }}"