Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

initial kafka support for puppet beaver #23

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
$respawn_delay = 3,
$max_failure = 7,
$hostname = $::fqdn,
$transport = 'redis'
$transport = 'redis',
$logstash_version = 0,
) inherits beaver::params {

#### Validate parameters
Expand Down Expand Up @@ -145,13 +146,17 @@
fail("\"${max_failure}\" is not a valid max_failure parameter value")
}

if ! is_numeric($logstash_version) {
fail("\"${logstash_version}\" is not a valid logstash_version parameter value")
}

validate_string($hostname)

if ! ($transport in [ 'redis', 'rabbitmq', 'zmq', 'udp', 'mqtt', 'sqs' ]) {
if ! ($transport in [ 'redis', 'rabbitmq', 'zmq', 'udp', 'mqtt', 'sqs', 'kafka' ]) {
fail("\"${transport}\" is not a valid transport parameter value")
}

$config = "hostname: ${hostname}\nformat: ${format}\nrespawn_delay: ${respawn_delay}\nmax_failure: ${max_failure}\ntransport: ${transport}"
$config = "hostname: ${hostname}\nformat: ${format}\nrespawn_delay: ${respawn_delay}\nmax_failure: ${max_failure}\ntransport: ${transport}\nlogstash_version: ${logstash_version}"

#### Manage actions

Expand Down
75 changes: 75 additions & 0 deletions manifests/output/kafka.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# == Define: beaver::output::kafka
#
# send events to a kafka broker
#
#
# === Parameters
#
# [*host*]
# Kafka host to submit to
# Value type is string
# This variable is mandatory
#
# [*port*]
# Kafka port number
# Value type is number
# Default value: 9092
# This variable is optional
#
# [*topic*]
# Kafka topic
# Value type is string
# Default value: logstash-topic
# This variable is optional
#
# [*client_id*]
# Kafka client id
# Value type is string
# Default value: beaver-kafka
# This variable is optional

# === Examples
#
# beaver::output::kafka{'kafkaout':
# host => 'kafkahost'
# }
#
# === Authors
#
# * Michael Gaber <mailto:[email protected]>
#
define beaver::output::kafka(
$host,
$port = 9092,
$topic = 'logstash-topic',
$client_id = 'beaver-kafka'
) {

#### Validate parameters
if $host {
validate_string($host)
}

if ! is_numeric($port) {
fail("\"${port}\" is not a valid port parameter value")
}

$opt_host = "kafka_host: ${host}:${port}\n"

validate_string($topic)

$opt_topic = "kafka_topic: ${topic}\n"

validate_string($client_id)

$opt_client_id = "kafka_client_id: ${client_id}\n"

#### Create file fragment

file_fragment{ "output_kafka_${::fqdn}":
tag => "beaver_config_${::fqdn}",
content => "{opt_host}${opt_topic}${opt_client_id}\n",
order => 20
}

}
5 changes: 3 additions & 2 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

#### Package management

include python
if $beaver::manage_python {
include python
}

# set params: in operation
if $beaver::ensure == 'present' {
Expand Down Expand Up @@ -57,5 +59,4 @@
provider => 'pip',
require => Class['python'],
}

}
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
# service status
$status = 'enabled'

# manage python package
$manage_python = true

#### Internal module values

# packages
Expand Down