From 3417cd72f33e677a8dc000b93372cba63becaa6c Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 5 Mar 2019 13:44:15 +0100 Subject: [PATCH] =?UTF-8?q?m=C3=A9s=20facts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 +++++++++++++++--------- lib/facter/eypconf_customer.rb | 25 +++++++++++++++++++++++++ lib/facter/eypconf_platform.rb | 25 +++++++++++++++++++++++++ lib/facter/eypconf_projectid.rb | 25 ------------------------- 4 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 lib/facter/eypconf_customer.rb create mode 100644 lib/facter/eypconf_platform.rb delete mode 100644 lib/facter/eypconf_projectid.rb diff --git a/README.md b/README.md index 12c6eee..bf98885 100644 --- a/README.md +++ b/README.md @@ -64,11 +64,11 @@ download { 'salt': ### facts -#### eypconf_userid +#### eypconf_platformid -/opt/eypconf/id/userid.sh /opt/eypconf/id/userid +/opt/eypconf/id/platformid.sh /opt/eypconf/id/platformid -**eypconf_userid_uppercase** and **eypconf_userid_lowercase** +**eypconf_platformid_uppercase** and **eypconf_platformid_lowercase** #### eypconf_magic_hash @@ -80,11 +80,11 @@ download { 'salt': **eypconf_env_uppercase** and **eypconf_env_lowercase** -#### eypconf_projectid +#### eypconf_type -/opt/eypconf/id/projectid.sh /opt/eypconf/id/projectid +/opt/eypconf/id/type.sh /opt/eypconf/id/type -**eypconf_projectid_uppercase** and **eypconf_projectid_lowercase** +**eypconf_type_uppercase** and **eypconf_type_lowercase** #### eypconf_servergroup @@ -92,11 +92,17 @@ download { 'salt': **eypconf_servergroup_uppercase** and **eypconf_servergroup_lowercase** -#### eypconf_type +#### eypconf_userid -/opt/eypconf/id/type.sh /opt/eypconf/id/type +/opt/eypconf/id/userid.sh /opt/eypconf/id/userid -**eypconf_type_uppercase** and **eypconf_type_lowercase** +**eypconf_userid_uppercase** and **eypconf_userid_lowercase** + +#### eypconf_customer + +/opt/eypconf/id/customer.sh /opt/eypconf/id/customer + +**eypconf_customer_uppercase** and **eypconf_customer_lowercase** ### types diff --git a/lib/facter/eypconf_customer.rb b/lib/facter/eypconf_customer.rb new file mode 100644 index 0000000..6b4a01e --- /dev/null +++ b/lib/facter/eypconf_customer.rb @@ -0,0 +1,25 @@ +if File.exists?('/opt/eypconf/id/customer.sh') then + customer = Facter::Util::Resolution.exec('bash /opt/eypconf/id/customer.sh').to_s +else + customer = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/customer ]; then cat /opt/eypconf/id/customer | paste -sd,; fi\'').to_s +end + +unless customer.nil? or customer.empty? + Facter.add('eypconf_customer') do + setcode do + customer + end + end + + Facter.add('eypconf_customer_uppercase') do + setcode do + customer.upcase + end + end + + Facter.add('eypconf_customer_lowercase') do + setcode do + customer.downcase + end + end +end diff --git a/lib/facter/eypconf_platform.rb b/lib/facter/eypconf_platform.rb new file mode 100644 index 0000000..d482da7 --- /dev/null +++ b/lib/facter/eypconf_platform.rb @@ -0,0 +1,25 @@ +if File.exists?('/opt/eypconf/id/platformid.sh') then + platformid = Facter::Util::Resolution.exec('bash /opt/eypconf/id/platformid.sh').to_s +else + platformid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/platformid ]; then cat /opt/eypconf/id/platformid | paste -sd,; fi\'').to_s +end + +unless platformid.nil? or platformid.empty? + Facter.add('eypconf_platformid') do + setcode do + platformid + end + end + + Facter.add('eypconf_platformid_uppercase') do + setcode do + platformid.upcase + end + end + + Facter.add('eypconf_platformid_lowercase') do + setcode do + platformid.downcase + end + end +end diff --git a/lib/facter/eypconf_projectid.rb b/lib/facter/eypconf_projectid.rb deleted file mode 100644 index 25b2003..0000000 --- a/lib/facter/eypconf_projectid.rb +++ /dev/null @@ -1,25 +0,0 @@ -if File.exists?('/opt/eypconf/id/projectid.sh') then - userid = Facter::Util::Resolution.exec('bash /opt/eypconf/id/projectid.sh').to_s -else - userid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/projectid ]; then cat /opt/eypconf/id/projectid | paste -sd,; fi\'').to_s -end - -unless userid.nil? or userid.empty? - Facter.add('eypconf_projectid') do - setcode do - userid - end - end - - Facter.add('eypconf_projectid_uppercase') do - setcode do - userid.upcase - end - end - - Facter.add('eypconf_projectid_lowercase') do - setcode do - userid.downcase - end - end -end