fix(security): move dashboard auth and netbird secrets to Infisical lifecycle
ansible-core-net / deploy (push) Successful in 21s
ansible-core-net / deploy (push) Successful in 21s
This commit is contained in:
1 parent
309b6538d0
commit
4ab29058fe
7 files changed
+58
-61
No files matched your search
@@ -18,60 +18,14 @@
|
||||
group: root
|
||||
mode: "0700"
|
||||
|
||||
- name: Проверить, созданы ли уже ключи
|
||||
ansible.builtin.stat:
|
||||
path: "{{ netbird_dir }}/.env"
|
||||
register: netbird_env
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Проверить почту Let's Encrypt
|
||||
- name: Проверить наличие обязательных секретов NetBird
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- netbird_letsencrypt_email is defined
|
||||
- netbird_letsencrypt_email | length > 3
|
||||
fail_msg: Укажите почту Let's Encrypt при запуске плейбука.
|
||||
when: not netbird_env.stat.exists
|
||||
|
||||
- name: Сгенерировать ключи панели
|
||||
ansible.builtin.shell: openssl rand -base64 32 | tr -d '\n'
|
||||
register: netbird_generated_keys
|
||||
changed_when: false
|
||||
no_log: true
|
||||
loop:
|
||||
- auth
|
||||
- datastore
|
||||
- session
|
||||
when: not netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
|
||||
- name: Запомнить новые ключи
|
||||
ansible.builtin.set_fact:
|
||||
netbird_auth_secret: "{{ netbird_generated_keys.results[0].stdout }}"
|
||||
netbird_datastore_key: "{{ netbird_generated_keys.results[1].stdout }}"
|
||||
netbird_session_key: "{{ netbird_generated_keys.results[2].stdout }}"
|
||||
no_log: true
|
||||
when: not netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
|
||||
- name: Прочитать сохранённые ключи
|
||||
ansible.builtin.slurp:
|
||||
src: "{{ netbird_dir }}/.env"
|
||||
register: netbird_env_raw
|
||||
no_log: true
|
||||
when: netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
tags:
|
||||
- config
|
||||
|
||||
- name: Разобрать сохранённые ключи
|
||||
ansible.builtin.set_fact:
|
||||
netbird_auth_secret: "{{ env_map['NETBIRD_AUTH_SECRET'] }}"
|
||||
netbird_datastore_key: "{{ env_map['NETBIRD_DATASTORE_KEY'] }}"
|
||||
netbird_session_key: "{{ env_map['NETBIRD_SESSION_KEY'] }}"
|
||||
netbird_letsencrypt_email: "{{ env_map['NETBIRD_LETSENCRYPT_EMAIL'] }}"
|
||||
vars:
|
||||
env_lines: "{{ (netbird_env_raw.content | b64decode).splitlines() | reject('equalto', '') | list }}"
|
||||
env_map: "{{ dict(env_lines | map('split', '=', 1)) }}"
|
||||
no_log: true
|
||||
when: netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
- 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 (NETBIRD_AUTH_SECRET, NETBIRD_DATASTORE_KEY, NETBIRD_SESSION_KEY, NETBIRD_LETSENCRYPT_EMAIL) не переданы из Infisical!"
|
||||
tags:
|
||||
- config
|
||||
|
||||
|
||||
Reference in new issue
Block a user