aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-12 12:04:12 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-04-12 12:09:28 +0200
commit4e8486c1a0453209043480eaf8b5769e70864420 (patch)
tree7d393b0cdaef94ca81856db3883b3baa9c94c539 /modules
parent528b0cf99b8e62789f982970ee3766ec4f54133f (diff)
downloadPuppet-4e8486c1a0453209043480eaf8b5769e70864420.tar.gz
Puppet-4e8486c1a0453209043480eaf8b5769e70864420.tar.zst
Puppet-4e8486c1a0453209043480eaf8b5769e70864420.zip
Add a way to specify a port for backup hosts
Diffstat (limited to 'modules')
-rw-r--r--modules/role/manifests/backup.pp1
-rw-r--r--modules/role/templates/backup/backup_dirname_head.sh.erb2
-rw-r--r--modules/role/templates/backup/backup_dirname_part.sh.erb2
-rw-r--r--modules/role/templates/backup/backup_dirname_tail.sh.erb2
4 files changed, 5 insertions, 2 deletions
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 (
70 $dirname = $infos["name"] 70 $dirname = $infos["name"]
71 $login = $infos["login"] 71 $login = $infos["login"]
72 $host = $infos["host"] 72 $host = $infos["host"]
73 $port = if $infos.dig("port") { $infos.dig("port") } else { 22 }
73 $dest = "$login@$host" 74 $dest = "$login@$host"
74 $base = "$mountpoint/$dirname" 75 $base = "$mountpoint/$dirname"
75 $nbr = $infos["nbr"] 76 $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 @@
1##### <%= @dirname %> ##### 1##### <%= @dirname %> #####
2PORT="<%= @port %>"
2DEST="<%= @dest %>" 3DEST="<%= @dest %>"
3BASE="<%= @base %>" 4BASE="<%= @base %>"
4OLD_BAK_BASE=$BASE/older/j 5OLD_BAK_BASE=$BASE/older/j
@@ -10,6 +11,7 @@ if ! ssh \
10 -o PreferredAuthentications=publickey \ 11 -o PreferredAuthentications=publickey \
11 -o StrictHostKeyChecking=yes \ 12 -o StrictHostKeyChecking=yes \
12 -o ClearAllForwardings=yes \ 13 -o ClearAllForwardings=yes \
14 -p $PORT \
13 $DEST backup; then 15 $DEST backup; then
14 echo "Fichier de verrouillage backup sur $DEST ou impossible de se connecter" >&2 16 echo "Fichier de verrouillage backup sur $DEST ou impossible de se connecter" >&2
15 skip=$DEST 17 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 <<EOF
11EOF 11EOF
12 12
13OUT=$RSYNC_OUTPUT/$LOCAL 13OUT=$RSYNC_OUTPUT/$LOCAL
14rsync -XAavbrz --fake-super -e ssh --numeric-ids --delete \ 14rsync -XAavbrz --fake-super -e "ssh -p $PORT" --numeric-ids --delete \
15 --backup-dir=$BAK_BASE/$LOCAL \ 15 --backup-dir=$BAK_BASE/$LOCAL \
16<%- unless @args.empty? -%> 16<%- unless @args.empty? -%>
17 <%= @args %>\ 17 <%= @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 @@
1 1
2 ssh $DEST sh -c "date > .cache/last_backup" 2 ssh -p $PORT $DEST sh -c "date > .cache/last_backup"
3fi # [ "$skip" != "$DEST" ] 3fi # [ "$skip" != "$DEST" ]
4##### End <%= @dirname %> ##### 4##### End <%= @dirname %> #####