mirror of
https://github.com/krislamo/pup-tests
synced 2024-11-10 01:00: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:
parent
1b42ed53a3
commit
555304661b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.vagrant
|
.vagrant
|
||||||
*.retry
|
*.retry
|
||||||
|
keys
|
||||||
|
|
||||||
|
11
Vagrantfile
vendored
11
Vagrantfile
vendored
@ -22,6 +22,17 @@ Vagrant.configure("2") do |config|
|
|||||||
master.vm.synced_folder "./code", "/etc/puppet/code", type: "rsync",
|
master.vm.synced_folder "./code", "/etc/puppet/code", type: "rsync",
|
||||||
rsync__args: ["--verbose", "--archive", "-z", "--copy-links"]
|
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
|
end
|
||||||
|
|
||||||
# Clients / Agents
|
# Clients / Agents
|
||||||
|
@ -11,6 +11,19 @@ class amanda::client {
|
|||||||
shell => "/bin/bash"
|
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
|
# Deploy amanda hosts for clients
|
||||||
file { '/etc/amandahosts':
|
file { '/etc/amandahosts':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
|
@ -47,6 +47,19 @@ class amanda {
|
|||||||
owner => "backup"
|
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
|
# Deploy amanda hosts for the amanda server
|
||||||
file { '/etc/amandahosts':
|
file { '/etc/amandahosts':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
|
14
pup-tests.sh
14
pup-tests.sh
@ -26,6 +26,17 @@ EOF
|
|||||||
|
|
||||||
if [ "$1" == "create" ]
|
if [ "$1" == "create" ]
|
||||||
then
|
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 destroy -f
|
||||||
vagrant up
|
vagrant up
|
||||||
|
|
||||||
@ -34,6 +45,7 @@ then
|
|||||||
|
|
||||||
vagrant ssh webserver -c "sudo puppet agent -t"
|
vagrant ssh webserver -c "sudo puppet agent -t"
|
||||||
vagrant ssh backups -c "sudo puppet agent -t"
|
vagrant ssh backups -c "sudo puppet agent -t"
|
||||||
|
|
||||||
elif [ "$1" == "apply" ]
|
elif [ "$1" == "apply" ]
|
||||||
then
|
then
|
||||||
vagrant ssh master -c "cd /etc/puppet/code/environments/production && \
|
vagrant ssh master -c "cd /etc/puppet/code/environments/production && \
|
||||||
@ -45,6 +57,7 @@ then
|
|||||||
else
|
else
|
||||||
vagrant ssh $2 -c "sudo puppet agent -t";
|
vagrant ssh $2 -c "sudo puppet agent -t";
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [ "$1" == "cert-update" ]
|
elif [ "$1" == "cert-update" ]
|
||||||
then
|
then
|
||||||
vagrant ssh master -c "sudo puppet cert clean $2"
|
vagrant ssh master -c "sudo puppet cert clean $2"
|
||||||
@ -54,6 +67,7 @@ then
|
|||||||
vagrant ssh master -c "sudo puppet cert sign $2"
|
vagrant ssh master -c "sudo puppet cert sign $2"
|
||||||
sleep 3
|
sleep 3
|
||||||
vagrant ssh $2 -c "sudo puppet agent -t"
|
vagrant ssh $2 -c "sudo puppet agent -t"
|
||||||
|
|
||||||
elif [ "$1" == "help" ]
|
elif [ "$1" == "help" ]
|
||||||
then
|
then
|
||||||
cat << "EOF"
|
cat << "EOF"
|
||||||
|
Loading…
Reference in New Issue
Block a user