refactor: перейти на ansible.posix.authorized_key, очищать ключ раннера и поддержать внешние секреты
This commit is contained in:
1 parent
7ff2b00d27
commit
69e098415b
4 files changed
+12
-11
No files matched your search
@@ -15,14 +15,10 @@
|
||||
mode: "0700"
|
||||
|
||||
- name: Добавить авторизованные SSH-ключи
|
||||
ansible.builtin.lineinfile:
|
||||
path: /root/.ssh/authorized_keys
|
||||
line: "{{ item }}"
|
||||
ansible.posix.authorized_key:
|
||||
user: root
|
||||
key: "{{ item }}"
|
||||
state: present
|
||||
create: true
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0600"
|
||||
loop: "{{ host_authorized_keys }}"
|
||||
|
||||
- name: Удалить cloud-init настройки пароля SSH
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
- auth
|
||||
- datastore
|
||||
- session
|
||||
when: not netbird_env.stat.exists
|
||||
when: not netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
|
||||
- name: Запомнить новые ключи
|
||||
ansible.builtin.set_fact:
|
||||
@@ -50,14 +50,14 @@
|
||||
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
|
||||
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
|
||||
when: netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
tags:
|
||||
- config
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
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
|
||||
when: netbird_env.stat.exists and netbird_auth_secret is not defined
|
||||
tags:
|
||||
- config
|
||||
|
||||
|
||||
Reference in new issue
Block a user