diff --git a/.gitignore b/.gitignore index 9f6435d..f951ae7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vagrant *.retry +keys diff --git a/Vagrantfile b/Vagrantfile index 768e1f6..7e1df63 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/code/environments/production/modules/amanda/manifests/client.pp b/code/environments/production/modules/amanda/manifests/client.pp index 4b7ec41..740ffd0 100644 --- a/code/environments/production/modules/amanda/manifests/client.pp +++ b/code/environments/production/modules/amanda/manifests/client.pp @@ -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, diff --git a/code/environments/production/modules/amanda/manifests/init.pp b/code/environments/production/modules/amanda/manifests/init.pp index dc7c0f0..a639910 100644 --- a/code/environments/production/modules/amanda/manifests/init.pp +++ b/code/environments/production/modules/amanda/manifests/init.pp @@ -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, diff --git a/pup-tests.sh b/pup-tests.sh index 8eed2a6..ff4f3ab 100755 --- a/pup-tests.sh +++ b/pup-tests.sh @@ -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"