feat(security): switch secrets management to Bitwarden dynamic lookup and clean repository
This commit is contained in:
1 parent
8df7cef716
commit
a49f271b4f
8 files changed
+24
-35
No files matched your search
@@ -10,6 +10,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
sshpass \
|
sshpass \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
|
nodejs \
|
||||||
|
npm \
|
||||||
|
&& npm install -g @bitwarden/cli \
|
||||||
&& ansible-galaxy collection install ansible.posix community.general \
|
&& ansible-galaxy collection install ansible.posix community.general \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
@@ -19,7 +19,9 @@ jobs:
|
|||||||
- name: Запустить плейбук NetBird
|
- name: Запустить плейбук NetBird
|
||||||
env:
|
env:
|
||||||
RUNNER_SSH_KEY: ${{ secrets.RUNNER_SSH_KEY }}
|
RUNNER_SSH_KEY: ${{ secrets.RUNNER_SSH_KEY }}
|
||||||
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
|
BW_CLIENTID: ${{ secrets.BW_CLIENTID }}
|
||||||
|
BW_CLIENTSECRET: ${{ secrets.BW_CLIENTSECRET }}
|
||||||
|
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
|
||||||
NETBIRD_LETSENCRYPT_EMAIL: ${{ inputs.letsencrypt_email }}
|
NETBIRD_LETSENCRYPT_EMAIL: ${{ inputs.letsencrypt_email }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
@@ -28,6 +30,15 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Настройка и вход в Bitwarden CLI для получения секретов на лету
|
||||||
|
bw config server https://pass.gunihome.ru
|
||||||
|
export BW_CLIENTID="${BW_CLIENTID}"
|
||||||
|
export BW_CLIENTSECRET="${BW_CLIENTSECRET}"
|
||||||
|
bw login --apikey
|
||||||
|
export BW_SESSION=$(bw unlock --passwordenv BW_PASSWORD --raw)
|
||||||
|
|
||||||
|
trap 'rm -f "${HOME}/.ssh/id_ed25519"; bw lock 2>/dev/null || true' EXIT
|
||||||
|
|
||||||
rm -rf "${HOME}/homelab-infra"
|
rm -rf "${HOME}/homelab-infra"
|
||||||
git clone https://gitea.gunihome.ru/karpenok/homelab-infra.git "${HOME}/homelab-infra"
|
git clone https://gitea.gunihome.ru/karpenok/homelab-infra.git "${HOME}/homelab-infra"
|
||||||
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
|
sha="${GITHUB_SHA:-${GITEA_SHA:-}}"
|
||||||
@@ -40,16 +51,6 @@ jobs:
|
|||||||
printf '%s\n' "${RUNNER_SSH_KEY}" > "${HOME}/.ssh/id_ed25519"
|
printf '%s\n' "${RUNNER_SSH_KEY}" > "${HOME}/.ssh/id_ed25519"
|
||||||
chmod 600 "${HOME}/.ssh/id_ed25519"
|
chmod 600 "${HOME}/.ssh/id_ed25519"
|
||||||
|
|
||||||
vault_args=()
|
|
||||||
if [ -n "${ANSIBLE_VAULT_PASSWORD:-}" ]; then
|
|
||||||
printf '%s\n' "${ANSIBLE_VAULT_PASSWORD}" > "${HOME}/.vault_pass"
|
|
||||||
chmod 600 "${HOME}/.vault_pass"
|
|
||||||
vault_args+=(--vault-password-file "${HOME}/.vault_pass")
|
|
||||||
trap 'rm -f "${HOME}/.ssh/id_ed25519" "${HOME}/.vault_pass"' EXIT
|
|
||||||
else
|
|
||||||
trap 'rm -f "${HOME}/.ssh/id_ed25519"' EXIT
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd "${HOME}/homelab-infra"
|
cd "${HOME}/homelab-infra"
|
||||||
|
|
||||||
extra_args=()
|
extra_args=()
|
||||||
@@ -61,5 +62,4 @@ jobs:
|
|||||||
-i inventories/prod/hosts.yml \
|
-i inventories/prod/hosts.yml \
|
||||||
--limit netbird \
|
--limit netbird \
|
||||||
--private-key "${HOME}/.ssh/id_ed25519" \
|
--private-key "${HOME}/.ssh/id_ed25519" \
|
||||||
"${vault_args[@]}" \
|
|
||||||
"${extra_args[@]}"
|
"${extra_args[@]}"
|
||||||
@@ -3,7 +3,6 @@ inventory = inventories/prod/hosts.yml
|
|||||||
roles_path = roles
|
roles_path = roles
|
||||||
retry_files_enabled = false
|
retry_files_enabled = false
|
||||||
stdout_callback = default
|
stdout_callback = default
|
||||||
vault_password_file = ~/.ansible/vault_pass
|
|
||||||
|
|
||||||
[ssh_connection]
|
[ssh_connection]
|
||||||
pipelining = True
|
pipelining = True
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# Общие глобальные переменные для всей инфраструктуры homelab (окружение prod)
|
||||||
|
admin_email: vvkarpenok@gmail.com
|
||||||
|
letsencrypt_email: "{{ admin_email }}"
|
||||||
|
|
||||||
|
# Получение секретов на лету напрямую из Vaultwarden (Bitwarden)
|
||||||
|
netbird_setup_key: "{{ lookup('community.general.bitwarden', 'netbird', field='setup_key') }}"
|
||||||
|
netbird_api_token: "{{ lookup('community.general.bitwarden', 'netbird', field='api_token') }}"
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
# Общие глобальные переменные для всей инфраструктуры homelab (окружение prod)
|
|
||||||
admin_email: vvkarpenok@gmail.com
|
|
||||||
letsencrypt_email: "{{ admin_email }}"
|
|
||||||
|
|
||||||
# Ссылки на зашифрованные секреты из vault.yml
|
|
||||||
netbird_setup_key: "{{ vault_netbird_setup_key }}"
|
|
||||||
netbird_api_token: "{{ vault_netbird_api_token }}"
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
|
||||||
66343233383061353432326463636332396261366566343537333836346635326231356565393234
|
|
||||||
3430613461323362616136623730336238303334646264640a343161666336653030623938653336
|
|
||||||
62366666376432646563333035393766613332633966393732383039333231363065376162386639
|
|
||||||
3637356437393463330a316336633234376166636164333238383465393266356432613233326132
|
|
||||||
37643932663564386464326265306334643930653338353262336466363963386261393665363330
|
|
||||||
61613830613435613264343631373736386162616465613437663261343339616535653561343635
|
|
||||||
30393833333064326230346437613263376134623333303735363036303465313961393834656431
|
|
||||||
36326361326234323935316637363538383365363662656437383537373736626433386462343630
|
|
||||||
66373332663837396564393464366162646336393239326665636361316262363335373333626465
|
|
||||||
39326234626166343961623466623933393266326639656639396463376131396135636139363839
|
|
||||||
633365666264376563376134383337656137
|
|
||||||
@@ -7,7 +7,6 @@ all:
|
|||||||
rus-central:
|
rus-central:
|
||||||
ansible_host: 45.154.185.208
|
ansible_host: 45.154.185.208
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
ansible_password: AUG1HiRoeCBpn9
|
|
||||||
netbird:
|
netbird:
|
||||||
hosts:
|
hosts:
|
||||||
rus-central:
|
rus-central:
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
collections:
|
collections:
|
||||||
- name: ansible.posix
|
- name: ansible.posix
|
||||||
|
- name: community.general
|
||||||
|
|
||||||
Reference in new issue
Block a user