-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from jordiprats/master
funcions bool2yesno i bool2onoff
- Loading branch information
Showing
20 changed files
with
452 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fixtures: | ||
repositories: | ||
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
symlinks: | ||
eyplib: "#{source_dir}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*~ | ||
/pkg/ | ||
/.vagrant | ||
/junit | ||
/log | ||
/spec/fixtures/manifests | ||
/spec/fixtures/modules | ||
/Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
language: ruby | ||
sudo: required | ||
services: | ||
- docker | ||
script: | ||
- bundle exec rspec spec/acceptance | ||
bundler_args: --without system_tests | ||
matrix: | ||
include: | ||
- rvm: default | ||
env: LINT=puppetcode | ||
dist: trusty | ||
bundler_args: | ||
script: bundle exec rake lint | ||
- rvm: default | ||
env: LINT=metadata | ||
dist: trusty | ||
bundler_args: | ||
script: bundle exec rake metadata_lint | ||
- rvm: default | ||
env: JOB=validate | ||
dist: trusty | ||
bundler_args: | ||
script: bundle exec rake validate | ||
- rvm: default | ||
env: BEAKER_set="centos5-docker" | ||
dist: trusty | ||
bundler_args: | ||
script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb | ||
- rvm: default | ||
env: BEAKER_set="centos6-docker" | ||
dist: trusty | ||
bundler_args: | ||
script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb | ||
- rvm: default | ||
env: BEAKER_set="centos7-docker" | ||
dist: trusty | ||
bundler_args: | ||
script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb | ||
- rvm: default | ||
env: BEAKER_set="ubuntu14-docker" | ||
dist: trusty | ||
bundler_args: | ||
script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
source 'https://rubygems.org' | ||
|
||
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3'] | ||
gem 'puppet', puppetversion | ||
gem 'puppetlabs_spec_helper', '>= 0.1.0' | ||
gem 'puppet-lint', '>= 0.3.2' | ||
gem 'facter', '>= 1.7.0' | ||
|
||
group :system_tests do | ||
gem 'beaker', :require => false | ||
gem 'beaker-rspec', :require => false | ||
gem 'beaker_spec_helper', :require => false | ||
gem 'beaker-puppet_install_helper', :require => false | ||
gem 'serverspec', :require => false | ||
gem 'rspec', '< 3.2', :require => false if RUBY_VERSION =~ /^1\.8/ | ||
gem 'rspec-puppet', :require => false | ||
gem 'metadata-json-lint', :require => false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# eyplib | ||
|
||
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) | ||
|
||
#### Table of Contents | ||
|
||
1. [Overview](#overview) | ||
2. [Module Description](#module-description) | ||
3. [Setup](#setup) | ||
* [What eyplib affects](#what-eyplib-affects) | ||
* [Setup requirements](#setup-requirements) | ||
4. [Usage](#usage) | ||
5. [Reference](#reference) | ||
6. [Development](#development) | ||
* [Contributing](#contributing) | ||
|
||
## Overview | ||
|
||
Standard library of resources for Puppet modules. | ||
|
||
## Module Description | ||
|
||
Contains common functions for eyp modules | ||
|
||
## Setup | ||
|
||
Installing the eyplib module adds the functions, facts, and resources of this standard library to Puppet. | ||
|
||
### What eyplib affects | ||
|
||
After you've installed eyplib, all of its functions, facts, and resources are already available. | ||
|
||
### Setup Requirements | ||
|
||
Requires pluginsync enabled | ||
|
||
## Usage | ||
|
||
Just add a dependency on your metadata.json file, for example: | ||
|
||
```json | ||
"dependencies": [ | ||
{"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0"}, | ||
{"name":"puppetlabs/concat","version_requirement":">= 1.2.3"}, | ||
{"name":"eyp/eyplib","version_requirement":">= 0.1.0 < 0.2.0"} | ||
], | ||
``` | ||
|
||
## Reference | ||
|
||
### functions | ||
|
||
#### bool2onoff | ||
|
||
Transform a boolean (it can also be a string) to **On** or **Off**. Other values through. | ||
|
||
#### bool2yesno | ||
|
||
Transform a boolean (it can also be a string) to **yes** or **no**. Other values through. | ||
|
||
## Development | ||
|
||
We are pushing to have acceptance testing in place, so any new feature should | ||
have some test to check both presence and absence of any feature | ||
|
||
### Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'rubygems' | ||
require 'puppetlabs_spec_helper/rake_tasks' | ||
require 'puppet-lint/tasks/puppet-lint' | ||
require 'metadata-json-lint/rake_task' | ||
PuppetLint.configuration.send('disable_80chars') | ||
PuppetLint.configuration.send('disable_class_inherits_from_params_class') | ||
PuppetLint.configuration.send('disable_documentation') | ||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] | ||
|
||
desc "Validate manifests, templates, and ruby files" | ||
task :validate do | ||
Dir['manifests/**/*.pp'].each do |manifest| | ||
sh "puppet parser validate --noop #{manifest}" | ||
end | ||
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file| | ||
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/ | ||
end | ||
Dir['templates/**/*.erb'].each do |template| | ||
sh "erb -P -x -T '-' #{template} | ruby -c" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#shamesly stolen from: https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/puppet/parser/functions/bool2httpd.rb | ||
# with minor changes | ||
# | ||
# | ||
#Copyright (C) 2012 Puppet Labs Inc | ||
# | ||
#Puppet Labs can be contacted at: [email protected] | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
# | ||
# | ||
Puppet::Parser::Functions::newfunction(:bool2onoff, :type => :rvalue, :doc => <<-EOS | ||
Transform a supposed boolean to On or Off. Other values through. | ||
EOS | ||
) do |args| | ||
raise(Puppet::ParseError, "bool2onoff() wrong number of arguments. Given: #{args.size} for 1)") if args.size != 1 | ||
|
||
arg = args[0] | ||
|
||
if arg.nil? or arg == false or arg =~ /false/i or arg =~ /off/i or arg == :undef | ||
return 'off' | ||
elsif arg == true or arg =~ /true/i or arg =~ /on/i | ||
return 'on' | ||
end | ||
|
||
return arg.to_s | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#shamesly stolen from: https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/puppet/parser/functions/bool2httpd.rb | ||
# with minor changes | ||
# | ||
# | ||
#Copyright (C) 2012 Puppet Labs Inc | ||
# | ||
#Puppet Labs can be contacted at: [email protected] | ||
# | ||
#Licensed under the Apache License, Version 2.0 (the "License"); | ||
# | ||
# | ||
Puppet::Parser::Functions::newfunction(:bool2yesno, :type => :rvalue, :doc => <<-EOS | ||
Transform a supposed boolean to yes or no. Pass all other values through. | ||
Given a nil value (undef), bool2yesno will return 'no' | ||
EOS | ||
) do |args| | ||
raise(Puppet::ParseError, "bool2yesno() wrong number of arguments. #{args.size} vs 1)") if args.size != 1 | ||
|
||
arg = args[0] | ||
|
||
if arg.nil? or arg == false or arg =~ /false/i or arg =~ /no/i or arg == :undef | ||
return 'no' | ||
elsif arg == true or arg =~ /true/i or arg =~ /yes/i | ||
return 'yes' | ||
end | ||
|
||
return arg.to_s | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# == Class: eyplib | ||
# | ||
# === eyplib documentation | ||
# | ||
class eyplib inherits eyplib::params{ | ||
|
||
# nothing to do here | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name": "eyp-eyplib", | ||
"version": "0.1.1", | ||
"author": "eyp", | ||
"summary": "Utility functions for puppet modules", | ||
"license": "Apache-2.0", | ||
"source": "https://github.com/AtlasIT-AM/eyp-eyplib", | ||
"project_page": null, | ||
"issues_url": "https://github.com/AtlasIT-AM/eyp-eyplib/issues", | ||
"dependencies": [ | ||
{"name":"puppetlabs/stdlib","version_requirement":">= 1.0.0"} | ||
], | ||
"operatingsystem_support": [ | ||
{ | ||
"operatingsystem": "RedHat", | ||
"operatingsystemrelease": [ "5", "6", "7" ] | ||
}, | ||
{ | ||
"operatingsystem": "CentOS", | ||
"operatingsystemrelease": [ "5", "6", "7" ] | ||
}, | ||
{ | ||
"operatingsystem": "Scientific", | ||
"operatingsystemrelease": [ "5", "6", "7" ] | ||
}, | ||
{ | ||
"operatingsystem": "OEL", | ||
"operatingsystemrelease": [ "5", "6", "7" ] | ||
}, | ||
{ | ||
"operatingsystem": "OracleLinux", | ||
"operatingsystemrelease": [ "5", "6", "7" ] | ||
}, | ||
{ | ||
"operatingsystem": "Ubuntu", | ||
"operatingsystemrelease": [ "14.04" ] | ||
} | ||
], | ||
"requirements": [ | ||
{ | ||
"name": "pe", | ||
"version_requirement": ">= 3.0.0" | ||
}, | ||
{ | ||
"name": "puppet", | ||
"version_requirement": ">= 3.0.0" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'spec_helper_acceptance' | ||
require_relative './version.rb' | ||
|
||
describe 'eyplib class' do | ||
|
||
context 'basic setup' do | ||
# Using puppet_apply as a helper | ||
it 'should work with no errors' do | ||
pp = <<-EOF | ||
class { 'eyplib': } | ||
EOF | ||
|
||
# Run it twice and test for idempotency | ||
expect(apply_manifest(pp).exit_code).to_not eq(1) | ||
expect(apply_manifest(pp).exit_code).to eq(0) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
HOSTS: | ||
centos-5-x64: | ||
default_apply_opts: | ||
order: random | ||
strict_variables: | ||
platform: el-5-x86_64 | ||
hypervisor : docker | ||
image: centos:5 | ||
docker_preserve_image: true | ||
docker_cmd: '["/sbin/init"]' | ||
docker_image_commands: | ||
- 'rm -rf /var/run/network/*' | ||
- 'yum install -y gcc make crontabs tar wget java-1.7.0-openjdk java-1.7.0-openjdk-devel' | ||
CONFIG: | ||
type: foss | ||
log_level: debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
HOSTS: | ||
centos-6-x64: | ||
default_apply_opts: | ||
order: random | ||
strict_variables: | ||
platform: el-6-x86_64 | ||
hypervisor : docker | ||
image: centos:6 | ||
docker_preserve_image: true | ||
docker_cmd: '["/sbin/init"]' | ||
docker_image_commands: | ||
- 'rm -rf /var/run/network/*' | ||
- 'yum install -y gcc make crontabs tar wget curl' | ||
CONFIG: | ||
type: foss | ||
log_level: debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
HOSTS: | ||
centos-7-x64: | ||
default_apply_opts: | ||
order: random | ||
strict_variables: | ||
platform: el-7-x86_64 | ||
hypervisor : docker | ||
image: centos:7 | ||
docker_preserve_image: true | ||
docker_cmd: '["/usr/sbin/init"]' | ||
docker_image_commands: | ||
- 'rm -rf /var/run/network/*' | ||
- 'yum install -y gcc make crontabs tar wget iproute java-1.7.0-openjdk java-1.7.0-openjdk-devel' | ||
CONFIG: | ||
type: foss | ||
log_level: debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
HOSTS: | ||
ubuntu-14-04: | ||
default_apply_opts: | ||
order: random | ||
strict_variables: | ||
platform: ubuntu-14.04-x64 | ||
hypervisor : docker | ||
image: ubuntu:14.04 | ||
docker_preserve_image: true | ||
docker_image_commands: | ||
- 'apt-get install gcc make tar wget openjdk-7-jdk openjdk-7-jre -y' | ||
CONFIG: | ||
type: foss | ||
log_level: debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
_osfamily = fact('osfamily') | ||
_operatingsystem = fact('operatingsystem') | ||
_operatingsystemrelease = fact('operatingsystemrelease').to_f | ||
|
||
case _osfamily | ||
when 'RedHat' | ||
$examplevar = 'valrh' | ||
|
||
when 'Debian' | ||
$examplevar = 'valdeb' | ||
|
||
else | ||
$examplevar = '-_-' | ||
|
||
end |
Oops, something went wrong.