Advertisement
Guest User

puppet_class profile::fail2ban

a guest
Jul 13th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Puppet 1.92 KB | None | 0 0
  1. class profile::fail2ban {
  2.   include ::fail2ban
  3.   file { ['/etc/fail2ban/fail2ban.local','/etc/fail2ban/jail.local']:
  4.     ensure => absent,
  5.     notify => Service[$fail2ban::service_name],
  6.   }
  7.  
  8.   file_line { '/etc/fail2ban/fail2ban.conf':
  9.     ensure  => present,
  10.     line    => 'logtarget = SYSLOG',
  11.     match   => 'logtarget = /var/log/fail2ban.log',
  12.     path    => '/etc/fail2ban/fail2ban.conf',
  13.     require => Package[$fail2ban::package_name],
  14.     notify  => Service[$fail2ban::service_name],
  15.   }
  16.  
  17.   if $cms == 'wp' {
  18.  
  19.     $wp_nginx_blocked = @(EOF)
  20.     [Definition]
  21.     failregex = ^.* Blocked request from <HOST>.*$
  22.     ignoreregex =
  23.     | EOF
  24.     file { '/etc/fail2ban/filter.d/wp_nginx_blocked.conf':
  25.       content => inline_template($wp_nginx_blocked),
  26.       ensure  => present,
  27.       group   => root,
  28.       mode    => '0644',
  29.       owner   => root,
  30.       require => Package[$fail2ban::package_name],
  31.       notify  => Service[$fail2ban::service_name],
  32.     }
  33.  
  34.     $wplogin_conf = @(EOF)
  35.     [Definition]
  36.     failregex = {*\"remote_addr\": \"<HOST>\",.*\"request\":\ \"POST\ \/*wp-login.php
  37.    ignoreregex =
  38.    | EOF
  39.    file { '/etc/fail2ban/filter.d/wplogin.conf':
  40.      content => inline_template($wplogin_conf),
  41.      ensure  => present,
  42.      group   => root,
  43.      mode    => '0644',
  44.      owner   => root,
  45.      require => Package[$fail2ban::package_name],
  46.      notify  => Service[$fail2ban::service_name],
  47.    }
  48.  
  49.    $wp_xmlrpc_conf = @(EOF)
  50.    [Definition]
  51.    failregex = {*\"remote_addr\": \"<HOST>\",.*\"request\":\ \"POST\ \/*xmlrpc.php
  52.    ignoreregex =
  53.    | EOF
  54.    file { '/etc/fail2ban/filter.d/wp_xmlrpc.conf':
  55.      content => inline_template($wp_xmlrpc_conf),
  56.      ensure  => present,
  57.      group   => root,
  58.      mode    => '0644',
  59.      owner   => root,
  60.      require => Package[$fail2ban::package_name],
  61.      notify  => Service[$fail2ban::service_name],
  62.    }
  63.  }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement