Skip to content

Commit

Permalink
Merge pull request #6 from jordiprats/master
Browse files Browse the repository at this point in the history
eypconf
  • Loading branch information
jordiprats authored Jun 20, 2017
2 parents 36b55f4 + e980a47 commit 2cee3c2
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## 0.1.8

* added **eypconf** facts
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
13 changes: 13 additions & 0 deletions lib/facter/eypconf_magic_hash.rb
Original file line number Diff line number Diff line change
@@ -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
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
25 changes: 25 additions & 0 deletions lib/facter/eypconf_userid.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "eyp-eyplib",
"version": "0.1.6",
"version": "0.1.8",
"author": "eyp",
"summary": "Utility functions for puppet modules",
"license": "Apache-2.0",
"source": "https://github.com/NTTCom-MS/eyp-eyplib",
"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": [
{
Expand Down

0 comments on commit 2cee3c2

Please sign in to comment.