Files
homelab-infra/ansible/roles/rus-central/netbird/tasks/main.yml
T
karpenok 842a633916
ansible-core-net / deploy (push) Successful in 27s
ansible-core-secrets / deploy (push) Successful in 12s
ansible-rus-central / deploy (push) Successful in 36s
chore(ansible,ci): align workflow paths, shared letsencrypt_email, and netbird task tags
2026-11-11 11:35:45 +07:00

100 lines
3.1 KiB
YAML

---
- name: Разрешить порты панели
ansible.builtin.command: ufw allow {{ item }}
register: ufw_rule
changed_when: "'added' in (ufw_rule.stdout | lower)"
loop: "{{ netbird_ports }}"
- name: Поставить openssl
ansible.builtin.apt:
name: openssl
state: present
- name: Создать каталог панели
ansible.builtin.file:
path: "{{ netbird_dir }}"
state: directory
owner: root
group: root
mode: "0700"
- name: Проверить наличие обязательных секретов NetBird
ansible.builtin.assert:
that:
- netbird_domain is defined and netbird_domain | length > 3
- netbird_auth_secret is defined and netbird_auth_secret | length > 0
- netbird_datastore_key is defined and netbird_datastore_key | length > 0
- netbird_session_key is defined and netbird_session_key | length > 0
- netbird_letsencrypt_email is defined and netbird_letsencrypt_email | length > 3
fail_msg: "Не задан домен NetBird (host_vars) или один из секретов NETBIRD_AUTH_SECRET, NETBIRD_DATASTORE_KEY, NETBIRD_SESSION_KEY, NETBIRD_LETSENCRYPT_EMAIL."
- name: Записать .env
ansible.builtin.template:
src: env.j2
dest: "{{ netbird_dir }}/.env"
owner: root
group: root
mode: "0600"
no_log: true
notify: Перезапустить NetBird
- name: Положить манифест панели
ansible.builtin.copy:
src: compose.yaml
dest: "{{ netbird_dir }}/compose.yaml"
owner: root
group: root
mode: "0644"
notify: Перезапустить NetBird
- name: Собрать dashboard.env
ansible.builtin.template:
src: dashboard.env.j2
dest: "{{ netbird_dir }}/dashboard.env"
owner: root
group: root
mode: "0644"
notify: Перезапустить NetBird
- name: Собрать config.yaml
ansible.builtin.template:
src: config.yaml.j2
dest: "{{ netbird_dir }}/config.yaml"
owner: root
group: root
mode: "0600"
no_log: true
notify: Перезапустить NetBird
- name: Применить изменения конфигурации
ansible.builtin.meta: flush_handlers
- name: Убедиться, что панель запущена
ansible.builtin.command: docker compose up -d
args:
chdir: "{{ netbird_dir }}"
register: compose_up
changed_when: "'Started' in compose_up.stderr or 'Created' in compose_up.stderr or 'Recreated' in compose_up.stderr"
- name: Показать состояние контейнеров
ansible.builtin.command: docker compose ps
args:
chdir: "{{ netbird_dir }}"
register: compose_ps
changed_when: false
- name: Дождаться ответа панели
ansible.builtin.command: >
curl -sk --resolve {{ netbird_domain }}:443:127.0.0.1
-o /dev/null -w '%{http_code}'
https://{{ netbird_domain }}/
register: panel_http
changed_when: false
retries: 30
delay: 10
until: panel_http.stdout in ['200', '302']
- name: Итог установки
ansible.builtin.debug:
msg: "{{ compose_ps.stdout_lines + ['Первый вход: https://' + netbird_domain + '/setup'] }}"