From eb3a9848d627aa2eabb66f183a4373a69dfb2e6d Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 13 Jun 2016 12:05:07 +0200 Subject: [PATCH 1/6] canvi ver per proba --- metadata.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metadata.json b/metadata.json index 6280131..c62f9c9 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-eyplib", - "version": "0.1.6", + "version": "0.1.7", "author": "eyp", "summary": "Utility functions for puppet modules", "license": "Apache-2.0", @@ -8,7 +8,7 @@ "project_page": null, "issues_url": "https://github.com/NTTCom-MS/eyp-eyplib/issues", "dependencies": [ - {"name":"puppetlabs/stdlib","version_requirement":">= 1.0.0"} + {"name":"puppetlabs/stdlib","version_requirement":">= 4.12.0"} ], "operatingsystem_support": [ { From c61fddbb720fb4c95627d2d84d9cd7bd91da7f6a Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Wed, 14 Sep 2016 11:49:44 +0200 Subject: [PATCH 2/6] adding changelog file --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4591f22 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# CHANGELOG + From efb439fe80bcca5984b9162e6988c4e28f9d61a3 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Sat, 7 Jan 2017 13:52:43 +0100 Subject: [PATCH 3/6] ERB example --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 3e4b3c3..0e62a41 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,12 @@ Just add a dependency on your metadata.json file, for example: ], ``` +in ERB files you can call this function using: + +```erb +<%= scope.function_bool2onoff([@trace]) %> +``` + ## Reference ### functions From ce8502337459119ddc1ba2481bcde53a35a9b125 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Sat, 7 Jan 2017 14:03:32 +0100 Subject: [PATCH 4/6] detalls --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e62a41..f69d178 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Just add a dependency on your metadata.json file, for example: ], ``` -in ERB files you can call this function using: +in ERB files you can call this module's functions using: ```erb <%= scope.function_bool2onoff([@trace]) %> From 74402b4c03f1e0019e9f1befae7ee449b8322741 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Wed, 17 May 2017 11:06:37 +0200 Subject: [PATCH 5/6] eypconf facts --- CHANGELOG.md | 3 +++ lib/facter/eypconf_env.rb | 26 ++++++++++++++++++++++++++ lib/facter/eypconf_magic_hash.rb | 9 +++++++++ lib/facter/eypconf_type.rb | 25 +++++++++++++++++++++++++ lib/facter/eypconf_userid.rb | 21 +++++++++++++++++++++ metadata.json | 2 +- 6 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 lib/facter/eypconf_env.rb create mode 100644 lib/facter/eypconf_magic_hash.rb create mode 100644 lib/facter/eypconf_type.rb create mode 100644 lib/facter/eypconf_userid.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 4591f22..41e0f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,5 @@ # CHANGELOG +## 0.1.8 + +* added **eypconf** facts diff --git a/lib/facter/eypconf_env.rb b/lib/facter/eypconf_env.rb new file mode 100644 index 0000000..318365c --- /dev/null +++ b/lib/facter/eypconf_env.rb @@ -0,0 +1,26 @@ +if File.exists?('/opt/eypconf/id/env.sh') then + env = Facter::Util::Resolution.exec('bash /opt/eypconf/id/env.sh').to_s +else + env = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/env ]; then cat /opt/eypconf/id/env | paste -sd,; fi\'').to_s +end + +unless env.nil? or env.empty? + Facter.add('eypconf_env') do + setcode do + env + end + end + + Facter.add('eypconf_env_uppercase') do + setcode do + env.upcase + end + end + + Facter.add('eypconf_env_lowercase') do + setcode do + env.downcase + end + end + +end diff --git a/lib/facter/eypconf_magic_hash.rb b/lib/facter/eypconf_magic_hash.rb new file mode 100644 index 0000000..8377f60 --- /dev/null +++ b/lib/facter/eypconf_magic_hash.rb @@ -0,0 +1,9 @@ +magichash = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/.magic ]; then cat /opt/eypconf/id/.magic | paste -sd,; else echo "deadbeef"; fi\'').to_s + +unless magichash.nil? or magichash.empty? + Facter.add('eypconf_magic_hash') do + setcode do + magichash + end + end +end diff --git a/lib/facter/eypconf_type.rb b/lib/facter/eypconf_type.rb new file mode 100644 index 0000000..a25997f --- /dev/null +++ b/lib/facter/eypconf_type.rb @@ -0,0 +1,25 @@ +if File.exists?('/opt/eypconf/id/type.sh') then + nodetype = Facter::Util::Resolution.exec('bash /opt/eypconf/id/type.sh').to_s +else + nodetype = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/type ]; then cat /opt/eypconf/id/type | paste -sd,; fi\'') +end + +unless nodetype.nil? or nodetype.empty? + Facter.add('eypconf_type') do + setcode do + nodetype + end + end + + Facter.add('eypconf_type_uppercase') do + setcode do + nodetype.upcase + end + end + + Facter.add('eypconf_type_lowercase') do + setcode do + nodetype.downcase + end + end +end diff --git a/lib/facter/eypconf_userid.rb b/lib/facter/eypconf_userid.rb new file mode 100644 index 0000000..c884896 --- /dev/null +++ b/lib/facter/eypconf_userid.rb @@ -0,0 +1,21 @@ +userid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/customer ]; then cat /opt/eypconf/id/customer | paste -sd,; else echo "defaultcustomer"; fi\'').to_s + +unless userid.nil? or userid.empty? + Facter.add('eypconf_userid') do + setcode do + userid + end + end + + Facter.add('eypconf_userid_uppercase') do + setcode do + userid.upcase + end + end + + Facter.add('eypconf_userid_lowercase') do + setcode do + userid.downcase + end + end +end diff --git a/metadata.json b/metadata.json index c62f9c9..92c014d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-eyplib", - "version": "0.1.7", + "version": "0.1.8", "author": "eyp", "summary": "Utility functions for puppet modules", "license": "Apache-2.0", From e980a47993a174e700f6db66088ef43747b24441 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Wed, 17 May 2017 11:43:04 +0200 Subject: [PATCH 6/6] scripts for userid and magic hash --- lib/facter/eypconf_magic_hash.rb | 6 +++++- lib/facter/eypconf_userid.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/facter/eypconf_magic_hash.rb b/lib/facter/eypconf_magic_hash.rb index 8377f60..6935bc0 100644 --- a/lib/facter/eypconf_magic_hash.rb +++ b/lib/facter/eypconf_magic_hash.rb @@ -1,4 +1,8 @@ -magichash = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/.magic ]; then cat /opt/eypconf/id/.magic | paste -sd,; else echo "deadbeef"; fi\'').to_s +if File.exists?('/opt/eypconf/id/magic.sh') then + magichash = Facter::Util::Resolution.exec('bash /opt/eypconf/id/magic.sh').to_s +else + magichash = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/.magic ]; then cat /opt/eypconf/id/.magic | paste -sd,; else echo "deadbeef"; fi\'').to_s +end unless magichash.nil? or magichash.empty? Facter.add('eypconf_magic_hash') do diff --git a/lib/facter/eypconf_userid.rb b/lib/facter/eypconf_userid.rb index c884896..97c3e71 100644 --- a/lib/facter/eypconf_userid.rb +++ b/lib/facter/eypconf_userid.rb @@ -1,4 +1,8 @@ -userid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/customer ]; then cat /opt/eypconf/id/customer | paste -sd,; else echo "defaultcustomer"; fi\'').to_s +if File.exists?('/opt/eypconf/id/userid.sh') then + userid = Facter::Util::Resolution.exec('bash /opt/eypconf/id/userid.sh').to_s +else + userid = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/userid ]; then cat /opt/eypconf/id/userid | paste -sd,; fi\'').to_s +end unless userid.nil? or userid.empty? Facter.add('eypconf_userid') do