1
0
mirror of https://github.com/krislamo/pup-tests synced 2024-09-19 17:20:35 +00:00

Added SSH keys for restoration

On "./pup-tests.sh create" SSH keys will be created and placed on
the webserver and backup server to allow the backup server to
restore files back to the webserver easily.
This commit is contained in:
Kris Lamoureux 2019-03-04 12:14:45 -05:00
parent 1b42ed53a3
commit 555304661b
Signed by: kris
GPG Key ID: A30022791E1719A4
5 changed files with 52 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vagrant
*.retry
keys

11
Vagrantfile vendored
View File

@ -22,6 +22,17 @@ Vagrant.configure("2") do |config|
master.vm.synced_folder "./code", "/etc/puppet/code", type: "rsync",
rsync__args: ["--verbose", "--archive", "-z", "--copy-links"]
# Sync custom SSH keys to Puppet Master
modpath = "/etc/puppet/code/environments/production/modules/"
master.vm.provision "file",
source: "./keys/backup-key",
destination: modpath + "amanda/files/backup-key"
master.vm.provision "file",
source: "./keys/backup-key.pub",
destination: modpath + "amanda/files/backup-key.pub"
end
# Clients / Agents

View File

@ -11,6 +11,19 @@ class amanda::client {
shell => "/bin/bash"
}
# Enable remote access from backup server
file { '/var/backups/.ssh':
ensure => directory
}
# Deploy temporary backup key made by pup-tests.sh
file { '/var/backups/.ssh/authorized_keys':
ensure => file,
content => file('amanda/backup-key.pub'),
owner => 'backup',
mode => "644"
}
# Deploy amanda hosts for clients
file { '/etc/amandahosts':
ensure => file,

View File

@ -47,6 +47,19 @@ class amanda {
owner => "backup"
}
# # Enable remote access from backup server
# file { '/var/backups/.ssh':
# ensure => directory
# }
# Deploy temporary backup key made by pup-tests.sh
file { '/home/vagrant/.ssh/id_rsa':
ensure => file,
content => file('amanda/backup-key'),
owner => 'vagrant',
mode => "600"
}
# Deploy amanda hosts for the amanda server
file { '/etc/amandahosts':
ensure => file,

View File

@ -26,6 +26,17 @@ EOF
if [ "$1" == "create" ]
then
mkdir -p keys
if [ -f ./keys/backup-key ] || [ -f ./keys/backup-key.pub ] ; then
rm ./keys/backup-key*
fi
ssh-keygen -t rsa -b 4096 -N '' -f ./keys/backup-key
chmod -R 777 ./keys
vagrant destroy -f
vagrant up
@ -34,6 +45,7 @@ then
vagrant ssh webserver -c "sudo puppet agent -t"
vagrant ssh backups -c "sudo puppet agent -t"
elif [ "$1" == "apply" ]
then
vagrant ssh master -c "cd /etc/puppet/code/environments/production && \
@ -45,6 +57,7 @@ then
else
vagrant ssh $2 -c "sudo puppet agent -t";
fi
elif [ "$1" == "cert-update" ]
then
vagrant ssh master -c "sudo puppet cert clean $2"
@ -54,6 +67,7 @@ then
vagrant ssh master -c "sudo puppet cert sign $2"
sleep 3
vagrant ssh $2 -c "sudo puppet agent -t"
elif [ "$1" == "help" ]
then
cat << "EOF"