LinuDan

Puppet-tripwire

Oct 31st, 2015
520
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. modules/tripwire/manifests/init.pp
  2. #= Class: tripwire
  3. #
  4. # Manages tripwire
  5. #
  6. #= Usage:
  7. # include tripwire (in default nodes)
  8. #
  9. # Notes:
  10. #- Loads TWeagent rpm
  11. #- Copies in a chkconfig aware variation of /etc/init.d/twdaemon
  12. #- Runs a configuration script
  13. #
  14. class tripwire (
  15.     $servername = '',
  16.     $port       = '',
  17.     $password   = '',
  18.  
  19. ) {
  20.  
  21.     include stdlib
  22.  
  23.     package { 'TWeagent':
  24.         ensure => 'installed'
  25.     }
  26.  
  27.     exec { 'configureTripwire':
  28.         command => "/usr/local/tripwire/te/agent/bin/twconfig postInstallConfig --server-host ${servername} --server-port ${port} --passphrase ${password}",
  29.         unless  => '/bin/grep -qF chkconfig /etc/init.d/twdaemon',
  30.         require => Package['TWeagent'],
  31.     }
  32.  
  33.     file { '/etc/init.d/twdaemon':
  34.         ensure  => present,
  35.         path    => '/etc/init.d/twdaemon',
  36.         mode    => '0744',
  37.         owner   => 'root',
  38.         group   => 'root',
  39.         require => Exec['configureTripwire'],
  40.         source  => 'puppet:///modules/tripwire/chkconfigAware-twdaemon'
  41.     }
  42.  
  43.     service { 'twdaemon':
  44.         ensure     => 'running',
  45.         enable     => true,
  46.         hasstatus  => true,
  47.         hasrestart => true,
  48.         require    => File['/etc/init.d/twdaemon'],
  49.     }
  50.  
  51.     $tw_servers = hiera_hash ( 'tripwire_servers', {} )
  52.  
  53.     if ! empty( $tw_servers ) {
  54.         create_resources ( tripwire::server, $tw_servers )
  55.     }
  56. }
  57.  
  58. modules/tripwire/files/chkconfigAware-twdaemon
  59. #!/bin/sh
  60. #
  61. # chkconfig: 235 95 95
  62. # description: Tripwire daemon
  63. #
  64. /usr/local/tripwire/te/agent/bin/twdaemon "$@"
RAW Paste Data