Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for non systemd OS #357

Merged
merged 7 commits into from
Jun 9, 2024
Merged
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
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ Default value: `'kafka'`

Data type: `Boolean`

Install the init.d or systemd service.
Install the systemd service.

Default value: `$kafka::params::manage_service`

Expand Down Expand Up @@ -862,7 +862,7 @@ Default value: `'kafka-consumer'`

Data type: `Boolean`

Install the init.d or systemd service.
Install the systemd service.

Default value: `$kafka::params::manage_service`

Expand Down Expand Up @@ -1306,7 +1306,7 @@ Default value: `'kafka-mirror'`

Data type: `Boolean`

Install the init.d or systemd service.
Install the systemd service.

Default value: `$kafka::params::manage_service`

Expand Down Expand Up @@ -1658,7 +1658,7 @@ Default value: `'kafka-producer'`

Data type: `Boolean`

Install the init.d or systemd service.
Install systemd service.

Default value: `$kafka::params::manage_service`

Expand Down
2 changes: 1 addition & 1 deletion manifests/broker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# Set the name of the service.
#
# @param manage_service
# Install the init.d or systemd service.
# Install the systemd service.
#
# @param service_ensure
# Set the ensure state of the service.
Expand Down
29 changes: 6 additions & 23 deletions manifests/broker/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,14 @@
}
$environment = deep_merge($env_defaults, $env)

if $facts['service_provider'] == 'systemd' {
include systemd
include systemd

file { "/etc/systemd/system/${service_name}.service":
ensure => file,
mode => '0644',
content => template('kafka/unit.erb'),
}

file { "/etc/init.d/${service_name}":
ensure => absent,
}

File["/etc/systemd/system/${service_name}.service"]
~> Service[$service_name]
} else {
file { "/etc/init.d/${service_name}":
ensure => file,
mode => '0755',
content => template('kafka/init.erb'),
zilchms marked this conversation as resolved.
Show resolved Hide resolved
before => Service[$service_name],
}
file { "/etc/systemd/system/${service_name}.service":
zilchms marked this conversation as resolved.
Show resolved Hide resolved
ensure => file,
mode => '0644',
content => template('kafka/unit.erb'),
}

service { $service_name:
~> service { $service_name:
ensure => $service_ensure,
enable => true,
hasstatus => true,
Expand Down
2 changes: 1 addition & 1 deletion manifests/consumer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
# Set the name of the service.
#
# @param manage_service
# Install the init.d or systemd service.
# Install the systemd service.
#
# @param service_ensure
# Set the ensure state of the service.
Expand Down
29 changes: 6 additions & 23 deletions manifests/consumer/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,14 @@
}
$environment = deep_merge($env_defaults, $env)

if $facts['service_provider'] == 'systemd' {
include systemd
include systemd

file { "/etc/systemd/system/${service_name}.service":
ensure => file,
mode => '0644',
content => template('kafka/unit.erb'),
}

file { "/etc/init.d/${service_name}":
ensure => absent,
}

File["/etc/systemd/system/${service_name}.service"]
~> Service[$service_name]
} else {
file { "/etc/init.d/${service_name}":
ensure => file,
mode => '0755',
content => template('kafka/init.erb'),
before => Service[$service_name],
}
file { "/etc/systemd/system/${service_name}.service":
ensure => file,
mode => '0644',
content => template('kafka/unit.erb'),
}

service { $service_name:
~> service { $service_name:
ensure => $service_ensure,
enable => true,
hasstatus => true,
Expand Down
2 changes: 1 addition & 1 deletion manifests/mirror.pp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
# Set the name of the service.
#
# @param manage_service
# Install the init.d or systemd service.
# Install the systemd service.
#
# @param service_ensure
# Set the ensure state of the service.
Expand Down
29 changes: 6 additions & 23 deletions manifests/mirror/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,14 @@
}
$environment = deep_merge($env_defaults, $env)

if $facts['service_provider'] == 'systemd' {
include systemd
include systemd

file { "/etc/systemd/system/${service_name}.service":
ensure => file,
mode => '0644',
content => template('kafka/unit.erb'),
}

file { "/etc/init.d/${service_name}":
ensure => absent,
}

File["/etc/systemd/system/${service_name}.service"]
~> Service[$service_name]
} else {
file { "/etc/init.d/${service_name}":
ensure => file,
mode => '0755',
content => template('kafka/init.erb'),
before => Service[$service_name],
}
file { "/etc/systemd/system/${service_name}.service":
ensure => file,
mode => '0644',
content => template('kafka/unit.erb'),
}

service { $service_name:
~> service { $service_name:
ensure => $service_ensure,
enable => true,
hasstatus => true,
Expand Down
2 changes: 1 addition & 1 deletion manifests/producer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# Set the name of the service.
#
# @param manage_service
# Install the init.d or systemd service.
# Install systemd service.
#
# @param service_ensure
# Set the ensure state of the service.
Expand Down
11 changes: 1 addition & 10 deletions manifests/producer/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,7 @@
}
$environment = deep_merge($env_defaults, $env)

if $facts['service_provider'] == 'systemd' {
fail('Console Producer is not supported on systemd, because the stdin of the process cannot be redirected')
} else {
file { "/etc/init.d/${service_name}":
ensure => file,
mode => '0755',
content => template('kafka/init.erb'),
before => Service[$service_name],
}
}
fail('Console Producer is not supported on systemd, because the stdin of the process cannot be redirected')
zilchms marked this conversation as resolved.
Show resolved Hide resolved

service { $service_name:
ensure => $service_ensure,
Expand Down
14 changes: 2 additions & 12 deletions spec/acceptance/broker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class { 'kafka::broker':
apply_manifest(pp, catch_failures: true)
end

describe file('/etc/systemd/system/kafka.service'), if: (fact('operatingsystemmajrelease') == '7' && fact('osfamily') == 'RedHat') do
describe file('/etc/systemd/system/kafka.service') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
Expand Down Expand Up @@ -197,17 +197,7 @@ class { 'kafka::broker':
apply_manifest(pp, catch_changes: true)
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
describe file('/etc/systemd/system/kafka.service') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
Expand Down
11 changes: 1 addition & 10 deletions spec/acceptance/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,7 @@ class { 'kafka::consumer':
apply_manifest(pp, catch_failures: true)
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
describe file('/etc/systemd/system/kafka-consumer.service') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
Expand Down
11 changes: 1 addition & 10 deletions spec/acceptance/mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,7 @@ class { 'kafka::mirror':
apply_manifest(pp, catch_changes: true)
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
describe file('/etc/systemd/system/kafka-mirror.service') do
it { is_expected.to be_file }
it { is_expected.to be_owned_by 'root' }
it { is_expected.to be_grouped_into 'root' }
Expand Down
23 changes: 4 additions & 19 deletions spec/classes/broker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,41 +52,26 @@
context 'manage_service false' do
let(:params) { super().merge(manage_service: false) }

it { is_expected.not_to contain_file('/etc/init.d/kafka') }
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service') }
it { is_expected.not_to contain_service('kafka') }
end

context 'defaults' do
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/init.d/kafka').with_ensure('absent') }
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=} }
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=} }
else
it { is_expected.to contain_file('/etc/init.d/kafka') }
end

it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=} }
it { is_expected.not_to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=} }
it { is_expected.to contain_service('kafka') }
end

context 'limit_nofile set' do
let(:params) { super().merge(limit_nofile: '65536') }

if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=65536$} }
else
it { is_expected.to contain_file('/etc/init.d/kafka').with_content %r{ulimit -n 65536$} }
end
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitNOFILE=65536$} }
end

