diff --git a/REFERENCE.md b/REFERENCE.md index b9bcdc5..d9ce130 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,1572 +1,1612 @@ # Reference ## Table of Contents **Classes** _Public Classes_ * [`kafka`](#kafka): This class handles the Kafka requirements. * [`kafka::broker`](#kafkabroker): This class handles the Kafka (broker). * [`kafka::consumer`](#kafkaconsumer): This class handles the Kafka (consumer). * [`kafka::consumer::config`](#kafkaconsumerconfig): This class handles the Kafka (consumer) config. * [`kafka::mirror`](#kafkamirror): This class handles the Kafka (mirror). * [`kafka::params`](#kafkaparams): This class provides default parameters. * [`kafka::producer`](#kafkaproducer): This class handles the Kafka (producer). * [`kafka::producer::config`](#kafkaproducerconfig): This class handles the Kafka (producer) config. _Private Classes_ * `kafka::broker::config`: This class handles the Kafka (broker) config. * `kafka::broker::install`: This class handles the Kafka (broker) package. * `kafka::broker::service`: This class handles the Kafka (broker) service. * `kafka::consumer::install`: This class handles the Kafka (consumer) package. * `kafka::consumer::service`: This class handles the Kafka (consumer) service. * `kafka::mirror::config`: This class handles the Kafka (mirror) config. * `kafka::mirror::install`: This class handles the Kafka (mirror) package. * `kafka::mirror::service`: This class handles the Kafka (mirror) service. * `kafka::producer::install`: This class handles the Kafka (producer) package. * `kafka::producer::service`: This class handles the Kafka (producer) service. **Defined types** * [`kafka::topic`](#kafkatopic): This defined type handles the creation of Kafka topics. ## Classes ### kafka This class handles the Kafka requirements. #### Examples ##### Basic usage ```puppet class { 'kafka': } ``` #### Parameters The following parameters are available in the `kafka` class. ##### `kafka_version` Data type: `String[1]` The version of Kafka that should be installed. Default value: $kafka::params::kafka_version ##### `scala_version` Data type: `String[1]` The scala version what Kafka was built with. Default value: $kafka::params::scala_version ##### `install_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka to. Default value: $kafka::params::install_dir ##### `mirror_url` Data type: `Stdlib::HTTPUrl` The url where the Kafka is downloaded from. Default value: $kafka::params::mirror_url ##### `manage_java` Data type: `Boolean` Install java if it's not already installed. Default value: $kafka::params::manage_java ##### `package_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka. Default value: $kafka::params::package_dir ##### `package_name` Data type: `Optional[String[1]]` Package name, when installing Kafka from a package. Default value: $kafka::params::package_name ##### `mirror_subpath` Data type: `Optional[String[1]]` The sub directory where the source is downloaded from. Default value: $kafka::params::mirror_subpath ##### `proxy_server` Data type: `Optional[String[1]]` Set proxy server, when installing Kafka from source. Default value: $kafka::params::proxy_server ##### `proxy_port` Data type: `Optional[String[1]]` Set proxy port, when installing Kafka from source. Default value: $kafka::params::proxy_port ##### `proxy_host` Data type: `Optional[String[1]]` Set proxy host, when installing Kafka from source. Default value: $kafka::params::proxy_host ##### `proxy_type` Data type: `Optional[String[1]]` Set proxy type, when installing Kafka from source. Default value: $kafka::params::proxy_type ##### `package_ensure` Data type: `String[1]` Package version or ensure state, when installing Kafka from a package. Default value: $kafka::params::package_ensure ##### `user_name` Data type: `String[1]` User to run Kafka as. Default value: $kafka::params::user_name +##### `user_shell` + +Data type: `Stdlib::Absolutepath` + +Login shell of the Kafka user. + +Default value: $kafka::params::user_shell + ##### `group_name` Data type: `String[1]` Group to run Kafka as. Default value: $kafka::params::group_name ##### `system_user` Data type: `Boolean` Whether the Kafka user is a system user or not. Default value: $kafka::params::system_user ##### `system_group` Data type: `Boolean` Whether the Kafka group is a system group or not. Default value: $kafka::params::system_group ##### `user_id` Data type: `Optional[Integer]` Create the Kafka user with this ID. Default value: $kafka::params::user_id ##### `group_id` Data type: `Optional[Integer]` Create the Kafka group with this ID. Default value: $kafka::params::group_id ##### `manage_user` Data type: `Boolean` Create the Kafka user if it's not already present. Default value: $kafka::params::manage_user ##### `manage_group` Data type: `Boolean` Create the Kafka group if it's not already present. Default value: $kafka::params::manage_group ##### `config_dir` Data type: `Stdlib::Absolutepath` The directory to create the Kafka config files to. Default value: $kafka::params::config_dir ##### `log_dir` Data type: `Stdlib::Absolutepath` The directory for Kafka log files. Default value: $kafka::params::log_dir ##### `install_mode` Data type: `Stdlib::Filemode` The permissions for the install directory. Default value: $kafka::params::install_mode ### kafka::broker This class handles the Kafka (broker). #### Examples ##### Basic usage ```puppet class { 'kafka::broker': config => { 'broker.id' => '0', 'zookeeper.connect' => 'localhost:2181' } } ``` #### Parameters The following parameters are available in the `kafka::broker` class. ##### `kafka_version` Data type: `String[1]` The version of Kafka that should be installed. Default value: $kafka::params::kafka_version ##### `scala_version` Data type: `String[1]` The scala version what Kafka was built with. Default value: $kafka::params::scala_version ##### `install_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka to. Default value: $kafka::params::install_dir ##### `mirror_url` Data type: `Stdlib::HTTPUrl` The url where the Kafka is downloaded from. Default value: $kafka::params::mirror_url ##### `manage_java` Data type: `Boolean` Install java if it's not already installed. Default value: $kafka::params::manage_java ##### `package_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka. Default value: $kafka::params::package_dir ##### `package_name` Data type: `Optional[String[1]]` Package name, when installing Kafka from a package. Default value: $kafka::params::package_name ##### `package_ensure` Data type: `String[1]` Package version or ensure state, when installing Kafka from a package. Default value: $kafka::params::package_ensure ##### `user_name` Data type: `String[1]` User to run Kafka as. Default value: $kafka::params::user_name +##### `user_shell` + +Data type: `Stdlib::Absolutepath` + +Login shell of the Kafka user. + +Default value: $kafka::params::user_shell + ##### `group_name` Data type: `String[1]` Group to run Kafka as. Default value: $kafka::params::group_name ##### `user_id` Data type: `Optional[Integer]` Create the Kafka user with this ID. Default value: $kafka::params::user_id ##### `group_id` Data type: `Optional[Integer]` Create the Kafka group with this ID. Default value: $kafka::params::group_id ##### `manage_user` Data type: `Boolean` Create the Kafka user if it's not already present. Default value: $kafka::params::manage_user ##### `manage_group` Data type: `Boolean` Create the Kafka group if it's not already present. Default value: $kafka::params::manage_group ##### `config_mode` Data type: `Stdlib::Filemode` The permissions for the config files. Default value: $kafka::params::config_mode ##### `config_dir` Data type: `Stdlib::Absolutepath` The directory to create the Kafka config files to. Default value: $kafka::params::config_dir ##### `log_dir` Data type: `Stdlib::Absolutepath` The directory for Kafka log files. Default value: $kafka::params::log_dir ##### `bin_dir` Data type: `Stdlib::Absolutepath` The directory where the Kafka scripts are. Default value: $kafka::params::bin_dir ##### `service_name` Data type: `String[1]` Set the name of the service. Default value: 'kafka' ##### `manage_service` Data type: `Boolean` Install the init.d or systemd service. Default value: $kafka::params::manage_service ##### `service_ensure` Data type: `Enum['running', 'stopped']` Set the ensure state of the service. Default value: $kafka::params::service_ensure ##### `service_restart` Data type: `Boolean` Whether the configuration files should trigger a service restart. Default value: $kafka::params::service_restart ##### `service_requires` Data type: `Array[String[1]]` Set the list of services required to be running before Kafka. Default value: $kafka::params::service_requires ##### `limit_nofile` Data type: `Optional[String[1]]` Set the 'LimitNOFILE' option of the systemd service. Default value: $kafka::params::limit_nofile ##### `limit_core` Data type: `Optional[String[1]]` Set the 'LimitCORE' option of the systemd service. Default value: $kafka::params::limit_core ##### `timeout_stop` Data type: `Optional[String[1]]` Set the 'TimeoutStopSec' option of the systemd service. Default value: $kafka::params::timeout_stop ##### `exec_stop` Data type: `Boolean` Set the 'ExecStop' option of the systemd service to 'kafka-server-stop.sh'. Default value: $kafka::params::exec_stop ##### `daemon_start` Data type: `Boolean` Use the '-daemon' option when starting Kafka with 'kafka-server-start.sh'. Default value: $kafka::params::daemon_start ##### `env` Data type: `Hash` A hash of the environment variables to set. Default value: {} ##### `config` Data type: `Hash[String[1], Any]` A hash of the broker configuration options. Default value: {} ##### `heap_opts` Data type: `String[1]` Set the Java heap size. Default value: $kafka::params::broker_heap_opts ##### `jmx_opts` Data type: `String[1]` Set the JMX options. Default value: $kafka::params::broker_jmx_opts ##### `log4j_opts` Data type: `String[1]` Set the Log4j options. Default value: $kafka::params::broker_log4j_opts ##### `opts` Data type: `String[0]` Set the Kafka options. Default value: $kafka::params::broker_opts ### kafka::consumer This class handles the Kafka (consumer). #### Examples ##### Basic usage ```puppet class { 'kafka::consumer': config => { 'client.id' => '0', 'zookeeper.connect' => 'localhost:2181' } } ``` #### Parameters The following parameters are available in the `kafka::consumer` class. ##### `kafka_version` Data type: `String[1]` The version of Kafka that should be installed. Default value: $kafka::params::kafka_version ##### `scala_version` Data type: `String[1]` The scala version what Kafka was built with. Default value: $kafka::params::scala_version ##### `install_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka to. Default value: $kafka::params::install_dir ##### `mirror_url` Data type: `Stdlib::HTTPUrl` The url where the Kafka is downloaded from. Default value: $kafka::params::mirror_url ##### `manage_java` Data type: `Boolean` Install java if it's not already installed. Default value: $kafka::params::manage_java ##### `package_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka. Default value: $kafka::params::package_dir ##### `package_name` Data type: `Optional[String[1]]` Package name, when installing Kafka from a package. Default value: $kafka::params::package_name ##### `package_ensure` Data type: `String[1]` Package version or ensure state, when installing Kafka from a package. Default value: $kafka::params::package_ensure ##### `user_name` Data type: `String[1]` User to run Kafka as. Default value: $kafka::params::user_name +##### `user_shell` + +Data type: `Stdlib::Absolutepath` + +Login shell of the Kafka user. + +Default value: $kafka::params::user_shell + ##### `group_name` Data type: `String[1]` Group to run Kafka as. Default value: $kafka::params::group_name ##### `user_id` Data type: `Optional[Integer]` Create the Kafka user with this ID. Default value: $kafka::params::user_id ##### `group_id` Data type: `Optional[Integer]` Create the Kafka group with this ID. Default value: $kafka::params::group_id ##### `manage_user` Data type: `Boolean` Create the Kafka user if it's not already present. Default value: $kafka::params::manage_user ##### `manage_group` Data type: `Boolean` Create the Kafka group if it's not already present. Default value: $kafka::params::manage_group ##### `config_mode` Data type: `Stdlib::Filemode` The permissions for the config files. Default value: $kafka::params::config_mode ##### `config_dir` Data type: `Stdlib::Absolutepath` The directory to create the Kafka config files to. Default value: $kafka::params::config_dir ##### `log_dir` Data type: `Stdlib::Absolutepath` The directory for Kafka log files. Default value: $kafka::params::log_dir ##### `bin_dir` Data type: `Stdlib::Absolutepath` The directory where the Kafka scripts are. Default value: $kafka::params::bin_dir ##### `service_name` Data type: `String[1]` Set the name of the service. Default value: 'kafka-consumer' ##### `manage_service` Data type: `Boolean` Install the init.d or systemd service. Default value: $kafka::params::manage_service ##### `service_ensure` Data type: `Enum['running', 'stopped']` Set the ensure state of the service. Default value: $kafka::params::service_ensure ##### `service_restart` Data type: `Boolean` Whether the configuration files should trigger a service restart. Default value: $kafka::params::service_restart ##### `service_requires` Data type: `Array[String[1]]` Set the list of services required to be running before Kafka. Default value: $kafka::params::service_requires ##### `limit_nofile` Data type: `Optional[String[1]]` Set the 'LimitNOFILE' option of the systemd service. Default value: $kafka::params::limit_nofile ##### `limit_core` Data type: `Optional[String[1]]` Set the 'LimitCORE' option of the systemd service. Default value: $kafka::params::limit_core ##### `env` Data type: `Hash` A hash of the environment variables to set. Default value: {} ##### `config` Data type: `Hash[String[1], Any]` A hash of the consumer configuration options. Default value: {} ##### `service_config` Data type: `Hash[String[1],String[1]]` A hash of the `kafka-console-consumer.sh` script options. Default value: {} ##### `jmx_opts` Data type: `String[1]` Set the JMX options. Default value: $kafka::params::consumer_jmx_opts ##### `log4j_opts` Data type: `String[1]` Set the Log4j options. Default value: $kafka::params::consumer_log4j_opts ### kafka::consumer::config This class handles the Kafka (consumer) config. #### Parameters The following parameters are available in the `kafka::consumer::config` class. ##### `manage_service` Data type: `Boolean` Default value: $kafka::consumer::manage_service ##### `service_name` Data type: `String[1]` Default value: $kafka::consumer::service_name ##### `service_restart` Data type: `Boolean` Default value: $kafka::consumer::service_restart ##### `config` Data type: `Hash[String[1], Any]` Default value: $kafka::consumer::config ##### `config_dir` Data type: `Stdlib::Absolutepath` Default value: $kafka::consumer::config_dir ##### `user_name` Data type: `String[1]` Default value: $kafka::consumer::user_name ##### `group_name` Data type: `String[1]` Default value: $kafka::consumer::group_name ##### `config_mode` Data type: `Stdlib::Filemode` Default value: $kafka::consumer::config_mode ### kafka::mirror This class handles the Kafka (mirror). #### Examples ##### Basic usage ```puppet class { 'kafka::mirror': consumer_config => { 'group.id' => 'kafka-mirror', 'zookeeper.connect' => 'localhost:2181' }, producer_config => { 'zookeeper.connect' => 'localhost:2181', }, service_config => { 'whitelist' => '.*', } } ``` #### Parameters The following parameters are available in the `kafka::mirror` class. ##### `kafka_version` Data type: `String[1]` The version of Kafka that should be installed. Default value: $kafka::params::kafka_version ##### `scala_version` Data type: `String[1]` The scala version what Kafka was built with. Default value: $kafka::params::scala_version ##### `install_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka to. Default value: $kafka::params::install_dir ##### `mirror_url` Data type: `Stdlib::HTTPUrl` The url where the Kafka is downloaded from. Default value: $kafka::params::mirror_url ##### `manage_java` Data type: `Boolean` Install java if it's not already installed. Default value: $kafka::params::manage_java ##### `package_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka. Default value: $kafka::params::package_dir ##### `package_name` Data type: `Optional[String[1]]` Package name, when installing Kafka from a package. Default value: $kafka::params::package_name ##### `package_ensure` Data type: `String[1]` Package version or ensure state, when installing Kafka from a package. Default value: $kafka::params::package_ensure ##### `user_name` Data type: `String[1]` User to run Kafka as. Default value: $kafka::params::user_name +##### `user_shell` + +Data type: `Stdlib::Absolutepath` + +Login shell of the Kafka user. + +Default value: $kafka::params::user_shell + ##### `group_name` Data type: `String[1]` Group to run Kafka as. Default value: $kafka::params::group_name ##### `user_id` Data type: `Optional[Integer]` Create the Kafka user with this ID. Default value: $kafka::params::user_id ##### `group_id` Data type: `Optional[Integer]` Create the Kafka group with this ID. Default value: $kafka::params::group_id ##### `manage_user` Data type: `Boolean` Create the Kafka user if it's not already present. Default value: $kafka::params::manage_user ##### `manage_group` Data type: `Boolean` Create the Kafka group if it's not already present. Default value: $kafka::params::manage_group ##### `config_mode` Data type: `Stdlib::Filemode` The permissions for the config files. Default value: $kafka::params::config_mode ##### `config_dir` Data type: `Stdlib::Absolutepath` The directory to create the Kafka config files to. Default value: $kafka::params::config_dir ##### `log_dir` Data type: `Stdlib::Absolutepath` The directory for Kafka log files. Default value: $kafka::params::log_dir ##### `bin_dir` Data type: `Stdlib::Absolutepath` The directory where the Kafka scripts are. Default value: $kafka::params::bin_dir ##### `service_name` Data type: `String[1]` Set the name of the service. Default value: 'kafka-mirror' ##### `manage_service` Data type: `Boolean` Install the init.d or systemd service. Default value: $kafka::params::manage_service ##### `service_ensure` Data type: `Enum['running', 'stopped']` Set the ensure state of the service. Default value: $kafka::params::service_ensure ##### `service_restart` Data type: `Boolean` Whether the configuration files should trigger a service restart. Default value: $kafka::params::service_restart ##### `service_requires` Data type: `Array[String[1]]` Set the list of services required to be running before Kafka. Default value: $kafka::params::service_requires ##### `limit_nofile` Data type: `Optional[String[1]]` Set the 'LimitNOFILE' option of the systemd service. Default value: $kafka::params::limit_nofile ##### `limit_core` Data type: `Optional[String[1]]` Set the 'LimitCORE' option of the systemd service. Default value: $kafka::params::limit_core ##### `env` Data type: `Hash` A hash of the environment variables to set. Default value: {} ##### `consumer_config` Data type: `Hash[String[1],String[1]]` A hash of the consumer configuration options. Default value: {} ##### `producer_config` Data type: `Hash[String[1],String[1]]` A hash of the producer configuration options. Default value: {} ##### `service_config` Data type: `Hash[String[1],String[1]]` A hash of the mirror script options. Default value: {} ##### `heap_opts` Data type: `String[1]` Set the Java heap size. Default value: $kafka::params::mirror_heap_opts ##### `jmx_opts` Data type: `String[1]` Set the JMX options. Default value: $kafka::params::mirror_jmx_opts ##### `log4j_opts` Data type: `String[1]` Set the Log4j options. Default value: $kafka::params::mirror_log4j_opts ### kafka::params This class provides default parameters. ### kafka::producer This class handles the Kafka (producer). #### Examples ##### Basic usage ```puppet class { 'kafka::producer': config => { 'client.id' => '0', 'zookeeper.connect' => 'localhost:2181' } } ``` #### Parameters The following parameters are available in the `kafka::producer` class. ##### `input` Data type: `Optional[String[1]]` Set named pipe as input. ##### `kafka_version` Data type: `String[1]` The version of Kafka that should be installed. Default value: $kafka::params::kafka_version ##### `scala_version` Data type: `String[1]` The scala version what Kafka was built with. Default value: $kafka::params::scala_version ##### `install_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka to. Default value: $kafka::params::install_dir ##### `mirror_url` Data type: `Stdlib::HTTPUrl` The url where the Kafka is downloaded from. Default value: $kafka::params::mirror_url ##### `manage_java` Data type: `Boolean` Install java if it's not already installed. Default value: $kafka::params::manage_java ##### `package_dir` Data type: `Stdlib::Absolutepath` The directory to install Kafka. Default value: $kafka::params::package_dir ##### `package_name` Data type: `Optional[String[1]]` Package name, when installing Kafka from a package. Default value: $kafka::params::package_name ##### `package_ensure` Data type: `String[1]` Package version or ensure state, when installing Kafka from a package. Default value: $kafka::params::package_ensure ##### `user_name` Data type: `String[1]` User to run Kafka as. Default value: $kafka::params::user_name +##### `user_shell` + +Data type: `Stdlib::Absolutepath` + +Login shell of the Kafka user. + +Default value: $kafka::params::user_shell + ##### `group_name` Data type: `String[1]` Group to run Kafka as. Default value: $kafka::params::group_name ##### `user_id` Data type: `Optional[Integer]` Create the Kafka user with this ID. Default value: $kafka::params::user_id ##### `group_id` Data type: `Optional[Integer]` Create the Kafka group with this ID. Default value: $kafka::params::group_id ##### `manage_user` Data type: `Boolean` Create the Kafka user if it's not already present. Default value: $kafka::params::manage_user ##### `manage_group` Data type: `Boolean` Create the Kafka group if it's not already present. Default value: $kafka::params::manage_group ##### `config_mode` Data type: `Stdlib::Filemode` The permissions for the config files. Default value: $kafka::params::config_mode ##### `config_dir` Data type: `Stdlib::Absolutepath` The directory to create the Kafka config files to. Default value: $kafka::params::config_dir ##### `log_dir` Data type: `Stdlib::Absolutepath` The directory for Kafka log files. Default value: $kafka::params::log_dir ##### `bin_dir` Data type: `Stdlib::Absolutepath` The directory where the Kafka scripts are. Default value: $kafka::params::bin_dir ##### `service_name` Data type: `String[1]` Set the name of the service. Default value: 'kafka-producer' ##### `manage_service` Data type: `Boolean` Install the init.d or systemd service. Default value: $kafka::params::manage_service ##### `service_ensure` Data type: `Enum['running', 'stopped']` Set the ensure state of the service. Default value: $kafka::params::service_ensure ##### `service_restart` Data type: `Boolean` Whether the configuration files should trigger a service restart. Default value: $kafka::params::service_restart ##### `service_requires` Data type: `Array[String[1]]` Set the list of services required to be running before Kafka. Default value: $kafka::params::service_requires ##### `limit_nofile` Data type: `Optional[String[1]]` Set the 'LimitNOFILE' option of the systemd service. Default value: $kafka::params::limit_nofile ##### `limit_core` Data type: `Optional[String[1]]` Set the 'LimitCORE' option of the systemd service. Default value: $kafka::params::limit_core ##### `env` Data type: `Hash` A hash of the environment variables to set. Default value: {} ##### `config` Data type: `Hash[String[1], Any]` A hash of the producer configuration options. Default value: {} ##### `service_config` Data type: `Hash[String[1],String[1]]` A hash of the `kafka-console-producer.sh` script options. Default value: {} ##### `jmx_opts` Data type: `String[1]` Set the JMX options. Default value: $kafka::params::producer_jmx_opts ##### `log4j_opts` Data type: `String[1]` Set the Log4j options. Default value: $kafka::params::producer_log4j_opts ### kafka::producer::config This class handles the Kafka (producer) config. #### Parameters The following parameters are available in the `kafka::producer::config` class. ##### `manage_service` Data type: `Boolean` Default value: $kafka::producer::manage_service ##### `service_name` Data type: `String[1]` Default value: $kafka::producer::service_name ##### `service_restart` Data type: `Boolean` Default value: $kafka::producer::service_restart ##### `config` Data type: `Hash[String[1], Any]` Default value: $kafka::producer::config ##### `config_dir` Data type: `Stdlib::Absolutepath` Default value: $kafka::producer::config_dir ##### `user_name` Data type: `String[1]` Default value: $kafka::producer::user_name ##### `group_name` Data type: `String[1]` Default value: $kafka::producer::group_name ##### `config_mode` Data type: `Stdlib::Filemode` Default value: $kafka::producer::config_mode ## Defined types ### kafka::topic This defined type handles the creation of Kafka topics. #### Examples ##### Basic usage ```puppet kafka::topic { 'test': ensure => present, zookeeper => 'localhost:2181', replication_factor => 1, partitions => 1, } ``` #### Parameters The following parameters are available in the `kafka::topic` defined type. ##### `ensure` Data type: `String[1]` Should the topic be created. Default value: '' ##### `zookeeper` Data type: `String[1]` The connection string for the ZooKeeper connection in the form host:port. Multiple hosts can be given to allow fail-over. Default value: '' ##### `replication_factor` Data type: `Variant[Integer,String[1]]` The replication factor for each partition in the topic being created. If not supplied, defaults to the cluster default. Default value: 1 ##### `partitions` Data type: `Variant[Integer,String[1]]` The number of partitions for the topic being created or altered. If not supplied for create, defaults to the cluster default. Default value: 1 ##### `bin_dir` Data type: `String[1]` The directory where the file kafka-topics.sh is located. Default value: '/opt/kafka/bin' ##### `config` Data type: `Optional[Hash[String[1],String[1]]]` A topic configuration override for the topic being created or altered. See the Kafka documentation for full details on the topic configs. Default value: `undef` diff --git a/manifests/broker.pp b/manifests/broker.pp index 3146026..f708814 100644 --- a/manifests/broker.pp +++ b/manifests/broker.pp @@ -1,155 +1,159 @@ # @summary # This class handles the Kafka (broker). # # @example Basic usage # class { 'kafka::broker': # config => { # 'broker.id' => '0', # 'zookeeper.connect' => 'localhost:2181' # } # } # # @param kafka_version # The version of Kafka that should be installed. # # @param scala_version # The scala version what Kafka was built with. # # @param install_dir # The directory to install Kafka to. # # @param mirror_url # The url where the Kafka is downloaded from. # # @param manage_java # Install java if it's not already installed. # # @param package_dir # The directory to install Kafka. # # @param package_name # Package name, when installing Kafka from a package. # # @param package_ensure # Package version or ensure state, when installing Kafka from a package. # # @param user_name # User to run Kafka as. # +# @param user_shell +# Login shell of the Kafka user. +# # @param group_name # Group to run Kafka as. # # @param user_id # Create the Kafka user with this ID. # # @param group_id # Create the Kafka group with this ID. # # @param manage_user # Create the Kafka user if it's not already present. # # @param manage_group # Create the Kafka group if it's not already present. # # @param config_mode # The permissions for the config files. # # @param config_dir # The directory to create the Kafka config files to. # # @param log_dir # The directory for Kafka log files. # # @param bin_dir # The directory where the Kafka scripts are. # # @param service_name # Set the name of the service. # # @param manage_service # Install the init.d or systemd service. # # @param service_ensure # Set the ensure state of the service. # # @param service_restart # Whether the configuration files should trigger a service restart. # # @param service_requires # Set the list of services required to be running before Kafka. # # @param limit_nofile # Set the 'LimitNOFILE' option of the systemd service. # # @param limit_core # Set the 'LimitCORE' option of the systemd service. # # @param timeout_stop # Set the 'TimeoutStopSec' option of the systemd service. # # @param exec_stop # Set the 'ExecStop' option of the systemd service to 'kafka-server-stop.sh'. # # @param daemon_start # Use the '-daemon' option when starting Kafka with 'kafka-server-start.sh'. # # @param env # A hash of the environment variables to set. # # @param config # A hash of the broker configuration options. # # @param heap_opts # Set the Java heap size. # # @param jmx_opts # Set the JMX options. # # @param log4j_opts # Set the Log4j options. # # @param opts # Set the Kafka options. # class kafka::broker ( String[1] $kafka_version = $kafka::params::kafka_version, String[1] $scala_version = $kafka::params::scala_version, Stdlib::Absolutepath $install_dir = $kafka::params::install_dir, Stdlib::HTTPUrl $mirror_url = $kafka::params::mirror_url, Boolean $manage_java = $kafka::params::manage_java, Stdlib::Absolutepath $package_dir = $kafka::params::package_dir, Optional[String[1]] $package_name = $kafka::params::package_name, String[1] $package_ensure = $kafka::params::package_ensure, String[1] $user_name = $kafka::params::user_name, + Stdlib::Absolutepath $user_shell = $kafka::params::user_shell, String[1] $group_name = $kafka::params::group_name, Optional[Integer] $user_id = $kafka::params::user_id, Optional[Integer] $group_id = $kafka::params::group_id, Boolean $manage_user = $kafka::params::manage_user, Boolean $manage_group = $kafka::params::manage_group, Stdlib::Filemode $config_mode = $kafka::params::config_mode, Stdlib::Absolutepath $config_dir = $kafka::params::config_dir, Stdlib::Absolutepath $log_dir = $kafka::params::log_dir, Stdlib::Absolutepath $bin_dir = $kafka::params::bin_dir, String[1] $service_name = 'kafka', Boolean $manage_service = $kafka::params::manage_service, Enum['running', 'stopped'] $service_ensure = $kafka::params::service_ensure, Boolean $service_restart = $kafka::params::service_restart, Array[String[1]] $service_requires = $kafka::params::service_requires, Optional[String[1]] $limit_nofile = $kafka::params::limit_nofile, Optional[String[1]] $limit_core = $kafka::params::limit_core, Optional[String[1]] $timeout_stop = $kafka::params::timeout_stop, Boolean $exec_stop = $kafka::params::exec_stop, Boolean $daemon_start = $kafka::params::daemon_start, Hash $env = {}, Hash[String[1], Any] $config = {}, String[1] $heap_opts = $kafka::params::broker_heap_opts, String[1] $jmx_opts = $kafka::params::broker_jmx_opts, String[1] $log4j_opts = $kafka::params::broker_log4j_opts, String[0] $opts = $kafka::params::broker_opts, ) inherits kafka::params { class { 'kafka::broker::install': } -> class { 'kafka::broker::config': } -> class { 'kafka::broker::service': } -> Class['kafka::broker'] } diff --git a/manifests/broker/install.pp b/manifests/broker/install.pp index b09f511..8870e36 100644 --- a/manifests/broker/install.pp +++ b/manifests/broker/install.pp @@ -1,30 +1,31 @@ # @summary # This class handles the Kafka (broker) package. # # @api private # class kafka::broker::install { assert_private() if !defined(Class['kafka']) { class { 'kafka': manage_java => $kafka::broker::manage_java, manage_group => $kafka::broker::manage_group, group_id => $kafka::broker::group_id, group_name => $kafka::broker::group_name, manage_user => $kafka::broker::manage_user, user_id => $kafka::broker::user_id, user_name => $kafka::broker::user_name, + user_shell => $kafka::broker::user_shell, config_dir => $kafka::broker::config_dir, log_dir => $kafka::broker::log_dir, mirror_url => $kafka::broker::mirror_url, kafka_version => $kafka::broker::kafka_version, scala_version => $kafka::broker::scala_version, install_dir => $kafka::broker::install_dir, package_dir => $kafka::broker::package_dir, package_ensure => $kafka::broker::package_ensure, package_name => $kafka::broker::package_name, } } } diff --git a/manifests/consumer.pp b/manifests/consumer.pp index a496688..d10394c 100644 --- a/manifests/consumer.pp +++ b/manifests/consumer.pp @@ -1,139 +1,143 @@ # @summary # This class handles the Kafka (consumer). # # @example Basic usage # class { 'kafka::consumer': # config => { # 'client.id' => '0', # 'zookeeper.connect' => 'localhost:2181' # } # } # # @param kafka_version # The version of Kafka that should be installed. # # @param scala_version # The scala version what Kafka was built with. # # @param install_dir # The directory to install Kafka to. # # @param mirror_url # The url where the Kafka is downloaded from. # # @param manage_java # Install java if it's not already installed. # # @param package_dir # The directory to install Kafka. # # @param package_name # Package name, when installing Kafka from a package. # # @param package_ensure # Package version or ensure state, when installing Kafka from a package. # # @param user_name # User to run Kafka as. # +# @param user_shell +# Login shell of the Kafka user. +# # @param group_name # Group to run Kafka as. # # @param user_id # Create the Kafka user with this ID. # # @param group_id # Create the Kafka group with this ID. # # @param manage_user # Create the Kafka user if it's not already present. # # @param manage_group # Create the Kafka group if it's not already present. # # @param config_mode # The permissions for the config files. # # @param config_dir # The directory to create the Kafka config files to. # # @param log_dir # The directory for Kafka log files. # # @param bin_dir # The directory where the Kafka scripts are. # # @param service_name # Set the name of the service. # # @param manage_service # Install the init.d or systemd service. # # @param service_ensure # Set the ensure state of the service. # # @param service_restart # Whether the configuration files should trigger a service restart. # # @param service_requires # Set the list of services required to be running before Kafka. # # @param limit_nofile # Set the 'LimitNOFILE' option of the systemd service. # # @param limit_core # Set the 'LimitCORE' option of the systemd service. # # @param env # A hash of the environment variables to set. # # @param config # A hash of the consumer configuration options. # # @param service_config # A hash of the `kafka-console-consumer.sh` script options. # # @param jmx_opts # Set the JMX options. # # @param log4j_opts # Set the Log4j options. # class kafka::consumer ( String[1] $kafka_version = $kafka::params::kafka_version, String[1] $scala_version = $kafka::params::scala_version, Stdlib::Absolutepath $install_dir = $kafka::params::install_dir, Stdlib::HTTPUrl $mirror_url = $kafka::params::mirror_url, Boolean $manage_java = $kafka::params::manage_java, Stdlib::Absolutepath $package_dir = $kafka::params::package_dir, Optional[String[1]] $package_name = $kafka::params::package_name, String[1] $package_ensure = $kafka::params::package_ensure, String[1] $user_name = $kafka::params::user_name, + Stdlib::Absolutepath $user_shell = $kafka::params::user_shell, String[1] $group_name = $kafka::params::group_name, Optional[Integer] $user_id = $kafka::params::user_id, Optional[Integer] $group_id = $kafka::params::group_id, Boolean $manage_user = $kafka::params::manage_user, Boolean $manage_group = $kafka::params::manage_group, Stdlib::Filemode $config_mode = $kafka::params::config_mode, Stdlib::Absolutepath $config_dir = $kafka::params::config_dir, Stdlib::Absolutepath $log_dir = $kafka::params::log_dir, Stdlib::Absolutepath $bin_dir = $kafka::params::bin_dir, String[1] $service_name = 'kafka-consumer', Boolean $manage_service = $kafka::params::manage_service, Enum['running', 'stopped'] $service_ensure = $kafka::params::service_ensure, Boolean $service_restart = $kafka::params::service_restart, Array[String[1]] $service_requires = $kafka::params::service_requires, Optional[String[1]] $limit_nofile = $kafka::params::limit_nofile, Optional[String[1]] $limit_core = $kafka::params::limit_core, Hash $env = {}, Hash[String[1], Any] $config = {}, Hash[String[1],String[1]] $service_config = {}, String[1] $jmx_opts = $kafka::params::consumer_jmx_opts, String[1] $log4j_opts = $kafka::params::consumer_log4j_opts, ) inherits kafka::params { class { 'kafka::consumer::install': } -> class { 'kafka::consumer::config': } -> class { 'kafka::consumer::service': } -> Class['kafka::consumer'] } diff --git a/manifests/consumer/install.pp b/manifests/consumer/install.pp index ed9f290..5b98f9f 100644 --- a/manifests/consumer/install.pp +++ b/manifests/consumer/install.pp @@ -1,30 +1,31 @@ # @summary # This class handles the Kafka (consumer) package. # # @api private # class kafka::consumer::install { assert_private() if !defined(Class['kafka']) { class { 'kafka': manage_java => $kafka::consumer::manage_java, manage_group => $kafka::consumer::manage_group, group_id => $kafka::consumer::group_id, group_name => $kafka::consumer::group_name, manage_user => $kafka::consumer::manage_user, user_id => $kafka::consumer::user_id, user_name => $kafka::consumer::user_name, + user_shell => $kafka::consumer::user_shell, config_dir => $kafka::consumer::config_dir, log_dir => $kafka::consumer::log_dir, mirror_url => $kafka::consumer::mirror_url, kafka_version => $kafka::consumer::kafka_version, scala_version => $kafka::consumer::scala_version, install_dir => $kafka::consumer::install_dir, package_dir => $kafka::consumer::package_dir, package_ensure => $kafka::consumer::package_ensure, package_name => $kafka::consumer::package_name, } } } diff --git a/manifests/init.pp b/manifests/init.pp index 0c76be4..cd43efa 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,232 +1,236 @@ # @summary # This class handles the Kafka requirements. # # @example Basic usage # class { 'kafka': } # # @param kafka_version # The version of Kafka that should be installed. # # @param scala_version # The scala version what Kafka was built with. # # @param install_dir # The directory to install Kafka to. # # @param mirror_url # The url where the Kafka is downloaded from. # # @param manage_java # Install java if it's not already installed. # # @param package_dir # The directory to install Kafka. # # @param package_name # Package name, when installing Kafka from a package. # # @param mirror_subpath # The sub directory where the source is downloaded from. # # @param proxy_server # Set proxy server, when installing Kafka from source. # # @param proxy_port # Set proxy port, when installing Kafka from source. # # @param proxy_host # Set proxy host, when installing Kafka from source. # # @param proxy_type # Set proxy type, when installing Kafka from source. # # @param package_ensure # Package version or ensure state, when installing Kafka from a package. # # @param user_name # User to run Kafka as. # +# @param user_shell +# Login shell of the Kafka user. +# # @param group_name # Group to run Kafka as. # # @param system_user # Whether the Kafka user is a system user or not. # # @param system_group # Whether the Kafka group is a system group or not. # # @param user_id # Create the Kafka user with this ID. # # @param group_id # Create the Kafka group with this ID. # # @param manage_user # Create the Kafka user if it's not already present. # # @param manage_group # Create the Kafka group if it's not already present. # # @param config_dir # The directory to create the Kafka config files to. # # @param log_dir # The directory for Kafka log files. # # @param install_mode # The permissions for the install directory. # class kafka ( String[1] $kafka_version = $kafka::params::kafka_version, String[1] $scala_version = $kafka::params::scala_version, Stdlib::Absolutepath $install_dir = $kafka::params::install_dir, Stdlib::HTTPUrl $mirror_url = $kafka::params::mirror_url, Boolean $manage_java = $kafka::params::manage_java, Stdlib::Absolutepath $package_dir = $kafka::params::package_dir, Optional[String[1]] $package_name = $kafka::params::package_name, Optional[String[1]] $mirror_subpath = $kafka::params::mirror_subpath, Optional[String[1]] $proxy_server = $kafka::params::proxy_server, Optional[String[1]] $proxy_port = $kafka::params::proxy_port, Optional[String[1]] $proxy_host = $kafka::params::proxy_host, Optional[String[1]] $proxy_type = $kafka::params::proxy_type, String[1] $package_ensure = $kafka::params::package_ensure, String[1] $user_name = $kafka::params::user_name, + Stdlib::Absolutepath $user_shell = $kafka::params::user_shell, String[1] $group_name = $kafka::params::group_name, Boolean $system_user = $kafka::params::system_user, Boolean $system_group = $kafka::params::system_group, Optional[Integer] $user_id = $kafka::params::user_id, Optional[Integer] $group_id = $kafka::params::group_id, Boolean $manage_user = $kafka::params::manage_user, Boolean $manage_group = $kafka::params::manage_group, Stdlib::Absolutepath $config_dir = $kafka::params::config_dir, Stdlib::Absolutepath $log_dir = $kafka::params::log_dir, Stdlib::Filemode $install_mode = $kafka::params::install_mode, ) inherits kafka::params { if $manage_java { class { 'java': distribution => 'jdk', } } if $manage_group { group { $group_name: ensure => present, gid => $group_id, system => $system_group, } } if $manage_user { user { $user_name: ensure => present, - shell => '/bin/bash', + shell => $user_shell, require => Group[$group_name], uid => $user_id, system => $system_user, } } file { $config_dir: ensure => directory, owner => $user_name, group => $group_name, } file { $log_dir: ensure => directory, owner => $user_name, group => $group_name, require => [ Group[$group_name], User[$user_name], ], } if $package_name == undef { include archive $mirror_path = $mirror_subpath ? { # if mirror_subpath was not changed, # we adapt it for the version $kafka::params::mirror_subpath => "kafka/${kafka_version}", # else, we just take whatever was supplied: default => $mirror_subpath, } $basefilename = "kafka_${scala_version}-${kafka_version}.tgz" $package_url = "${mirror_url}${mirror_path}/${basefilename}" $source = $mirror_url ?{ /tgz$/ => $mirror_url, default => $package_url, } $install_directory = $install_dir ? { # if install_dir was not changed, # we adapt it for the scala_version and the version $kafka::params::install_dir => "/opt/kafka-${scala_version}-${kafka_version}", # else, we just take whatever was supplied: default => $install_dir, } file { $package_dir: ensure => directory, owner => $user_name, group => $group_name, require => [ Group[$group_name], User[$user_name], ], } file { $install_directory: ensure => directory, owner => $user_name, group => $group_name, mode => $install_mode, require => [ Group[$group_name], User[$user_name], ], } file { '/opt/kafka': ensure => link, target => $install_directory, require => File[$install_directory], } if $proxy_server == undef and $proxy_host != undef and $proxy_port != undef { $final_proxy_server = "${proxy_host}:${proxy_port}" } else { $final_proxy_server = $proxy_server } archive { "${package_dir}/${basefilename}": ensure => present, extract => true, extract_command => 'tar xfz %s --strip-components=1', extract_path => $install_directory, source => $source, creates => "${install_directory}/config", cleanup => true, proxy_server => $final_proxy_server, proxy_type => $proxy_type, user => $user_name, group => $group_name, require => [ File[$package_dir], File[$install_directory], Group[$group_name], User[$user_name], ], before => File[$config_dir], } } else { package { $package_name: ensure => $package_ensure, before => File[$config_dir], } } } diff --git a/manifests/mirror.pp b/manifests/mirror.pp index 674db86..80d156e 100644 --- a/manifests/mirror.pp +++ b/manifests/mirror.pp @@ -1,153 +1,157 @@ # @summary # This class handles the Kafka (mirror). # # @example Basic usage # class { 'kafka::mirror': # consumer_config => { # 'group.id' => 'kafka-mirror', # 'zookeeper.connect' => 'localhost:2181' # }, # producer_config => { # 'zookeeper.connect' => 'localhost:2181', # }, # service_config => { # 'whitelist' => '.*', # } # } # # @param kafka_version # The version of Kafka that should be installed. # # @param scala_version # The scala version what Kafka was built with. # # @param install_dir # The directory to install Kafka to. # # @param mirror_url # The url where the Kafka is downloaded from. # # @param manage_java # Install java if it's not already installed. # # @param package_dir # The directory to install Kafka. # # @param package_name # Package name, when installing Kafka from a package. # # @param package_ensure # Package version or ensure state, when installing Kafka from a package. # # @param user_name # User to run Kafka as. # +# @param user_shell +# Login shell of the Kafka user. +# # @param group_name # Group to run Kafka as. # # @param user_id # Create the Kafka user with this ID. # # @param group_id # Create the Kafka group with this ID. # # @param manage_user # Create the Kafka user if it's not already present. # # @param manage_group # Create the Kafka group if it's not already present. # # @param config_mode # The permissions for the config files. # # @param config_dir # The directory to create the Kafka config files to. # # @param log_dir # The directory for Kafka log files. # # @param bin_dir # The directory where the Kafka scripts are. # # @param service_name # Set the name of the service. # # @param manage_service # Install the init.d or systemd service. # # @param service_ensure # Set the ensure state of the service. # # @param service_restart # Whether the configuration files should trigger a service restart. # # @param service_requires # Set the list of services required to be running before Kafka. # # @param limit_nofile # Set the 'LimitNOFILE' option of the systemd service. # # @param limit_core # Set the 'LimitCORE' option of the systemd service. # # @param env # A hash of the environment variables to set. # # @param consumer_config # A hash of the consumer configuration options. # # @param producer_config # A hash of the producer configuration options. # # @param service_config # A hash of the mirror script options. # # @param heap_opts # Set the Java heap size. # # @param jmx_opts # Set the JMX options. # # @param log4j_opts # Set the Log4j options. # class kafka::mirror ( String[1] $kafka_version = $kafka::params::kafka_version, String[1] $scala_version = $kafka::params::scala_version, Stdlib::Absolutepath $install_dir = $kafka::params::install_dir, Stdlib::HTTPUrl $mirror_url = $kafka::params::mirror_url, Boolean $manage_java = $kafka::params::manage_java, Stdlib::Absolutepath $package_dir = $kafka::params::package_dir, Optional[String[1]] $package_name = $kafka::params::package_name, String[1] $package_ensure = $kafka::params::package_ensure, String[1] $user_name = $kafka::params::user_name, + Stdlib::Absolutepath $user_shell = $kafka::params::user_shell, String[1] $group_name = $kafka::params::group_name, Optional[Integer] $user_id = $kafka::params::user_id, Optional[Integer] $group_id = $kafka::params::group_id, Boolean $manage_user = $kafka::params::manage_user, Boolean $manage_group = $kafka::params::manage_group, Stdlib::Filemode $config_mode = $kafka::params::config_mode, Stdlib::Absolutepath $config_dir = $kafka::params::config_dir, Stdlib::Absolutepath $log_dir = $kafka::params::log_dir, Stdlib::Absolutepath $bin_dir = $kafka::params::bin_dir, String[1] $service_name = 'kafka-mirror', Boolean $manage_service = $kafka::params::manage_service, Enum['running', 'stopped'] $service_ensure = $kafka::params::service_ensure, Boolean $service_restart = $kafka::params::service_restart, Array[String[1]] $service_requires = $kafka::params::service_requires, Optional[String[1]] $limit_nofile = $kafka::params::limit_nofile, Optional[String[1]] $limit_core = $kafka::params::limit_core, Hash $env = {}, Hash[String[1],String[1]] $consumer_config = {}, Hash[String[1],String[1]] $producer_config = {}, Hash[String[1],String[1]] $service_config = {}, String[1] $heap_opts = $kafka::params::mirror_heap_opts, String[1] $jmx_opts = $kafka::params::mirror_jmx_opts, String[1] $log4j_opts = $kafka::params::mirror_log4j_opts, ) inherits kafka::params { class { 'kafka::mirror::install': } -> class { 'kafka::mirror::config': } -> class { 'kafka::mirror::service': } -> Class['kafka::mirror'] } diff --git a/manifests/mirror/install.pp b/manifests/mirror/install.pp index 1d3f741..d243aa4 100644 --- a/manifests/mirror/install.pp +++ b/manifests/mirror/install.pp @@ -1,30 +1,31 @@ # @summary # This class handles the Kafka (mirror) package. # # @api private # class kafka::mirror::install { assert_private() if !defined(Class['kafka']) { class { 'kafka': manage_java => $kafka::mirror::manage_java, manage_group => $kafka::mirror::manage_group, group_id => $kafka::mirror::group_id, group_name => $kafka::mirror::group_name, manage_user => $kafka::mirror::manage_user, user_id => $kafka::mirror::user_id, user_name => $kafka::mirror::user_name, + user_shell => $kafka::mirror::user_shell, config_dir => $kafka::mirror::config_dir, log_dir => $kafka::mirror::log_dir, mirror_url => $kafka::mirror::mirror_url, kafka_version => $kafka::mirror::kafka_version, scala_version => $kafka::mirror::scala_version, install_dir => $kafka::mirror::install_dir, package_dir => $kafka::mirror::package_dir, package_ensure => $kafka::mirror::package_ensure, package_name => $kafka::mirror::package_name, } } } diff --git a/manifests/params.pp b/manifests/params.pp index 4e513f9..925500e 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,64 +1,72 @@ # @summary # This class provides default parameters. # class kafka::params { unless $facts['os']['family'] =~ /(RedHat|Debian|Suse)/ { warning("${facts['os']['family']} is not supported") } $kafka_version = '2.4.1' $scala_version = '2.12' $install_dir = "/opt/kafka-${scala_version}-${kafka_version}" $config_dir = '/opt/kafka/config' $bin_dir = '/opt/kafka/bin' $log_dir = '/var/log/kafka' $mirror_url = 'https://www.apache.org/dyn/closer.lua?action=download&filename=' $mirror_subpath = "kafka/${kafka_version}" $manage_java = false $package_dir = '/var/tmp/kafka' $package_name = undef $proxy_server = undef $proxy_host = undef $proxy_port = undef $proxy_type = undef $package_ensure = 'present' $user_name = 'kafka' + if $facts['service_provider'] == 'systemd' { + $user_shell = $facts['os']['family'] ? { + /RedHat|Suse/ => '/sbin/nologin', + 'Debian' => '/usr/sbin/nologin', + } + } else { + $user_shell = '/bin/bash' + } $group_name = 'kafka' $user_id = undef $group_id = undef $system_user = false $system_group = false $manage_user = true $manage_group = true $config_mode = '0644' $install_mode = '0755' $manage_service = true $service_ensure = 'running' $service_restart = true $service_requires = $facts['os']['family'] ? { /RedHat|Suse/ => ['network.target', 'syslog.target'], default => [], } $limit_nofile = undef $limit_core = undef $timeout_stop = undef $exec_stop = false $daemon_start = false $broker_heap_opts = '-Xmx1G -Xms1G' $broker_jmx_opts = '-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9990' $broker_log4j_opts = "-Dlog4j.configuration=file:${config_dir}/log4j.properties" $broker_opts = '' $mirror_heap_opts = '-Xmx256M' $mirror_jmx_opts = '-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9991' $mirror_log4j_opts = $broker_log4j_opts $producer_jmx_opts = '-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9992' $producer_log4j_opts = $broker_log4j_opts $consumer_jmx_opts = '-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9993' $consumer_log4j_opts = $broker_log4j_opts } diff --git a/manifests/producer.pp b/manifests/producer.pp index 5ade012..6981717 100644 --- a/manifests/producer.pp +++ b/manifests/producer.pp @@ -1,143 +1,147 @@ # @summary # This class handles the Kafka (producer). # # @example Basic usage # class { 'kafka::producer': # config => { # 'client.id' => '0', # 'zookeeper.connect' => 'localhost:2181' # } # } # # @param input # Set named pipe as input. # # @param kafka_version # The version of Kafka that should be installed. # # @param scala_version # The scala version what Kafka was built with. # # @param install_dir # The directory to install Kafka to. # # @param mirror_url # The url where the Kafka is downloaded from. # # @param manage_java # Install java if it's not already installed. # # @param package_dir # The directory to install Kafka. # # @param package_name # Package name, when installing Kafka from a package. # # @param package_ensure # Package version or ensure state, when installing Kafka from a package. # # @param user_name # User to run Kafka as. # +# @param user_shell +# Login shell of the Kafka user. +# # @param group_name # Group to run Kafka as. # # @param user_id # Create the Kafka user with this ID. # # @param group_id # Create the Kafka group with this ID. # # @param manage_user # Create the Kafka user if it's not already present. # # @param manage_group # Create the Kafka group if it's not already present. # # @param config_mode # The permissions for the config files. # # @param config_dir # The directory to create the Kafka config files to. # # @param log_dir # The directory for Kafka log files. # # @param bin_dir # The directory where the Kafka scripts are. # # @param service_name # Set the name of the service. # # @param manage_service # Install the init.d or systemd service. # # @param service_ensure # Set the ensure state of the service. # # @param service_restart # Whether the configuration files should trigger a service restart. # # @param service_requires # Set the list of services required to be running before Kafka. # # @param limit_nofile # Set the 'LimitNOFILE' option of the systemd service. # # @param limit_core # Set the 'LimitCORE' option of the systemd service. # # @param env # A hash of the environment variables to set. # # @param config # A hash of the producer configuration options. # # @param service_config # A hash of the `kafka-console-producer.sh` script options. # # @param jmx_opts # Set the JMX options. # # @param log4j_opts # Set the Log4j options. # class kafka::producer ( Optional[String[1]] $input, String[1] $kafka_version = $kafka::params::kafka_version, String[1] $scala_version = $kafka::params::scala_version, Stdlib::Absolutepath $install_dir = $kafka::params::install_dir, Stdlib::HTTPUrl $mirror_url = $kafka::params::mirror_url, Boolean $manage_java = $kafka::params::manage_java, Stdlib::Absolutepath $package_dir = $kafka::params::package_dir, Optional[String[1]] $package_name = $kafka::params::package_name, String[1] $package_ensure = $kafka::params::package_ensure, String[1] $user_name = $kafka::params::user_name, + Stdlib::Absolutepath $user_shell = $kafka::params::user_shell, String[1] $group_name = $kafka::params::group_name, Optional[Integer] $user_id = $kafka::params::user_id, Optional[Integer] $group_id = $kafka::params::group_id, Boolean $manage_user = $kafka::params::manage_user, Boolean $manage_group = $kafka::params::manage_group, Stdlib::Filemode $config_mode = $kafka::params::config_mode, Stdlib::Absolutepath $config_dir = $kafka::params::config_dir, Stdlib::Absolutepath $log_dir = $kafka::params::log_dir, Stdlib::Absolutepath $bin_dir = $kafka::params::bin_dir, String[1] $service_name = 'kafka-producer', Boolean $manage_service = $kafka::params::manage_service, Enum['running', 'stopped'] $service_ensure = $kafka::params::service_ensure, Boolean $service_restart = $kafka::params::service_restart, Array[String[1]] $service_requires = $kafka::params::service_requires, Optional[String[1]] $limit_nofile = $kafka::params::limit_nofile, Optional[String[1]] $limit_core = $kafka::params::limit_core, Hash $env = {}, Hash[String[1], Any] $config = {}, Hash[String[1],String[1]] $service_config = {}, String[1] $jmx_opts = $kafka::params::producer_jmx_opts, String[1] $log4j_opts = $kafka::params::producer_log4j_opts, ) inherits kafka::params { class { 'kafka::producer::install': } -> class { 'kafka::producer::config': } -> class { 'kafka::producer::service': } -> Class['kafka::producer'] } diff --git a/manifests/producer/install.pp b/manifests/producer/install.pp index f3cd3ce..fbb7a2c 100644 --- a/manifests/producer/install.pp +++ b/manifests/producer/install.pp @@ -1,30 +1,31 @@ # @summary # This class handles the Kafka (producer) package. # # @api private # class kafka::producer::install { assert_private() if !defined(Class['kafka']) { class { 'kafka': manage_java => $kafka::producer::manage_java, manage_group => $kafka::producer::manage_group, group_id => $kafka::producer::group_id, group_name => $kafka::producer::group_name, manage_user => $kafka::producer::manage_user, user_id => $kafka::producer::user_id, user_name => $kafka::producer::user_name, + user_shell => $kafka::producer::user_shell, config_dir => $kafka::producer::config_dir, log_dir => $kafka::producer::log_dir, mirror_url => $kafka::producer::mirror_url, kafka_version => $kafka::producer::kafka_version, scala_version => $kafka::producer::scala_version, install_dir => $kafka::producer::install_dir, package_dir => $kafka::producer::package_dir, package_ensure => $kafka::producer::package_ensure, package_name => $kafka::producer::package_name, } } } diff --git a/spec/acceptance/broker_spec.rb b/spec/acceptance/broker_spec.rb index 9926af1..6f90278 100644 --- a/spec/acceptance/broker_spec.rb +++ b/spec/acceptance/broker_spec.rb @@ -1,234 +1,245 @@ require 'spec_helper_acceptance' +if fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat' + user_shell = '/bin/bash' +else + case fact('osfamily') + when 'RedHat', 'Suse' + user_shell = '/sbin/nologin' + when 'Debian' + user_shell = '/usr/sbin/nologin' + end +end + describe 'kafka::broker' do it 'works with no errors' do pp = <<-EOS class { 'kafka::broker': config => { 'zookeeper.connect' => 'localhost:2181', }, } -> kafka::topic { 'demo': ensure => present, zookeeper => 'localhost:2181', } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe 'kafka::broker::install' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::broker': config => { 'zookeeper.connect' => 'localhost:2181', }, } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.1') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::broker::config' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::broker': config => { 'zookeeper.connect' => 'localhost:2181', }, } EOS apply_manifest(pp, catch_failures: true) end describe file('/opt/kafka/config/server.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } it { is_expected.to contain 'zookeeper.connect=localhost:2181' } end end context 'with custom config dir' do it 'works with no errors' do pp = <<-EOS class { 'kafka::broker': config => { 'zookeeper.connect' => 'localhost:2181', }, config_dir => '/opt/kafka/custom_config' } EOS apply_manifest(pp, catch_failures: true) end describe file('/opt/kafka/custom_config/server.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } it { is_expected.to contain 'zookeeper.connect=localhost:2181' } end end context 'with specific version' do it 'works with no errors' do pp = <<-EOS class { 'kafka::broker': kafka_version => '2.4.0', config => { 'zookeeper.connect' => 'localhost:2181', }, } EOS apply_manifest(pp, catch_failures: true) end describe file('/opt/kafka/config/server.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::broker::service' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::broker': config => { 'zookeeper.connect' => 'localhost:2181', }, } EOS apply_manifest(pp, catch_failures: true) end - describe file('/etc/init.d/kafka'), if: (fact('operatingsystemmajrelease') =~ %r{(5|6)} && fact('osfamily') == 'RedHat') do + describe file('/etc/init.d/kafka'), if: (fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } end describe file('/etc/systemd/system/kafka.service'), if: (fact('operatingsystemmajrelease') == '7' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } end describe service('kafka') do it { is_expected.to be_running } it { is_expected.to be_enabled } end end end describe 'kafka::broker::service' do context 'with log4j/jmx parameters' do it 'works with no errors' do pp = <<-EOS exec { 'create log dir': command => '/bin/mkdir -p /some/path/to/logs', creates => '/some/path/to/logs', } -> class { 'kafka::broker': config => { 'zookeeper.connect' => 'localhost:2181', }, heap_opts => '-Xmx512M -Xmx512M', log4j_opts => '-Dlog4j.configuration=file:/tmp/log4j.properties', jmx_opts => '-Dcom.sun.management.jmxremote', opts => '-Djava.security.policy=/some/path/my.policy', log_dir => '/some/path/to/logs' } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - describe file('/etc/init.d/kafka'), if: (fact('operatingsystemmajrelease') =~ %r{(5|6)} && fact('osfamily') == 'RedHat') do + describe file('/etc/init.d/kafka'), if: (fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote"' } it { is_expected.to contain 'export KAFKA_HEAP_OPTS="-Xmx512M -Xmx512M"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/tmp/log4j.properties"' } end describe file('/etc/init.d/kafka'), if: (fact('service_provider') == 'upstart' && fact('osfamily') == 'Debian') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain %r{^# Provides:\s+kafka$} } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote"' } it { is_expected.to contain 'export KAFKA_HEAP_OPTS="-Xmx512M -Xmx512M"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/tmp/log4j.properties"' } end describe file('/etc/systemd/system/kafka.service'), if: (fact('operatingsystemmajrelease') == '7' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain "Environment='KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote'" } it { is_expected.to contain "Environment='KAFKA_HEAP_OPTS=-Xmx512M -Xmx512M'" } it { is_expected.to contain "Environment='KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/tmp/log4j.properties'" } it { is_expected.to contain "Environment='KAFKA_OPTS=-Djava.security.policy=/some/path/my.policy'" } it { is_expected.to contain "Environment='LOG_DIR=/some/path/to/logs'" } end describe service('kafka') do it { is_expected.to be_running } it { is_expected.to be_enabled } end end end end diff --git a/spec/acceptance/consumer_spec.rb b/spec/acceptance/consumer_spec.rb index 0650a4a..5813475 100644 --- a/spec/acceptance/consumer_spec.rb +++ b/spec/acceptance/consumer_spec.rb @@ -1,166 +1,177 @@ require 'spec_helper_acceptance' +if fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat' + user_shell = '/bin/bash' +else + case fact('osfamily') + when 'RedHat', 'Suse' + user_shell = '/sbin/nologin' + when 'Debian' + user_shell = '/usr/sbin/nologin' + end +end + describe 'kafka::consumer' do it 'works with no errors' do pp = <<-EOS class { 'kafka::consumer': service_config => { topic => 'demo', bootstrap-server => 'localhost:9092', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe 'kafka::consumer::install' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::consumer': service_config => { topic => 'demo', bootstrap-server => 'localhost:9092', }, } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.1') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::consumer::config' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::consumer': service_config => { topic => 'demo', bootstrap-server => 'localhost:9092', }, } EOS apply_manifest(pp, catch_failures: true) end describe file('/opt/kafka/config/consumer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::consumer::config' do context 'with custom config_dir' do it 'works with no errors' do pp = <<-EOS class { 'kafka::consumer': service_config => { topic => 'demo', bootstrap-server => 'localhost:9092', }, config_dir => '/opt/kafka/custom_config', } EOS apply_manifest(pp, catch_failures: true) end describe file('/opt/kafka/custom_config/consumer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::consumer::service' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::consumer': service_config => { topic => 'demo', bootstrap-server => 'localhost:9092', }, } EOS apply_manifest(pp, catch_failures: true) end - describe file('/etc/init.d/kafka-consumer'), if: (fact('operatingsystemmajrelease') =~ %r{(5|6)} && fact('osfamily') == 'RedHat') do + describe file('/etc/init.d/kafka-consumer'), if: (fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9993"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"' } end describe file('/etc/init.d/kafka-consumer'), if: (fact('service_provider') == 'upstart' && fact('osfamily') == 'Debian') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain %r{^# Provides:\s+kafka-consumer$} } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9993"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"' } end describe file('/etc/systemd/system/kafka-consumer.service'), if: (fact('operatingsystemmajrelease') == '7' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain 'Environment=\'KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9993\'' } it { is_expected.to contain 'Environment=\'KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties\'' } end describe service('kafka-consumer') do it { is_expected.to be_running } it { is_expected.to be_enabled } end end end end diff --git a/spec/acceptance/init_spec.rb b/spec/acceptance/init_spec.rb index e74d8db..53c4db3 100644 --- a/spec/acceptance/init_spec.rb +++ b/spec/acceptance/init_spec.rb @@ -1,212 +1,223 @@ require 'spec_helper_acceptance' +if fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat' + user_shell = '/bin/bash' +else + case fact('osfamily') + when 'RedHat', 'Suse' + user_shell = '/sbin/nologin' + when 'Debian' + user_shell = '/usr/sbin/nologin' + end +end + describe 'kafka' do it 'works with no errors' do pp = <<-EOS class { 'kafka': } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe 'kafka::init' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka': } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.1') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end context 'with specific kafka version' do it 'works with no errors' do pp = <<-EOS class { 'kafka': kafka_version => '2.4.0', } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.0') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.0') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end context 'with specific scala version' do it 'works with no errors' do pp = <<-EOS class { 'kafka': scala_version => '2.13', } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.13-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.13-2.4.1') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end context 'with specific config dir' do it 'works with no errors' do pp = <<-EOS class { 'kafka': config_dir => '/opt/kafka/custom_config', } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.1') } end describe file('/opt/kafka/custom_config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end end diff --git a/spec/acceptance/mirror_spec.rb b/spec/acceptance/mirror_spec.rb index 1301b47..d5144e7 100644 --- a/spec/acceptance/mirror_spec.rb +++ b/spec/acceptance/mirror_spec.rb @@ -1,244 +1,255 @@ require 'spec_helper_acceptance' +if fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat' + user_shell = '/bin/bash' +else + case fact('osfamily') + when 'RedHat', 'Suse' + user_shell = '/sbin/nologin' + when 'Debian' + user_shell = '/usr/sbin/nologin' + end +end + describe 'kafka::mirror' do it 'works with no errors' do pp = <<-EOS class { 'kafka::mirror': consumer_config => { 'group.id' => 'kafka-mirror', 'bootstrap.servers' => 'localhost:9092', }, producer_config => { 'bootstrap.servers' => 'localhost:9092', }, service_config => { 'whitelist' => '.*', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe 'kafka::mirror::install' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::mirror': consumer_config => { 'group.id' => 'kafka-mirror', 'bootstrap.servers' => 'localhost:9092', }, producer_config => { 'bootstrap.servers' => 'localhost:9092', }, service_config => { 'whitelist' => '.*', }, } EOS apply_manifest(pp, catch_failures: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.1') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::mirror::config' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::mirror': consumer_config => { 'group.id' => 'kafka-mirror', 'bootstrap.servers' => 'localhost:9092', }, producer_config => { 'bootstrap.servers' => 'localhost:9092', }, service_config => { 'whitelist' => '.*', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe file('/opt/kafka/config/consumer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka/config/producer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end context 'with custom config_dir' do it 'works with no errors' do pp = <<-EOS class { 'kafka::mirror': consumer_config => { 'group.id' => 'kafka-mirror', 'bootstrap.servers' => 'localhost:9092', }, producer_config => { 'bootstrap.servers' => 'localhost:9092', }, service_config => { 'whitelist' => '.*', }, config_dir => '/opt/kafka/custom_config', } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe file('/opt/kafka/custom_config/consumer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka/custom_config/producer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end context 'with specific version' do it 'works with no errors' do pp = <<-EOS class { 'kafka::mirror': kafka_version => '2.4.0', consumer_config => { 'group.id' => 'kafka-mirror', 'bootstrap.servers' => 'localhost:9092', }, producer_config => { 'bootstrap.servers' => 'localhost:9092', }, service_config => { 'whitelist' => '.*', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe file('/opt/kafka/config/consumer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka/config/producer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::mirror::service' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::mirror': consumer_config => { 'group.id' => 'kafka-mirror', 'bootstrap.servers' => 'localhost:9092', }, producer_config => { 'bootstrap.servers' => 'localhost:9092', }, service_config => { 'whitelist' => '.*', }, } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end - describe file('/etc/init.d/kafka-mirror'), if: (fact('operatingsystemmajrelease') =~ %r{(5|6)} && fact('osfamily') == 'RedHat') do + describe file('/etc/init.d/kafka-mirror'), if: (fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9991"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"' } end describe file('/etc/init.d/kafka-mirror'), if: (fact('service_provider') == 'upstart' && fact('osfamily') == 'Debian') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain %r{^# Provides:\s+kafka-mirror$} } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9991"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"' } end describe file('/etc/systemd/system/kafka-mirror.service'), if: (fact('operatingsystemmajrelease') == '7' && fact('osfamily') == 'RedHat') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain 'Environment=\'KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9991\'' } it { is_expected.to contain 'Environment=\'KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties\'' } end describe service('kafka-mirror') do it { is_expected.to be_running } it { is_expected.to be_enabled } end end end end diff --git a/spec/acceptance/producer_spec.rb b/spec/acceptance/producer_spec.rb index b2e18f8..2df0dce 100644 --- a/spec/acceptance/producer_spec.rb +++ b/spec/acceptance/producer_spec.rb @@ -1,151 +1,162 @@ require 'spec_helper_acceptance' +if fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat' + user_shell = '/bin/bash' +else + case fact('osfamily') + when 'RedHat', 'Suse' + user_shell = '/sbin/nologin' + when 'Debian' + user_shell = '/usr/sbin/nologin' + end +end + describe 'kafka::producer', if: (fact('operatingsystemmajrelease') == '6' && fact('osfamily') == 'RedHat') do # systemd systems not supported by kafka::producer::service it 'works with no errors' do pp = <<-EOS exec { 'create fifo': command => '/usr/bin/mkfifo /tmp/kafka-producer', user => 'kafka', creates => '/tmp/kafka-producer', } -> class { 'kafka::producer': service_config => { 'broker-list' => 'localhost:9092', topic => 'demo', }, input => '3<>/tmp/kafka-producer 0>&3', } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe 'kafka::producer::install' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS exec { 'create fifo': command => '/usr/bin/mkfifo /tmp/kafka-producer', user => 'kafka', creates => '/tmp/kafka-producer', } -> class { 'kafka::producer': service_config => { 'broker-list' => 'localhost:9092', topic => 'demo', }, input => '3<>/tmp/kafka-producer 0>&3', } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe group('kafka') do it { is_expected.to exist } end describe user('kafka') do it { is_expected.to exist } it { is_expected.to belong_to_group 'kafka' } - it { is_expected.to have_login_shell '/bin/bash' } + it { is_expected.to have_login_shell user_shell } end describe file('/var/tmp/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka-2.12-2.4.1') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/opt/kafka') do it { is_expected.to be_linked_to('/opt/kafka-2.12-2.4.1') } end describe file('/opt/kafka/config') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end describe file('/var/log/kafka') do it { is_expected.to be_directory } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::producer::config' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS exec { 'create fifo': command => '/usr/bin/mkfifo /tmp/kafka-producer', user => 'kafka', creates => '/tmp/kafka-producer', } -> class { 'kafka::producer': service_config => { 'broker-list' => 'localhost:9092', topic => 'demo', }, input => '3<>/tmp/kafka-producer 0>&3', } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe file('/opt/kafka/config/producer.properties') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'kafka' } it { is_expected.to be_grouped_into 'kafka' } end end end describe 'kafka::producer::service' do context 'with default parameters' do it 'works with no errors' do pp = <<-EOS class { 'kafka::producer': service_config => { 'broker-list' => 'localhost:9092', topic => 'demo', }, input => '3<>/tmp/kafka-producer 0>&3', } EOS apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end describe file('/etc/init.d/kafka-producer') do it { is_expected.to be_file } it { is_expected.to be_owned_by 'root' } it { is_expected.to be_grouped_into 'root' } it { is_expected.to contain 'export KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9992"' } it { is_expected.to contain 'export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:/opt/kafka/config/log4j.properties"' } end describe file('/etc/init.d/kafka-producer'), if: (fact('service_provider') == 'upstart' && fact('osfamily') == 'Debian') do it { is_expected.to contain %r{^# Provides:\s+kafka-producer$} } end describe service('kafka-producer') do it { is_expected.to be_running } it { is_expected.to be_enabled } end end end end