From 97103ded8390d10ea3468615c654e89d07c0a921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 19 Mar 2018 16:00:01 +0100 Subject: Filter ldapvar to contain only puppetClient information --- modules/base_installation/lib/facter/ldapvar.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/base_installation/lib/facter/ldapvar.rb b/modules/base_installation/lib/facter/ldapvar.rb index 3ee6623..08d58e4 100644 --- a/modules/base_installation/lib/facter/ldapvar.rb +++ b/modules/base_installation/lib/facter/ldapvar.rb @@ -27,16 +27,18 @@ begin connection.search(base, scope, filter) do |entry| data_ = entry.to_hash - data_['vars'] = (data_[Puppet[:ldapstackedattrs]] || []) - .map { |var| var.split("=", 2) } - .group_by { |(key, value)| key } - .map { |key, value| [key, value.map(&:last)] } - .to_h + if data_["objectClass"].any? { |class_| class_ == "puppetClient" } + data_['vars'] = (data_[Puppet[:ldapstackedattrs]] || []) + .map { |var| var.split("=", 2) } + .group_by { |(key, value)| key } + .map { |key, value| [key, value.map(&:last)] } + .to_h - data[:other] << data_ + data[:other] << data_ - if data_["cn"].any? { |cn| cn == host } - data[:self] = data_ + if data_["cn"].any? { |cn| cn == host } + data[:self] = data_ + end end end -- cgit v1.2.3