diff --git a/amanda/lib/facter/amanda.rb b/amanda/lib/facter/amanda.rb new file mode 100644 index 0000000..2b6ba96 --- /dev/null +++ b/amanda/lib/facter/amanda.rb @@ -0,0 +1,27 @@ +Facter.add('amanda_serverkey') do + setcode do + begin + match = File.read('/var/lib/amanda/.ssh/id_rsa_amdump.pub')[/^ssh-rsa ([^ ]+)/, 1] + if match + data = match + end + rescue + data = '' + end + data + end +end + +Facter.add('amanda_clientkey') do + setcode do + begin + match = File.read('/var/lib/amanda/.ssh/id_rsa_amrecover.pub')[/^ssh-rsa ([^ ]+)/, 1] + if match + data = match + end + rescue + data = '' + end + data + end +end diff --git a/amanda/manifests/init.pp b/amanda/manifests/init.pp new file mode 100644 index 0000000..0485491 --- /dev/null +++ b/amanda/manifests/init.pp @@ -0,0 +1,90 @@ +class amanda::common { + + file { "/var/lib/amanda/.ssh": + ensure => directory, + mode => 0700, + owner => amandabackup, + group => disk, + } + + file { "/var/lib/amanda/.ssh/authorized_keys": + ensure => present, + mode => 0600, + owner => amandabackup, + group => disk, + require => File["/var/lib/amanda/.ssh"], + } + +} + + +class amanda::client inherits amanda::common { + + if !$amanda_server { + fail("\$amanda_server must be defined.") + } + + if !$amanda_client { + $amanda_client = $ipaddress + } + + include inetd::server + + package { "amanda-enterprise-backup-client": + ensure => installed, + before => File["/var/lib/amanda/.ssh"], + require => Class["inetd::server"], + } + + file { [ "/etc/xinetd.d/amandaclient", + "/etc/xinetd.d/zmrecover", ]: + ensure => absent, + notify => Service["xinetd"], + require => Package["amanda-enterprise-backup-client"], + } + + file { "/etc/amanda/amanda-client.conf": + ensure => present, + mode => 0644, + owner => amandabackup, + group => disk, + content => template("amanda/amanda-client.conf.erb"), + require => Package["amanda-enterprise-backup-client"], + } + + if $amanda_clientkey { + @@ssh_authorized_key { "amrecover@${homename}": + ensure => present, + key => "${amanda_clientkey}", + type => "ssh-rsa", + user => "amandabackup", + tag => "amandaclient", + options => [ "no-agent-forwarding", "no-port-forwarding", "no-X11-forwarding", + "command=\"/usr/lib/amanda/amandad -auth=ssh amindexd amidxtaped\"", + "from=\"${amanda_client}\"", ], + } + } + + Ssh_authorized_key <<| tag == "amandaserver" |>> + +} + + +class amanda::server inherits amanda::common { + + if $amanda_serverkey { + @@ssh_authorized_key { "amdump@${homename}": + ensure => present, + key => "${amanda_serverkey}", + type => "ssh-rsa", + user => "amandabackup", + tag => "amandaserver", + options => [ "no-agent-forwarding", "no-port-forwarding", "no-X11-forwarding", + "command=\"/usr/lib/amanda/amandad -auth=ssh amdump\"", + "from=\"${amanda_server}\"", ], + } + } + + Ssh_authorized_key <<| tag == "amandaclient" |>> + +} diff --git a/amanda/templates/amanda-client.conf.erb b/amanda/templates/amanda-client.conf.erb new file mode 100644 index 0000000..64a10e8 --- /dev/null +++ b/amanda/templates/amanda-client.conf.erb @@ -0,0 +1,9 @@ +# amanda.conf - sample Amanda client configuration file. +# +# This file normally goes in /etc/amanda/amanda-client.conf. +# + +index_server "<%= amanda_server %>" +tape_server "<%= amanda_server %>" +auth "ssh" +ssh_keys "/var/lib/amanda/.ssh/id_rsa_amrecover"