refactor: drop the finished secrets migration from the deploy path
Product tags now come from the role directory, and edits to the CI scripts no longer redeploy every machine. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
9f337445a9
commit
a0507719b0
7 files changed
+16
-68
No files matched your search
Regular → Executable
+15
-25
@@ -1,8 +1,9 @@
|
||||
#!/bin/sh
|
||||
# Печатает аргументы ansible-playbook для одной машины.
|
||||
# Полный прогон только для общих файлов: playbooks/site.yml, --limit, <машина>
|
||||
# Продукт из коммита: playbooks/<машина>.yml, --tags, role[,role]
|
||||
# Неизвестный файл внутри roles/<машина>/ завершает скрипт с кодом 2.
|
||||
# Файл роли: playbooks/<машина>.yml, --tags, каталог роли
|
||||
# Тег берётся из каталога ansible/roles/<машина>/<продукт>/ и должен совпадать с тегом в плейбуке машины.
|
||||
# Файл в roles/<машина>/ вне такого каталога завершает скрипт с кодом 2.
|
||||
# Коммит без файлов этой машины ничего не печатает и завершается с кодом 0.
|
||||
set -eu
|
||||
|
||||
@@ -38,6 +39,7 @@ fi
|
||||
tags=""
|
||||
full_from_files=0
|
||||
unknown=0
|
||||
playbook="ansible/playbooks/${machine}.yml"
|
||||
|
||||
add_tag() {
|
||||
case ",$tags," in
|
||||
@@ -59,32 +61,20 @@ if [ "$full" -eq 0 ] && [ -n "$changed" ]; then
|
||||
for file in $changed; do
|
||||
[ -n "$file" ] || continue
|
||||
case "$file" in
|
||||
ansible/roles/host/* | ansible/playbooks/host.yml | ansible/playbooks/site.yml | ansible/playbooks/"$machine".yml | ansible/inventories/prod/hosts.yml | ansible/inventories/prod/group_vars/* | ansible/inventories/prod/host_vars/"$machine".yml | ansible/ci/*)
|
||||
ansible/roles/host/* | ansible/playbooks/host.yml | ansible/playbooks/site.yml | ansible/playbooks/"$machine".yml | ansible/inventories/prod/hosts.yml | ansible/inventories/prod/group_vars/* | ansible/inventories/prod/host_vars/"$machine".yml)
|
||||
full_from_files=1
|
||||
;;
|
||||
ansible/roles/core-net/traefik/*)
|
||||
[ "$machine" = "core-net" ] && add_tag traefik
|
||||
ansible/roles/"$machine"/*/*)
|
||||
product=${file#ansible/roles/"$machine"/}
|
||||
product=${product%%/*}
|
||||
if grep -q "role: ${machine}/${product}" "$playbook" && grep -q "tags: \[${product}\]" "$playbook"; then
|
||||
add_tag "$product"
|
||||
else
|
||||
reject_unknown "$file"
|
||||
fi
|
||||
;;
|
||||
ansible/roles/core-net/authentik/*)
|
||||
[ "$machine" = "core-net" ] && add_tag authentik
|
||||
;;
|
||||
ansible/roles/core-net/*)
|
||||
[ "$machine" = "core-net" ] && reject_unknown "$file"
|
||||
;;
|
||||
ansible/roles/core-secrets/infisical/*)
|
||||
[ "$machine" = "core-secrets" ] && add_tag infisical
|
||||
;;
|
||||
ansible/roles/core-secrets/vaultwarden/*)
|
||||
[ "$machine" = "core-secrets" ] && add_tag vaultwarden
|
||||
;;
|
||||
ansible/roles/core-secrets/*)
|
||||
[ "$machine" = "core-secrets" ] && reject_unknown "$file"
|
||||
;;
|
||||
ansible/roles/rus-central/netbird/*)
|
||||
[ "$machine" = "rus-central" ] && add_tag netbird
|
||||
;;
|
||||
ansible/roles/rus-central/*)
|
||||
[ "$machine" = "rus-central" ] && reject_unknown "$file"
|
||||
ansible/roles/"$machine"/*)
|
||||
reject_unknown "$file"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in new issue
Block a user