context 'limit_core set' do
let(:params) { super().merge(limit_core: 'infinity') }

if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=infinity$} }
else
it { is_expected.to contain_file('/etc/init.d/kafka').with_content %r{ulimit -c infinity$} }
end
it { is_expected.to contain_file('/etc/systemd/system/kafka.service').with_content %r{^LimitCORE=infinity$} }
end

context 'service_requires set', if: os_facts['service_provider'] == 'systemd' do
Expand Down
7 changes: 1 addition & 6 deletions spec/classes/consumer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@

describe 'kafka::consumer::service' do
context 'defaults' do
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/systemd/system/kafka-consumer.service') }
else
it { is_expected.to contain_file('/etc/init.d/kafka-consumer') }
end

it { is_expected.to contain_file('/etc/systemd/system/kafka-consumer.service') }
it { is_expected.to contain_service('kafka-consumer') }
end
end
Expand Down
9 changes: 1 addition & 8 deletions spec/classes/mirror_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,7 @@

describe 'kafka::mirror::service' do
context 'defaults' do
if os_facts['service_provider'] == 'systemd'
it { is_expected.to contain_file('/etc/init.d/kafka-mirror').with_ensure('absent') }
it { is_expected.to contain_file('/etc/systemd/system/kafka-mirror.service').with_content %r{/opt/kafka/config/(?=.*consumer)|(?=.*producer).propertie} }
else
it { is_expected.to contain_file('/etc/init.d/kafka-mirror') }
it { is_expected.to contain_file('/etc/init.d/kafka-mirror').with_content %r{/opt/kafka/config/(?=.*consumer)|(?=.*producer).properties} }
end

it { is_expected.to contain_file('/etc/systemd/system/kafka-mirror.service').with_content %r{/opt/kafka/config/(?=.*consumer)|(?=.*producer).propertie} }
it { is_expected.to contain_service('kafka-mirror') }
end
end
Expand Down
30 changes: 1 addition & 29 deletions spec/classes/producer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,7 @@
}
end

if os_facts['service_provider'] == 'systemd'
it { is_expected.to compile.and_raise_error(%r{Console Producer is not supported on systemd, because the stdin of the process cannot be redirected}) }
else
it { is_expected.to contain_class('kafka::producer::install').that_comes_before('Class[kafka::producer::config]') }
it { is_expected.to contain_class('kafka::producer::config').that_comes_before('Class[kafka::producer::service]') }
it { is_expected.to contain_class('kafka::producer::service').that_comes_before('Class[kafka::producer]') }
it { is_expected.to contain_class('kafka::producer') }

describe 'kafka::producer::install' do
context 'defaults' do
it { is_expected.to contain_class('kafka') }
end
end

describe 'kafka::producer::config' do
context 'defaults' do
it { is_expected.to contain_file('/opt/kafka/config/producer.properties') }
end
end

describe 'kafka::producer::service' do
context 'defaults' do
it { is_expected.to contain_file('/etc/init.d/kafka-producer') }
it { is_expected.to contain_service('kafka-producer') }
end
end

it_validates_parameter 'mirror_url'
end
it { is_expected.to compile.and_raise_error(%r{Console Producer is not supported on systemd, because the stdin of the process cannot be redirected}) }
end
end
end
Loading
Loading