From 3341f5c01e26a694dc0d0df74224cbd5fb50e1f8 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 14 Aug 2017 08:33:20 +0200 Subject: [PATCH 1/3] eypconf_group --- .travis.yml | 10 ++++++++ CHANGELOG.md | 4 ++++ README.md | 19 ++++++++++----- lib/facter/eypconf_group.rb | 25 ++++++++++++++++++++ metadata.json | 2 +- spec/acceptance/nodesets/debian8-docker.yml | 14 +++++++++++ spec/acceptance/nodesets/ubuntu16-docker.yml | 15 ++++++++++++ 7 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 lib/facter/eypconf_group.rb create mode 100644 spec/acceptance/nodesets/debian8-docker.yml create mode 100644 spec/acceptance/nodesets/ubuntu16-docker.yml diff --git a/.travis.yml b/.travis.yml index 9ddb2dc..b81d7a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,3 +43,13 @@ matrix: dist: trusty bundler_args: script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb + - rvm: default + env: BEAKER_set="ubuntu16-docker" + dist: trusty + bundler_args: + script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb + - rvm: default + env: BEAKER_set="debian8-docker" + dist: trusty + bundler_args: + script: sudo service docker restart ; sleep 10 && bundle exec rspec spec/acceptance/*_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index a5ba98b..6c48d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.1.10 + +* added **eypconf_group** fact + ## 0.1.9 * removed bool2httpd function diff --git a/README.md b/README.md index f69d178..bf4560f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # eyplib -![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) - #### Table of Contents 1. [Overview](#overview) @@ -20,7 +18,7 @@ Standard library of resources for Puppet modules. ## Module Description -Contains common functions for eyp modules +Contains common functions for eyp modules and node classification facts ## Setup @@ -36,7 +34,7 @@ Requires pluginsync enabled ## Usage -Just add a dependency on your metadata.json file, for example: +Just add a dependency on your **metadata.json** file, for example: ```json "dependencies": [ @@ -56,6 +54,14 @@ in ERB files you can call this module's functions using: ### functions +#### bool2boolstr + +Transform a boolean to a string (**true** or **false**). Other values through. + +#### bool2number + +Transform a boolean (it can also be a string) to **0** or **1**. Other values through. + #### bool2onoff Transform a boolean (it can also be a string) to **On** or **Off**. Other values through. @@ -64,9 +70,10 @@ Transform a boolean (it can also be a string) to **On** or **Off**. Other values Transform a boolean (it can also be a string) to **yes** or **no**. Other values through. -#### bool2httpd +#### bool2yn + +Transform a boolean (it can also be a string) to **y** or **n**. Other values through. -Same as **bool2onoff**, transform a boolean (it can also be a string) to **On** or **Off**. Other values through. ## Development diff --git a/lib/facter/eypconf_group.rb b/lib/facter/eypconf_group.rb new file mode 100644 index 0000000..932a634 --- /dev/null +++ b/lib/facter/eypconf_group.rb @@ -0,0 +1,25 @@ +if File.exists?('/opt/eypconf/id/group.sh') then + nodetype = Facter::Util::Resolution.exec('bash /opt/eypconf/id/group.sh').to_s +else + nodetype = Facter::Util::Resolution.exec('bash -c \'if [ -f /opt/eypconf/id/group ]; then cat /opt/eypconf/id/type | paste -sd,; fi\'') +end + +unless nodetype.nil? or nodetype.empty? + Facter.add('eypconf_group') do + setcode do + nodetype + end + end + + Facter.add('eypconf_group_uppercase') do + setcode do + nodetype.upcase + end + end + + Facter.add('eypconf_group_lowercase') do + setcode do + nodetype.downcase + end + end +end diff --git a/metadata.json b/metadata.json index 9ff6aee..de68864 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-eyplib", - "version": "0.1.9", + "version": "0.1.10", "author": "eyp", "summary": "Utility functions for puppet modules", "license": "Apache-2.0", diff --git a/spec/acceptance/nodesets/debian8-docker.yml b/spec/acceptance/nodesets/debian8-docker.yml new file mode 100644 index 0000000..be88af7 --- /dev/null +++ b/spec/acceptance/nodesets/debian8-docker.yml @@ -0,0 +1,14 @@ +HOSTS: + debian-8: + default_apply_opts: + order: random + strict_variables: + platform: debian-8-amd64 + hypervisor : docker + image: debian:8 + docker_preserve_image: true + docker_image_commands: + - 'apt-get install libssl-dev gcc make tar wget openjdk-7-jdk -y' +CONFIG: + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu16-docker.yml b/spec/acceptance/nodesets/ubuntu16-docker.yml new file mode 100644 index 0000000..67a3f61 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu16-docker.yml @@ -0,0 +1,15 @@ +HOSTS: + ubuntu-1604-x64: + default_apply_opts: + order: random + strict_variables: + platform: ubuntu-16.04-amd64 + hypervisor : docker + image: ubuntu:16.04 + docker_cmd: '["/sbin/init"]' + docker_preserve_image: true + docker_image_commands: + - 'apt-get install net-tools gcc make tar wget -y' +CONFIG: + type: foss + log_level: debug From b0bf6ecde65168afae16c78ab49218528243c0e1 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 14 Aug 2017 08:35:56 +0200 Subject: [PATCH 2/3] typo --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 298133b..9a4fae1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,7 +2,7 @@ # # === eyplib documentation # -class eyplib inherits eyplib::params{ +class eyplib{ # nothing to do here From eabacd1953bd648646ee28a154735bd6d439fd42 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 14 Aug 2017 08:36:03 +0200 Subject: [PATCH 3/3] til --- manifests/init.pp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9a4fae1..62e9173 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,8 +2,6 @@ # # === eyplib documentation # -class eyplib{ - +class eyplib { # nothing to do here - }