From 19c8efe7cd7c9039b47c3b5cc4a1bd690e60b07d Mon Sep 17 00:00:00 2001 From: Joshua Knarr Date: Fri, 11 Nov 2016 13:56:29 -0500 Subject: [PATCH] Issue #77 - attempt to fathom id automatically --- lib/facter/hostid.rb | 10 ++++++++++ manifests/params.pp | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 lib/facter/hostid.rb diff --git a/lib/facter/hostid.rb b/lib/facter/hostid.rb new file mode 100644 index 0000000..5b645fd --- /dev/null +++ b/lib/facter/hostid.rb @@ -0,0 +1,10 @@ +# add hostid fact +# it grabs the last digits off the hostname to automatically provision services which need +# a host to have some sort of unique serial number +# +Facter.add(:hostid) do + setcode do + hostid = Facter.value(:hostname) + hostid.gsub(/\D/, "") + end +end diff --git a/manifests/params.pp b/manifests/params.pp index 3a95fd5..8e634ea 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -101,7 +101,8 @@ $datalogstore = undef $election_port = 2888 $export_tag = 'zookeeper' - $id = '1' + $id = $facts['hostid'] + if $id == nil { $id = '1' } $init_limit = 10 $initialize_datastore = false $leader = true