]> gitweb.fluxo.info Git - puppet-sshd.git/commitdiff
merged with riseup module, various cleaning up
authormh <mh@immerda.ch>
Thu, 10 Dec 2009 22:15:07 +0000 (23:15 +0100)
committermh <mh@immerda.ch>
Thu, 10 Dec 2009 22:15:07 +0000 (23:15 +0100)
1  2 
manifests/base.pp
manifests/client/base.pp
manifests/client/debian.pp
manifests/client/linux.pp
manifests/debian.pp
manifests/gentoo.pp
manifests/init.pp
manifests/linux.pp
manifests/ssh_authorized_key.pp
templates/sshd_config/CentOS.erb

index b24997469b8143fc97ca77b212c063fedbb4e73e,0000000000000000000000000000000000000000..2ac238505318d28bdc3cdeca7847b87ee8d55b75
mode 100644,000000..100644
--- /dev/null
@@@ -1,31 -1,0 +1,35 @@@
-     file { 'sshd_config':
-         path => '/etc/ssh/sshd_config',
-         owner => root,
-         group => 0,
-         mode => 600,
-         content => $lsbdistcodename ? {
-           '' => template("sshd/sshd_config/${operatingsystem}.erb"),
-           default => template ("sshd/sshd_config/${operatingsystem}_${lsbdistcodename}.erb"),
-         },
-         notify => Service[sshd],
-     }
-     # Now add the key, if we've got one
-     case $sshrsakey_key {
-         '': { info("no sshrsakey on $fqdn") }
-         default: {
-             @@sshkey{"$hostname.$domain":
-                 type => ssh-rsa,
-                 key => $sshrsakey_key,
-                 ensure => present,
-             }
-         }
-     }
-     service{'sshd':
-         name => 'sshd',
-         enable => true,
-         ensure => running,
-         hasstatus => true,
-                   require => File[sshd_config],
 +class sshd::base {     
++  file { 'sshd_config':
++    path => '/etc/ssh/sshd_config',
++    content => $lsbdistcodename ? {
++      '' => template("sshd/sshd_config/${operatingsystem}.erb"),
++      default => template ("sshd/sshd_config/${operatingsystem}_${lsbdistcodename}.erb"),
++    },
++    notify => Service[sshd],
++    owner => root, group => 0, mode => 600;
++  }
++
++  # Now add the key, if we've got one
++  case $sshrsakey_key {
++    '': { info("no sshrsakey on $fqdn") }
++    default: {
++      @@sshkey{"$hostname.$domain":
++        type => ssh-rsa,
++        key => $sshrsakey_key,
++        ensure => present,
++      }
++      @@sshkey{"$ipaddress":
++        type => ssh-rsa,
++        key => $sshrsakey,
++        ensure => present,
++      }
 +    }
++  }
++  service{'sshd':
++    name => 'sshd',
++    enable => true,
++    ensure => running,
++    hasstatus => true,
++    require => File[sshd_config],
++  }
 +}
index 2c3e31f084f5353d8d70915c2005950cea74ecd4,0000000000000000000000000000000000000000..33d9f9e17e7d97fba92ee795fb583c1289c39925
mode 100644,000000..100644
--- /dev/null
@@@ -1,9 -1,0 +1,9 @@@
-     # this is needed because the gid might have changed
-     file { '/etc/ssh/ssh_known_hosts':
-             mode => 0644, owner => root, group => 0;
-     }
 +class sshd::client::base {
-     # Now collect all server keys
-     Sshkey <<||>>
++  # this is needed because the gid might have changed
++  file { '/etc/ssh/ssh_known_hosts':
++    owner => root, group => 0, mode => 0644;
++  }
 +
++  # Now collect all server keys
++  Sshkey <<||>>
 +}
index 9ca6da9737115ac6c1e53166cde8f2513522f0e6,0000000000000000000000000000000000000000..2aaf3fb1a6d7a6e2c4ea21d6b0c0ffd70d1ec1aa
mode 100644,000000..100644
--- /dev/null
@@@ -1,5 -1,0 +1,5 @@@
-     Package['openssh-clients']{
-         name => 'openssh-client',
-     }
 +class sshd::client::debian inherits sshd::client::linux {
++  Package['openssh-clients']{
++    name => 'openssh-client',
++  }
 +}
index 522fa507134e9fbceaef32ee278f5c66bf83dc87,0000000000000000000000000000000000000000..8c58ca85ff20fd22f033ede456fa28d9bc84d2ac
mode 100644,000000..100644
--- /dev/null
@@@ -1,5 -1,0 +1,6 @@@
-     package {'openssh-clients':
-         ensure => installed,
-     }
 +class sshd::client::linux inherits sshd::client::base {
++  if $ssh_ensure_version == '' { $ssh_ensure_version = 'installed' }
++  package {'openssh-clients':
++    ensure => $ssh_ensure_version,
++  }
 +}
index 528779c10131473bc542395e894afc45afbc866b,0000000000000000000000000000000000000000..849d9f4671fe20379a236b761110bf3fcb8b5189
mode 100644,000000..100644
--- /dev/null
@@@ -1,16 -1,0 +1,25 @@@
-     require => Package['lsb']
 +class sshd::debian inherits sshd::linux {
 +
 +  # the templates for Debian need lsbdistcodename
 +  include lsb
 +  File['sshd_config']{
-     hasstatus => false,
++    require +> Package['lsb']
 +  }
 +
 +  Package[openssh]{
 +    name => 'openssh-server',
 +  }
++
++  $sshd_restartandstatus = $lsbdistcodename ? {
++    etch => false,
++    lenny => true,
++    default => false
++  }
++
 +  Service[sshd]{
 +    name => 'ssh',
++    pattern => 'sshd',
++    hasstatus => $sshd_restartandstatus,
++    hasrestart => $sshd_restartandstatus,
 +  }
 +}
index f56a96d482be9434a71974ff6f67e93acab34613,0000000000000000000000000000000000000000..631f3d19830177085d9af1a7a956badc910d38a2
mode 100644,000000..100644
--- /dev/null
@@@ -1,5 -1,0 +1,5 @@@
-     Package[openssh]{
-         category => 'net-misc',
-     }
 +class sshd::gentoo inherits sshd::linux {
++  Package[openssh]{
++    category => 'net-misc',
++  }
 +}
index 8489a6a6b1a9047379aac942601f10596066522e,386bd7783d946290db4bb5aed97972cd54c0ba40..83b26c18ee809ba0550ec3b97f23a7b2d6a31287
  #                       Might be interesting for sftponly usage
  #                       Default: empty -> no change of the default
  #
- # sshd_additional_options:  Set this to any additional sshd_options which aren't listed above.
- #                           As well this option might be usefull to define complexer Match Blocks
- #                           This string is going to be included, like it is defined. So take care!
- #                           Default: empty -> not added.
+ # sshd_head_additional_options:  Set this to any additional sshd_options which aren't listed above.
+ #                                Anything set here will be added to the beginning of the sshd_config file.
+ #                                This option might be useful to define complicated Match Blocks
+ #                                This string is going to be included, like it is defined. So take care!
+ #                                Default: empty -> not added.
+ #
+ # sshd_tail_additional_options:  Set this to any additional sshd_options which aren't listed above.
+ #                                Anything set here will be added to the end of the sshd_config file.
+ #                                This option might be useful to define complicated Match Blocks
+ #                                This string is going to be included, like it is defined. So take care!
+ #                                Default: empty -> not added.
  
  class sshd {
-     # prepare variables to use in templates
-     case $sshd_listen_address {
-       '': { $sshd_listen_address = [ '0.0.0.0', '::' ] }
-     }
-     case $sshd_allowed_users {
-         '': { $sshd_allowed_users = '' }
-     }
-     case $sshd_allowed_groups {
-       '': { $sshd_allowed_groups = '' }
-     }
-     case $sshd_use_pam {
-         '': { $sshd_use_pam = 'no' }
-     }
-     case $sshd_permit_root_login {
-         '': { $sshd_permit_root_login = 'without-password' }
-     }
-     case $sshd_password_authentication {
-         '': { $sshd_password_authentication = 'no' }
-     }
-     case $sshd_tcp_forwarding {
-       '': { $sshd_tcp_forwarding = 'no' }
-     }
-     case $sshd_x11_forwarding {
-         '': { $sshd_x11_forwarding = 'no' }
-     }
-     case $sshd_agent_forwarding {
-       '': { $sshd_agent_forwarding = 'no' }
-     }
-     case $sshd_challenge_response_authentication {
-         '': { $sshd_challenge_response_authentication = 'no' }
-     }
-     case $sshd_pubkey_authentication {
-       '': { $sshd_pubkey_authentication = 'yes' }
-     }
-     case $sshd_rsa_authentication {
-       '': { $sshd_rsa_authentication = 'no' }
-     }
-     case $sshd_strict_modes {
-       '': { $sshd_strict_modes = 'yes' }
-     }
-     case $sshd_ignore_rhosts {
-         '': { $sshd_ignore_rhosts = 'yes' }
-     }
-     case $sshd_rhosts_rsa_authentication {
-       '': { $sshd_rhosts_rsa_authentication = 'no' }
-     }
-     case $sshd_hostbased_authentication {
-       '': { $sshd_hostbased_authentication = 'no' }
-     }
-     case $sshd_permit_empty_passwords {
-       '': { $sshd_permit_empty_passwords = 'no' }
-     }
-     case $sshd_port {
-       '': { $sshd_port = 22 }
-     }
-     case $sshd_authorized_keys_file {
-       '': { $sshd_authorized_keys_file = "%h/.ssh/authorized_keys" }
-     }
-     case $sshd_sftp_subsystem {
-         '': { $sshd_sftp_subsystem = '' }
-     }
-     case $sshd_additional_options {
-         '': { $sshd_additional_options = '' }
-     }
-  
-     include sshd::client 
 -  include sshd::client 
 -  
 -  case $operatingsystem {
 -    gentoo: { include sshd::gentoo }
 -    redhat: { include sshd::redhat }
 -    centos: { include sshd::centos }
 -    openbsd: { include sshd::openbsd }
 -    debian: { include sshd::debian }
 -    ubuntu: { include sshd::ubuntu }
 -    default: { include sshd::default }
 -  }
 -}
 -
 -
 -class sshd::base {
 -  # prepare variables to use in templates
++   # prepare variables to use in templates
+   case $sshd_listen_address {
+     '': { $sshd_listen_address = [ '0.0.0.0', '::' ] }
+   }
+   case $sshd_allowed_users {
+     '': { $sshd_allowed_users = '' }
+   }
+   case $sshd_allowed_groups {
+     '': { $sshd_allowed_groups = '' }
+   }
+   case $sshd_use_pam {
+     '': { $sshd_use_pam = 'no' }
+   }
+   case $sshd_permit_root_login {
+     '': { $sshd_permit_root_login = 'without-password' }
+   }
+   case $sshd_password_authentication {
+     '': { $sshd_password_authentication = 'no' }
+   }
+   case $sshd_tcp_forwarding {
+     '': { $sshd_tcp_forwarding = 'no' }
+   }
+   case $sshd_x11_forwarding {
+     '': { $sshd_x11_forwarding = 'no' }
+   }
+   case $sshd_agent_forwarding {
+     '': { $sshd_agent_forwarding = 'no' }
+   }
+   case $sshd_challenge_response_authentication {
+     '': { $sshd_challenge_response_authentication = 'no' }
+   }
+   case $sshd_pubkey_authentication {
+     '': { $sshd_pubkey_authentication = 'yes' }
+   }
+   case $sshd_rsa_authentication {
+     '': { $sshd_rsa_authentication = 'no' }
+   }
+   case $sshd_strict_modes {
+     '': { $sshd_strict_modes = 'yes' }
+   }
+   case $sshd_ignore_rhosts {
+     '': { $sshd_ignore_rhosts = 'yes' }
+   }
+   case $sshd_rhosts_rsa_authentication {
+     '': { $sshd_rhosts_rsa_authentication = 'no' }
+   }
+   case $sshd_hostbased_authentication {
+     '': { $sshd_hostbased_authentication = 'no' }
+   }
+   case $sshd_permit_empty_passwords {
+     '': { $sshd_permit_empty_passwords = 'no' }
+   }
+   case $sshd_port {
+     '': { $sshd_port = 22 }
+   }
+   case $sshd_authorized_keys_file {
+     '': { $sshd_authorized_keys_file = "%h/.ssh/authorized_keys" }
+   }
+   case $sshd_sftp_subsystem {
+     '': { $sshd_sftp_subsystem = '' }
+   }
+   case $sshd_head_additional_options {
+     '': { $sshd_head_additional_options = '' }
+   }
+   case $sshd_tail_additional_options {
+     '': { $sshd_tail_additional_options = '' }
+   }
+   case $sshd_ensure_version {
+     '': { $sshd_ensure_version = "present" }
+   }
  
-     case $operatingsystem {
-         gentoo: { include sshd::gentoo }
-         redhat,centos: { include sshd::redhat }
-         centos: { include sshd::centos }
-         openbsd: { include sshd::openbsd }
-         debian,ubuntu: { include sshd::debian }
-         default: { include sshd::default }
 -  file { 'sshd_config':
 -    path => '/etc/ssh/sshd_config',
 -    owner => root,
 -    group => 0,
 -    mode => 600,
 -    content => $lsbdistcodename ? {
 -      '' => template("sshd/sshd_config/${operatingsystem}.erb"),
 -      default => template ("sshd/sshd_config/${operatingsystem}_${lsbdistcodename}.erb"),
 -      },
 -      notify => Service[sshd],
 -  }
 -  # Now add the key, if we've got one
 -  case $sshrsakey {
 -    '': { warning("no sshrsakey on $fqdn") }
 -    default: {
 -      @@sshkey{"$hostname.$domain":
 -        type => ssh-rsa,
 -        key => $sshrsakey,
 -        ensure => present,
 -      }
 -      @@sshkey{"$ipaddress":
 -        type => ssh-rsa,
 -        key => $sshrsakey,
 -        ensure => present,
 -      }
--    }
 -  }
 -  service{'sshd':
 -    name => 'sshd',
 -    enable => true,
 -    ensure => running,
 -    hasstatus => true,
 -    require => File[sshd_config],
++  include sshd::client 
 +
-     if $use_nagios {
-         if $nagios_check_ssh {
-             nagios::service{ "ssh_${fqdn}_port_${sshd_port}": check_command => "ssh_port!$sshd_port" }
-         }
-     }
++  case $operatingsystem {
++    gentoo: { include sshd::gentoo }
++    redhat,centos: { include sshd::redhat }
++    centos: { include sshd::centos }
++    openbsd: { include sshd::openbsd }
++    debian,ubuntu: { include sshd::debian }
++    default: { include sshd::default }
+   }
 -  
 +
-     if $use_shorewall{
-       include shorewall::rules::ssh
+   if $use_nagios {
+     case $nagios_check_ssh {
+       'false': { info("We don't do nagioschecks for ssh on ${fqdn}" ) }
+       default: { nagios::service{ "ssh_${fqdn}_port_${sshd_port}": check_command => "ssh_port!$sshd_port" } }
      }
+   }
  }
 -
 -class sshd::linux inherits sshd::base {
 -  if $sshd_ensure_version == '' { $sshd_ensure_version = 'installed' }
 -     package {'openssh':
 -         ensure => $sshd_ensure_version,
 -  }
 -  File[sshd_config]{
 -    require +> Package[openssh],
 -  }
 -}
 -
 -class sshd::gentoo inherits sshd::linux {
 -  Package[openssh]{
 -    category => 'net-misc',
 -  }
 -}
 -
 -class sshd::debian inherits sshd::linux {
 -  
 -  # the templates for Debian need lsbdistcodename
 -  include assert_lsbdistcodename
 -  
 -  Package[openssh]{
 -    name => 'openssh-server',
 -  }
 -
 -  $sshd_restartandstatus = $lsbdistcodename ? {
 -    etch => false,
 -    lenny => true,
 -    default => false
 -  }
 -
 -  Service[sshd]{
 -    name => 'ssh',
 -    pattern => 'sshd',
 -    hasstatus => $sshd_restartandstatus,
 -    hasrestart => $sshd_restartandstatus,
 -  }
 -}
 -class sshd::ubuntu inherits sshd::debian {}
 -
 -class sshd::redhat inherits sshd::linux {
 -  Package[openssh]{
 -    name => 'openssh-server',
 -  }
 -}
 -class sshd::centos inherits sshd::redhat {}
 -
 -class sshd::openbsd inherits sshd::base {
 -  Service[sshd]{
 -    restart => '/bin/kill -HUP `/bin/cat /var/run/sshd.pid`',
 -    stop => '/bin/kill `/bin/cat /var/run/sshd.pid`',
 -    start => '/usr/sbin/sshd',
 -    hasstatus => false,
 -  }
 -}
 -
 -### defines 
 -# wrapper to have some defaults.
 -define sshd::ssh_authorized_key(
 -  $type = 'ssh-dss',
 -  $key,
 -  $user = '',
 -  $target = undef,
 -  $options = 'absent'
 -  )
 -{
 -  $real_user = $user ? {
 -    false => $name,
 -    "" => $name,
 -    default => $user,
 -   }
 -  case $target {
 -    undef: {
 -      $real_target = "/home/$real_user/.ssh/authorized_keys"
 -    }
 -    default: {
 -      $real_target = $target
 -    }
 -  }
 -  ssh_authorized_key{$name:
 -    type => $type,
 -    key => $key,
 -    user => $real_user,
 -    target => $real_target,
 -  }
 -  
 -  case $options {
 -    'absent': { info("not setting any option for ssh_authorized_key: $name") }
 -    default: {
 -      Ssh_authorized_key[$name]{
 -        options => $options,
 -      }
 -    }
 -  }
 -}
index f659808abd6e6711eebf87ad985b9e35208b5fb3,0000000000000000000000000000000000000000..a1f4e2a449d3bb57b798cbb00008c40cff9b869d
mode 100644,000000..100644
--- /dev/null
@@@ -1,8 -1,0 +1,8 @@@
-     package{openssh:
-       ensure => present,
 +class sshd::linux inherits sshd::base {
-     File[sshd_config]{
-         require +> Package[openssh],
-     }
++  package{openssh:
++    ensure => $sshd_ensure_version,
++  }
++  File[sshd_config]{
++    require +> Package[openssh],
 +  }
 +}
index 2d528da16ab19b6e70a2468d071c881fcfa13bba,0000000000000000000000000000000000000000..9374e154ae222102faf267b745b78d4aafc62ce0
mode 100644,000000..100644
--- /dev/null
@@@ -1,36 -1,0 +1,42 @@@
-     $target = 'absent',
 +# wrapper to have some defaults.
 +define sshd::ssh_authorized_key(
 +    $type = 'ssh-dss',
 +    $key,
 +    $user = 'root',
-     case $target {
-         'absent': {
-             case $user {
-                 'root': { $real_target = '/root/.ssh/authorized_keys' }
-                 default: { $real_target = "/home/${user}/.ssh/authorized_keys" }
-             }
-         }
-         default: {
-             $real_target = $target
-         }
++    $target = undef,
 +    $options = 'absent'
 +){
 +
-     ssh_authorized_key{$name:
-         type => $type,
-         key => $key,
-         user => $user,
-         target => $real_target,
++  $real_user = $user ? {
++    false => $name,
++    "" => $name,
++    default => $user,
++  }
++
++  case $target {
++    undef: {
++      case $user {
++        'root': { $real_target = '/root/.ssh/authorized_keys' }
++        default: { $real_target = "/home/${user}/.ssh/authorized_keys" }
++      }
 +    }
-     case $options {
-         'absent': { info("not setting any option for ssh_authorized_key: $name") }
-         default: {
-             Ssh_authorized_key[$name]{
-                 options => $options,
-             }
-         }
++    default: {
++      $real_target = $target
 +    }
++  }
++  ssh_authorized_key{$name:
++    type => $type,
++    key => $key,
++    user => $real_user,
++    target => $real_target,
++  }
 +
++  case $options {
++    'absent': { info("not setting any option for ssh_authorized_key: $name") }
++    default: {
++      Ssh_authorized_key[$name]{
++        options => $options,
++      }
 +    }
++  }
 +}
index fcaf4d67d26f59b407996f4d5c9acdb031af94aa,bc5256ae5e7fd31f37ddfdf4ced810e95cf40894..a253029dfd5d0d27c335692fa8f6e7d7ee85db4c
@@@ -186,21 -194,21 +191,19 @@@ X11Forwarding n
  #Banner /some/path
  
  # override default of no subsystems
 -<%- if sshd_sftp_subsystem.to_s.empty? then %>
 +<%- if sshd_sftp_subsystem.to_s.empty? then -%>
  Subsystem     sftp    /usr/libexec/openssh/sftp-server
 -<%- else %>
 +<%- else -%>
  Subsystem      sftp    <%= sshd_sftp_subsystem %>
 -<%- end %>
 +<%- end -%>
  
 -<%- unless sshd_allowed_users.to_s.empty? then %>
 +<%- unless sshd_allowed_users.to_s.empty? then -%>
  AllowUsers <%= sshd_allowed_users %>
 -<%- end %>
 -<%- unless sshd_allowed_groups.to_s.empty? then %>
 +<%- end -%>
 +<%- unless sshd_allowed_groups.to_s.empty? then -%>
  AllowGroups <%= sshd_allowed_groups %>
 -<%- end %>
 -
 +<%- end -%>
  
- <%- unless sshd_additional_options.to_s.empty? then -%>
- <%= sshd_additional_options %>
- <%- end -%>
+ <%- unless sshd_tail_additional_options.to_s.empty? then %>
+ <%= sshd_tail_additional_options %>
+ <%- end %>
 -