Files
homelab-infra/ansible/roles/vector/tasks/main.yml
T
karpenok ca25b1d042
ansible-deploy / plan (push) Successful in 2s
ansible-lint / lint (push) Successful in 2s
ansible-deploy / deploy (core-mon, ) (push) Successful in 8s
ansible-deploy / deploy (core-net, ) (push) Successful in 9s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 8s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 2m18s
ansible-deploy / deploy (rus-central, ) (push) Successful in 2m0s
chore(security): disable vector on external VPS nodes and restrict exit node LAN access
2026-11-18 12:05:37 +07:00

89 lines
3.0 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: Отключить и удалить конфиг Vector, если сбор логов выключен
when: not (vector_enabled | bool)
block:
- name: Проверить наличие systemd-сервиса Vector
ansible.builtin.stat:
path: /lib/systemd/system/vector.service
register: vector_unit
- name: Остановить и отключить Vector
ansible.builtin.systemd:
name: vector
state: stopped
enabled: false
when: vector_unit.stat.exists
- name: Удалить конфигурацию Vector
ansible.builtin.file:
path: "{{ vector_config_path }}"
state: absent
- name: Установить и запустить нативный Vector
when: vector_enabled | bool
block:
- 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' }}"