base.pp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # The base class to setup the common things.
  2. # This is a private class and will always be used
  3. # throught the sshd class itself.
  4. class sshd::base {
  5. $sshd_config_content = $::operatingsystem ? {
  6. 'CentOS' => template("sshd/sshd_config/${::operatingsystem}_${::operatingsystemmajrelease}.erb"),
  7. default => $::lsbdistcodename ? {
  8. '' => template("sshd/sshd_config/${::operatingsystem}.erb"),
  9. default => template("sshd/sshd_config/${::operatingsystem}_${::lsbdistcodename}.erb")
  10. }
  11. }
  12. file { 'sshd_config':
  13. ensure => present,
  14. path => '/etc/ssh/sshd_config',
  15. content => $sshd_config_content,
  16. notify => Service[sshd],
  17. owner => root,
  18. group => 0,
  19. mode => '0600';
  20. }
  21. # Now add the key, if we've got one
  22. case $::sshrsakey {
  23. '': { info("no sshrsakey on ${::fqdn}") }
  24. default: {
  25. @@sshkey{$::fqdn:
  26. ensure => present,
  27. tag => 'fqdn',
  28. type => ssh-rsa,
  29. key => $::sshrsakey,
  30. }
  31. # In case the node has uses a shared network address,
  32. # we don't define a sshkey resource using an IP address
  33. if $sshd::shared_ip == 'no' {
  34. @@sshkey{$sshd::sshkey_ipaddress:
  35. ensure => present,
  36. tag => 'ipaddress',
  37. type => ssh-rsa,
  38. key => $::sshrsakey,
  39. }
  40. }
  41. }
  42. }
  43. service{'sshd':
  44. ensure => running,
  45. name => 'sshd',
  46. enable => true,
  47. hasstatus => true,
  48. require => File[sshd_config],
  49. }
  50. }