Pattern-match node names for VM backup exclusion

This commit is contained in:
Râu Cao 2023-12-05 18:04:57 +01:00
parent 1e9878d17e
commit b1763cd032
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
2 changed files with 4 additions and 4 deletions

View File

@ -45,9 +45,9 @@
"kosmos_kvm": {
"backup": {
"nodes_excluded": [
"garage-2", "garage-3", "garage-4",
"postgres-5",
"rsk-mainnet-2", "rsk-testnet-3"
"garage-",
"rsk-",
"postgres-5"
]
}
},

View File

@ -54,7 +54,7 @@ end
vm_domains = search(:node, "role:kvm_guest").map{|n| n["hostname"] } \
& `virsh list --name`.strip.chomp.split("\n")
vm_domains.reject! { |d| node["kosmos_kvm"]["backup"]["nodes_excluded"].include?(d) }
vm_domains.reject! { |d| node["kosmos_kvm"]["backup"]["nodes_excluded"].any?{ |n| d.match?(/^#{n}/) } }
template "/root/backups/backup_all_vms.sh" do
source "backup_all_vms.sh.erb"