Hi, we have a new code version for kafka-manager deploy. I will not give more details, just that now it also has a fact for the kafka-password and also some minor changes. Fact looks like this:
require 'facter'
Facter.add(:kafka_manager_pass) do
setcode do
file='/etc/kafka-manager/application.conf'
if File.exist?(file)
kafka_manager_pass = Facter::Core::Execution.exec("cat #{file} | grep basicAuthentication.password | cut -d'=' -f2 | tr -d '\"'")
else
kafka_manager_pass = "undef"
end
end
end
And also the new puppet code for the class:
class profiles::kafkamanager {
$zookeeper_connect = hiera('kafkamanager::zookeeperconnect')
$password = hiera("kafkamanager::password:",'password')
package {'kafka-manager':
ensure => installed,
}
group { 'kafka-manager':
ensure => 'present',
}
user { 'kafka-manager':
ensure => 'present',
groups => 'kafka-manager'
}
Group['kafka-manager'] -> User['kafka-manager']
file { '/usr/share/kafka-manager' :
ensure => directory,
owner => 'kafka-manager',
group => 'kafka-manager',
require => [ User['kafka-manager'], Group['kafka-manager'], ],
recurse => true,
}
file { '/etc/kafka-manager/application.conf':
ensure => present,
}
file_line { 'config_zookeeper':
path => '/etc/kafka-manager/application.conf',
line => "kafka-manager.zkhosts=\"${zookeeper_connect}\"",
match => 'kafka-manager.zkhosts=\"\"',
replace => true,
}
if ($::kafka_manager_pass == "undef") {
file_line { 'enable_pass_default':
path => '/etc/kafka-manager/application.conf',
match => "basicAuthentication.password=\"password\"",
line => "basicAuthentication.password=\"${password}\"",
replace => true,
}
}
elsif ($password != $::kafka_manager_pass) {
file_line { 'enable_pass':
path => '/etc/kafka-manager/application.conf',
match => "basicAuthentication.password=\"${::kafka_manager_pass}\"",
line => "basicAuthentication.password=\"${password}\"",
replace => true,
}
exec {'restart_kafkamanager':
command => '/usr/sbin/service kafka-manager restart',
path => ['/bin','/sbin','/usr/bin','/usr/sbin'],
refreshonly => true,
subscribe => File_line['enable_pass'],
}
}
file_line { 'enable_auth':
path => '/etc/kafka-manager/application.conf',
match => 'basicAuthentication.enabled=false',
line => 'basicAuthentication.enabled=true',
replace => true,
}
service { 'kafka-manager':
ensure => 'running',
enable => true,
require => [ File['/usr/share/kafka-manager'], File['/etc/kafka-manager/application.conf'] ],
subscribe => File["/etc/kafka-manager/application.conf"],
}
Give it a try!
Cheers!