class elastic::kibana {
  contain elastic::kibana::install
  contain elastic::kibana::config
  contain elastic::kibana::service
}

class elastic::kibana::install {
  file { '/opt/kibana':
    ensure => directory
  }

  file { '/opt/kibana/kibana.deb':
    ensure => file,
    source => 'https://artifacts.elastic.co/downloads/kibana/kibana-7.10.2-amd64.deb'
  } ~>
  package { 'kibana':
    provider => dpkg,
    source => "/opt/kibana/kibana.deb"
  }
}

class elastic::kibana::config {
  file { '/etc/kibana/kibana.yml':
    ensure => file,
    content => template('elastic/kibana.yml.erb'),
    notify => Service['kibana']
  }
}

class elastic::kibana::service {
  service { 'kibana':
    ensure => running,
    enable => true
  }
}
