ci: unify into matrix ansible-deploy.yml, add ansible-lint.yml and exit_nodes group
ansible-deploy / plan (push) Successful in 1s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 17s
ansible-lint / lint (push) Failing after 3s
ansible-deploy / deploy (core-mon, ) (push) Successful in 26s
ansible-deploy / deploy (core-net, ) (push) Successful in 52s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m18s
ansible-deploy / deploy (opnsense, ) (push) Successful in 9s
ansible-deploy / deploy (rus-central, ) (push) Successful in 52s
ansible-deploy / plan (push) Successful in 1s
ansible-deploy / deploy (core-secrets, ) (push) Successful in 17s
ansible-lint / lint (push) Failing after 3s
ansible-deploy / deploy (core-mon, ) (push) Successful in 26s
ansible-deploy / deploy (core-net, ) (push) Successful in 52s
ansible-deploy / deploy (ger-nod-02, ) (push) Successful in 1m18s
ansible-deploy / deploy (opnsense, ) (push) Successful in 9s
ansible-deploy / deploy (rus-central, ) (push) Successful in 52s
This commit is contained in:
1 parent
189e31e266
commit
fd0dcab300
18 files changed
+243
-278
No files matched your search
@@ -1,9 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Печатает аргументы ansible-playbook для одной машины.
|
||||
# Полный прогон только для общих файлов: playbooks/site.yml, --limit, <машина>
|
||||
# Файл роли: playbooks/<машина>.yml, --tags, каталог роли
|
||||
# Тег берётся из каталога ansible/roles/<машина>/<продукт>/ и должен совпадать с тегом в плейбуке машины.
|
||||
# Файл в roles/<машина>/ вне такого каталога завершает скрипт с кодом 2.
|
||||
# Полный прогон только при ручном запуске без тегов или при изменении общих файлов машины:
|
||||
# playbooks/site.yml --limit <машина>
|
||||
# Файл роли: playbooks/<машина>.yml --tags <продукт>
|
||||
# Коммит без файлов этой машины ничего не печатает и завершается с кодом 0.
|
||||
set -eu
|
||||
|
||||
@@ -11,14 +10,18 @@ machine=${1:?machine}
|
||||
event=${2:-}
|
||||
before=${3:-}
|
||||
after=${4:-}
|
||||
override_tags=${5:-}
|
||||
|
||||
case "$machine" in
|
||||
core-net | core-secrets | core-mon | core-git | rus-central | ger-nod-02 | opnsense) ;;
|
||||
*)
|
||||
echo "Неизвестная машина: $machine" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
playbook="ansible/playbooks/${machine}.yml"
|
||||
if [ "$machine" = "site" ] || [ "$machine" = "host" ] || [ ! -f "$playbook" ]; then
|
||||
echo "Неизвестная машина: $machine" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -n "$override_tags" ]; then
|
||||
printf '%s\n' "playbooks/${machine}.yml" "--tags" "$override_tags"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
full=0
|
||||
changed=""
|
||||
@@ -39,7 +42,6 @@ fi
|
||||
tags=""
|
||||
full_from_files=0
|
||||
unknown=0
|
||||
playbook="ansible/playbooks/${machine}.yml"
|
||||
|
||||
add_tag() {
|
||||
case ",$tags," in
|
||||
@@ -61,28 +63,23 @@ if [ "$full" -eq 0 ] && [ -n "$changed" ]; then
|
||||
for file in $changed; do
|
||||
[ -n "$file" ] || continue
|
||||
case "$file" in
|
||||
ansible/ansible.cfg | 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)
|
||||
ansible/ansible.cfg | 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/netbird_client/*)
|
||||
case "$machine" in
|
||||
core-net | ger-nod-02) add_tag netbird ;;
|
||||
esac
|
||||
;;
|
||||
ansible/roles/netbird_exit_node/*)
|
||||
case "$machine" in
|
||||
ger-nod-02) add_tag netbird ;;
|
||||
esac
|
||||
ansible/roles/netbird_client/* | ansible/roles/netbird_exit_node/*)
|
||||
if grep -qE "role: (netbird_client|netbird_exit_node)" "$playbook"; then
|
||||
add_tag netbird
|
||||
fi
|
||||
;;
|
||||
ansible/roles/remnanode/*)
|
||||
case "$machine" in
|
||||
ger-nod-02) add_tag remnanode ;;
|
||||
esac
|
||||
if grep -q "role: remnanode" "$playbook"; then
|
||||
add_tag remnanode
|
||||
fi
|
||||
;;
|
||||
ansible/roles/vmagent/*)
|
||||
case "$machine" in
|
||||
core-net | ger-nod-02) add_tag vmagent ;;
|
||||
esac
|
||||
if grep -q "role: vmagent" "$playbook"; then
|
||||
add_tag vmagent
|
||||
fi
|
||||
;;
|
||||
ansible/roles/"$machine"/.ci-trigger)
|
||||
;;
|
||||
|
||||
Reference in new issue
Block a user