diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..41e0f65 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# CHANGELOG + +## 0.1.8 + +* added **eypconf** facts diff --git a/README.md b/README.md index 3e4b3c3..f69d178 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 module's functions using: + +```erb +<%= scope.function_bool2onoff([@trace]) %> +``` + ## Reference ### functions 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..6935bc0 --- /dev/null +++ b/lib/facter/eypconf_magic_hash.rb @@ -0,0 +1,13 @@ +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 + 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..97c3e71 --- /dev/null +++ b/lib/facter/eypconf_userid.rb @@ -0,0 +1,25 @@ +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 + 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 6280131..92c014d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-eyplib", - "version": "0.1.6", + "version": "0.1.8", "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": [ {