From: Ismaƫl Bouya Date: Fri, 12 Apr 2019 10:04:12 +0000 (+0200) Subject: Add a way to specify a port for backup hosts X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=4e8486c1a0453209043480eaf8b5769e70864420;p=perso%2FImmae%2FProjets%2FPuppet.git Add a way to specify a port for backup hosts --- diff --git a/modules/role/manifests/backup.pp b/modules/role/manifests/backup.pp index 6b8d00c..bdc35d5 100644 --- a/modules/role/manifests/backup.pp +++ b/modules/role/manifests/backup.pp @@ -70,6 +70,7 @@ class role::backup ( $dirname = $infos["name"] $login = $infos["login"] $host = $infos["host"] + $port = if $infos.dig("port") { $infos.dig("port") } else { 22 } $dest = "$login@$host" $base = "$mountpoint/$dirname" $nbr = $infos["nbr"] diff --git a/modules/role/templates/backup/backup_dirname_head.sh.erb b/modules/role/templates/backup/backup_dirname_head.sh.erb index e20cfd3..15a0448 100644 --- a/modules/role/templates/backup/backup_dirname_head.sh.erb +++ b/modules/role/templates/backup/backup_dirname_head.sh.erb @@ -1,4 +1,5 @@ ##### <%= @dirname %> ##### +PORT="<%= @port %>" DEST="<%= @dest %>" BASE="<%= @base %>" OLD_BAK_BASE=$BASE/older/j @@ -10,6 +11,7 @@ if ! ssh \ -o PreferredAuthentications=publickey \ -o StrictHostKeyChecking=yes \ -o ClearAllForwardings=yes \ + -p $PORT \ $DEST backup; then echo "Fichier de verrouillage backup sur $DEST ou impossible de se connecter" >&2 skip=$DEST diff --git a/modules/role/templates/backup/backup_dirname_part.sh.erb b/modules/role/templates/backup/backup_dirname_part.sh.erb index ec662c4..77d4206 100644 --- a/modules/role/templates/backup/backup_dirname_part.sh.erb +++ b/modules/role/templates/backup/backup_dirname_part.sh.erb @@ -11,7 +11,7 @@ cat > $FILES_FROM < <%= @args %>\ diff --git a/modules/role/templates/backup/backup_dirname_tail.sh.erb b/modules/role/templates/backup/backup_dirname_tail.sh.erb index 5027992..11de00c 100644 --- a/modules/role/templates/backup/backup_dirname_tail.sh.erb +++ b/modules/role/templates/backup/backup_dirname_tail.sh.erb @@ -1,4 +1,4 @@ - ssh $DEST sh -c "date > .cache/last_backup" + ssh -p $PORT $DEST sh -c "date > .cache/last_backup" fi # [ "$skip" != "$DEST" ] ##### End <%= @dirname %> #####