Skip to content

Commit

Permalink
eypconf facts
Browse files Browse the repository at this point in the history
  • Loading branch information
jordiprats committed May 17, 2017
1 parent ce85023 commit 74402b4
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# CHANGELOG

## 0.1.8

* added **eypconf** facts
26 changes: 26 additions & 0 deletions lib/facter/eypconf_env.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions lib/facter/eypconf_magic_hash.rb
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions lib/facter/eypconf_type.rb
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions lib/facter/eypconf_userid.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 74402b4

Please sign in to comment.