From 4e8486c1a0453209043480eaf8b5769e70864420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 12 Apr 2019 12:04:12 +0200 Subject: Add a way to specify a port for backup hosts --- modules/role/manifests/backup.pp | 1 + modules/role/templates/backup/backup_dirname_head.sh.erb | 2 ++ modules/role/templates/backup/backup_dirname_part.sh.erb | 2 +- modules/role/templates/backup/backup_dirname_tail.sh.erb | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) (limited to 'modules') 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 %> ##### -- cgit v1.2.3