refactor: split machine deploys from one-time secrets migration
Roles stay under the machine that runs them, CI applies only a known product, and the /opt/secrets move is a one-shot playbook instead of part of every core-secrets run. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
341538fba9
commit
9c692522fb
85 files changed
+537
-492
No files matched your search
@@ -0,0 +1,119 @@
|
||||
---
|
||||
- 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."
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Записать .env
|
||||
ansible.builtin.template:
|
||||
src: env.j2
|
||||
dest: "{{ netbird_dir }}/.env"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
no_log: true
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Положить манифест панели
|
||||
ansible.builtin.copy:
|
||||
src: compose.yaml
|
||||
dest: "{{ netbird_dir }}/compose.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Собрать dashboard.env
|
||||
ansible.builtin.template:
|
||||
src: dashboard.env.j2
|
||||
dest: "{{ netbird_dir }}/dashboard.env"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Перезапустить NetBird
|
||||
tags:
|
||||
- config
|
||||
|
||||
- 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
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Применить изменения конфигурации
|
||||
ansible.builtin.meta: flush_handlers
|
||||
tags:
|
||||
- config
|
||||
|
||||
- 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"
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Показать состояние контейнеров
|
||||
ansible.builtin.command: docker compose ps
|
||||
args:
|
||||
chdir: "{{ netbird_dir }}"
|
||||
register: compose_ps
|
||||
changed_when: false
|
||||
tags:
|
||||
- config
|
||||
|
||||
- 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']
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Итог установки
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ compose_ps.stdout_lines + ['Первый вход: https://' + netbird_domain + '/setup'] }}"
|
||||
tags:
|
||||
- config
|
||||
Reference in new issue
Block a user