From 39d80ca478015e4f6874c139c7c236c6d71a4006 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 7 Mar 2016 18:52:58 +0100 Subject: [PATCH 1/7] init --- .fixtures.yml | 5 ++ .gitignore | 8 ++ .travis.yml | 45 +++++++++++ Gemfile | 18 +++++ README.md | 82 ++++++++++++++++++++ Rakefile | 21 +++++ manifests/init.pp | 12 +++ manifests/params.pp | 35 +++++++++ manifests/service.pp | 25 ++++++ metadata.json | 49 ++++++++++++ spec/acceptance/base_spec.rb | 21 +++++ spec/acceptance/nodesets/centos5-docker.yml | 16 ++++ spec/acceptance/nodesets/centos6-docker.yml | 16 ++++ spec/acceptance/nodesets/centos7-docker.yml | 16 ++++ spec/acceptance/nodesets/ubuntu14-docker.yml | 14 ++++ spec/acceptance/version.rb | 16 ++++ spec/classes/init_spec.rb | 36 +++++++++ spec/spec_helper.rb | 1 + spec/spec_helper_acceptance.rb | 22 ++++++ tests/init.pp | 12 +++ 20 files changed, 470 insertions(+) create mode 100644 .fixtures.yml create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 Gemfile create mode 100644 README.md create mode 100644 Rakefile create mode 100644 manifests/init.pp create mode 100644 manifests/params.pp create mode 100644 manifests/service.pp create mode 100644 metadata.json create mode 100644 spec/acceptance/base_spec.rb create mode 100644 spec/acceptance/nodesets/centos5-docker.yml create mode 100644 spec/acceptance/nodesets/centos6-docker.yml create mode 100644 spec/acceptance/nodesets/centos7-docker.yml create mode 100644 spec/acceptance/nodesets/ubuntu14-docker.yml create mode 100644 spec/acceptance/version.rb create mode 100644 spec/classes/init_spec.rb create mode 100644 spec/spec_helper.rb create mode 100644 spec/spec_helper_acceptance.rb create mode 100644 tests/init.pp diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..1ee192b --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git" + symlinks: + eyplib: "#{source_dir}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..edb819a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*~ +/pkg/ +/.vagrant +/junit +/log +/spec/fixtures/manifests +/spec/fixtures/modules +/Gemfile.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9ddb2dc --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..be325d9 --- /dev/null +++ b/Gemfile @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..7f7b0b1 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# eyplib + +#### Table of Contents + +1. [Overview](#overview) +2. [Module Description](#module-description) +3. [Setup](#setup) + * [What eyplib affects](#what-eyplib-affects) + * [Setup requirements](#setup-requirements) + * [Beginning with eyplib](#beginning-with-eyplib) +4. [Usage](#usage) +5. [Reference](#reference) +5. [Limitations](#limitations) +6. [Development](#development) + * [Contributing](#contributing) + +## Overview + +A one-maybe-two sentence summary of what the module does/what problem it solves. +This is your 30 second elevator pitch for your module. Consider including +OS/Puppet version it works with. + +## Module Description + +If applicable, this section should have a brief description of the technology +the module integrates with and what that integration enables. This section +should answer the questions: "What does this module *do*?" and "Why would I use +it?" + +If your module has a range of functionality (installation, configuration, +management, etc.) this is the time to mention it. + +## Setup + +### What eyplib affects + +* A list of files, packages, services, or operations that the module will alter, + impact, or execute on the system it's installed on. +* This is a great place to stick any warnings. +* Can be in list or paragraph form. + +### Setup Requirements + +If your module requires anything extra before setting up (pluginsync enabled, +etc.), mention it here. + +### Beginning with eyplib + +The very basic steps needed for a user to get the module up and running. + +If your most recent release breaks compatibility or requires particular steps +for upgrading, you may wish to include an additional section here: Upgrading +(For an example, see http://forge.puppetlabs.com/puppetlabs/firewall). + +## Usage + +Put the classes, types, and resources for customizing, configuring, and doing +the fancy stuff with your module here. + +## Reference + +Here, list the classes, types, providers, facts, etc contained in your module. +This section should include all of the under-the-hood workings of your module so +people know what the module is touching on their system but don't need to mess +with things. (We are working on automating this section!) + +## Limitations + +This is where you list OS compatibility, version compatibility, etc. + +## 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 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..39246f9 --- /dev/null +++ b/Rakefile @@ -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 diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..e2ba650 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,12 @@ +# == Class: eyplib +# +# === eyplib documentation +# +class eyplib inherits eyplib::params{ + + # service definition and notification: + # + # notify => Class['eyplib::service'], + # class { 'eyplib::service': } + +} diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..326f6ba --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,35 @@ +class eyplib::params { + + case $::osfamily + { + 'redhat': + { + case $::operatingsystemrelease + { + /^[5-7].*$/: + { + } + default: { fail("Unsupported RHEL/CentOS version! - ${::operatingsystemrelease}") } + } + } + 'Debian': + { + case $::operatingsystem + { + 'Ubuntu': + { + case $::operatingsystemrelease + { + /^14.*$/: + { + } + default: { fail("Unsupported Ubuntu version! - ${::operatingsystemrelease}") } + } + } + 'Debian': { fail('Unsupported') } + default: { fail('Unsupported Debian flavour!') } + } + } + default: { fail('Unsupported OS!') } + } +} diff --git a/manifests/service.pp b/manifests/service.pp new file mode 100644 index 0000000..ca60e15 --- /dev/null +++ b/manifests/service.pp @@ -0,0 +1,25 @@ +class eyplib::service ( + $manage_service=true, + $manage_docker_service=true, + $ensure ='running', + $enable =true, + ) inherits eyplib::params { + + # + validate_bool($manage_docker_service) + validate_bool($manage_service) + validate_bool($enable) + + validate_re($ensure, [ '^running$', '^stopped$' ], "Not a valid daemon status: ${ensure}") + + if(getvar('::eyp_docker_iscontainer')==undef or + getvar('::eyp_docker_iscontainer')==false or + getvar('::eyp_docker_iscontainer') =~ /false/ or + $manage_docker_service) + { + if($manage_service) + { + #service or exec here + } + } +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..86c5d04 --- /dev/null +++ b/metadata.json @@ -0,0 +1,49 @@ +{ + "name": "eyp-eyplib", + "version": "0.1.0", + "author": "eyp", + "summary": null, + "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" + } + ] +} diff --git a/spec/acceptance/base_spec.rb b/spec/acceptance/base_spec.rb new file mode 100644 index 0000000..4c8d81b --- /dev/null +++ b/spec/acceptance/base_spec.rb @@ -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 diff --git a/spec/acceptance/nodesets/centos5-docker.yml b/spec/acceptance/nodesets/centos5-docker.yml new file mode 100644 index 0000000..563ebd2 --- /dev/null +++ b/spec/acceptance/nodesets/centos5-docker.yml @@ -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 diff --git a/spec/acceptance/nodesets/centos6-docker.yml b/spec/acceptance/nodesets/centos6-docker.yml new file mode 100644 index 0000000..b54ef32 --- /dev/null +++ b/spec/acceptance/nodesets/centos6-docker.yml @@ -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 diff --git a/spec/acceptance/nodesets/centos7-docker.yml b/spec/acceptance/nodesets/centos7-docker.yml new file mode 100644 index 0000000..e99b37c --- /dev/null +++ b/spec/acceptance/nodesets/centos7-docker.yml @@ -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 diff --git a/spec/acceptance/nodesets/ubuntu14-docker.yml b/spec/acceptance/nodesets/ubuntu14-docker.yml new file mode 100644 index 0000000..82cf2a8 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu14-docker.yml @@ -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 diff --git a/spec/acceptance/version.rb b/spec/acceptance/version.rb new file mode 100644 index 0000000..a744070 --- /dev/null +++ b/spec/acceptance/version.rb @@ -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 diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb new file mode 100644 index 0000000..4682249 --- /dev/null +++ b/spec/classes/init_spec.rb @@ -0,0 +1,36 @@ + +require 'spec_helper' + +describe 'eyplib' do + context 'supported operating systems' do + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts + end + + context "eyplib class without any parameters" do + it { is_expected.to compile.with_all_deps } + + it { is_expected.to contain_service('eyplib') } + it { is_expected.to contain_package('eyplib').with_ensure('present') } + end + end + end + end + + context 'unsupported operating system' do + describe 'eyplib class without any parameters' do + let(:facts) do + { + :osfamily => 'SOFriki', + :operatingsystem => 'SOFregit', + } + end + + it { + expect { should raise_error(Puppet::Error) } + } + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2c6f566 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..07ff720 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,22 @@ +require 'beaker-rspec' +require 'beaker/puppet_install_helper' + +run_puppet_install_helper + +RSpec.configure do |c| + # Project root + proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + # Readable test descriptions + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module and dependencies + puppet_module_install(:source => proj_root, :module_name => 'eyplib') + hosts.each do |host| + # dependencies + on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + end + end +end diff --git a/tests/init.pp b/tests/init.pp new file mode 100644 index 0000000..5ca606e --- /dev/null +++ b/tests/init.pp @@ -0,0 +1,12 @@ +# The baseline for module testing used by Puppet Labs is that each manifest +# should have a corresponding test manifest that declares that class or defined +# type. +# +# Tests are then run by using puppet apply --noop (to check for compilation +# errors and view a log of events) or by fully applying the test in a virtual +# environment (to compare the resulting system state to the desired state). +# +# Learn more about module testing here: +# http://docs.puppetlabs.com/guides/tests_smoke.html +# +include eyplib From 1c33c55aa2505f7cfbb73d0288cf720d2892cdc5 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Mon, 7 Mar 2016 18:55:54 +0100 Subject: [PATCH 2/7] afegides funcions --- lib/puppet/parser/functions/bool2onoff.rb | 27 +++++++++++++++++++++++ lib/puppet/parser/functions/bool2yesno.rb | 17 ++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 lib/puppet/parser/functions/bool2onoff.rb create mode 100644 lib/puppet/parser/functions/bool2yesno.rb diff --git a/lib/puppet/parser/functions/bool2onoff.rb b/lib/puppet/parser/functions/bool2onoff.rb new file mode 100644 index 0000000..e2b4e77 --- /dev/null +++ b/lib/puppet/parser/functions/bool2onoff.rb @@ -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: info@puppetlabs.com +# +#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 diff --git a/lib/puppet/parser/functions/bool2yesno.rb b/lib/puppet/parser/functions/bool2yesno.rb new file mode 100644 index 0000000..778a7e0 --- /dev/null +++ b/lib/puppet/parser/functions/bool2yesno.rb @@ -0,0 +1,17 @@ +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 From 285847eebbd03f6731ffb1c01021a0d5e9233f75 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 8 Mar 2016 11:03:24 +0100 Subject: [PATCH 3/7] llicencia --- lib/puppet/parser/functions/bool2yesno.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/puppet/parser/functions/bool2yesno.rb b/lib/puppet/parser/functions/bool2yesno.rb index 778a7e0..6cd326d 100644 --- a/lib/puppet/parser/functions/bool2yesno.rb +++ b/lib/puppet/parser/functions/bool2yesno.rb @@ -1,3 +1,14 @@ +#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: info@puppetlabs.com +# +#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' From 87ee1dddc0ee461b28c3ea5df643de1463f597b4 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 8 Mar 2016 11:16:32 +0100 Subject: [PATCH 4/7] docs --- README.md | 56 +++++++++++++++++++++------------------------------ metadata.json | 2 +- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 7f7b0b1..05f70da 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # eyplib +![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg) + #### Table of Contents 1. [Overview](#overview) @@ -7,66 +9,54 @@ 3. [Setup](#setup) * [What eyplib affects](#what-eyplib-affects) * [Setup requirements](#setup-requirements) - * [Beginning with eyplib](#beginning-with-eyplib) 4. [Usage](#usage) 5. [Reference](#reference) -5. [Limitations](#limitations) 6. [Development](#development) * [Contributing](#contributing) ## Overview -A one-maybe-two sentence summary of what the module does/what problem it solves. -This is your 30 second elevator pitch for your module. Consider including -OS/Puppet version it works with. +Standard library of resources for Puppet modules. ## Module Description -If applicable, this section should have a brief description of the technology -the module integrates with and what that integration enables. This section -should answer the questions: "What does this module *do*?" and "Why would I use -it?" - -If your module has a range of functionality (installation, configuration, -management, etc.) this is the time to mention it. +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 -* A list of files, packages, services, or operations that the module will alter, - impact, or execute on the system it's installed on. -* This is a great place to stick any warnings. -* Can be in list or paragraph form. +After you've installed eyplib, all of its functions, facts, and resources are already available. ### Setup Requirements -If your module requires anything extra before setting up (pluginsync enabled, -etc.), mention it here. +Requires pluginsync enabled -### Beginning with eyplib +## Usage -The very basic steps needed for a user to get the module up and running. +Just add a dependency on your metadata.json file, for example: -If your most recent release breaks compatibility or requires particular steps -for upgrading, you may wish to include an additional section here: Upgrading -(For an example, see http://forge.puppetlabs.com/puppetlabs/firewall). +```json +"dependencies": [ + {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0"}, + {"name":"puppetlabs/concat","version_requirement":">= 1.2.3"}, + {"name":"eyp/eyplib","version_requirement":">= 0.0.1 < 0.1.0"} +], +``` -## Usage +## Reference -Put the classes, types, and resources for customizing, configuring, and doing -the fancy stuff with your module here. +### functions -## Reference +#### bool2onoff -Here, list the classes, types, providers, facts, etc contained in your module. -This section should include all of the under-the-hood workings of your module so -people know what the module is touching on their system but don't need to mess -with things. (We are working on automating this section!) +Transform a boolean (it can also be a string) to **On** or **Off**. Other values through. -## Limitations +#### bool2yesno -This is where you list OS compatibility, version compatibility, etc. +Transform a boolean (it can also be a string) to **yes** or **no**. Other values through. ## Development diff --git a/metadata.json b/metadata.json index 86c5d04..ca8803e 100644 --- a/metadata.json +++ b/metadata.json @@ -2,7 +2,7 @@ "name": "eyp-eyplib", "version": "0.1.0", "author": "eyp", - "summary": null, + "summary": "Utility functions for puppet modules", "license": "Apache-2.0", "source": "https://github.com/AtlasIT-AM/eyp-eyplib", "project_page": null, From 794d9c911e4f84b7cd3f90371839289950b7ba99 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 8 Mar 2016 11:18:21 +0100 Subject: [PATCH 5/7] fora merda --- manifests/params.pp | 35 ----------------------------------- manifests/service.pp | 25 ------------------------- 2 files changed, 60 deletions(-) delete mode 100644 manifests/params.pp delete mode 100644 manifests/service.pp diff --git a/manifests/params.pp b/manifests/params.pp deleted file mode 100644 index 326f6ba..0000000 --- a/manifests/params.pp +++ /dev/null @@ -1,35 +0,0 @@ -class eyplib::params { - - case $::osfamily - { - 'redhat': - { - case $::operatingsystemrelease - { - /^[5-7].*$/: - { - } - default: { fail("Unsupported RHEL/CentOS version! - ${::operatingsystemrelease}") } - } - } - 'Debian': - { - case $::operatingsystem - { - 'Ubuntu': - { - case $::operatingsystemrelease - { - /^14.*$/: - { - } - default: { fail("Unsupported Ubuntu version! - ${::operatingsystemrelease}") } - } - } - 'Debian': { fail('Unsupported') } - default: { fail('Unsupported Debian flavour!') } - } - } - default: { fail('Unsupported OS!') } - } -} diff --git a/manifests/service.pp b/manifests/service.pp deleted file mode 100644 index ca60e15..0000000 --- a/manifests/service.pp +++ /dev/null @@ -1,25 +0,0 @@ -class eyplib::service ( - $manage_service=true, - $manage_docker_service=true, - $ensure ='running', - $enable =true, - ) inherits eyplib::params { - - # - validate_bool($manage_docker_service) - validate_bool($manage_service) - validate_bool($enable) - - validate_re($ensure, [ '^running$', '^stopped$' ], "Not a valid daemon status: ${ensure}") - - if(getvar('::eyp_docker_iscontainer')==undef or - getvar('::eyp_docker_iscontainer')==false or - getvar('::eyp_docker_iscontainer') =~ /false/ or - $manage_docker_service) - { - if($manage_service) - { - #service or exec here - } - } -} From a4de01b1ec3a0e85c468e4235e310d3b5c2f3b80 Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 8 Mar 2016 11:19:13 +0100 Subject: [PATCH 6/7] comentari --- manifests/init.pp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index e2ba650..298133b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,9 +4,6 @@ # class eyplib inherits eyplib::params{ - # service definition and notification: - # - # notify => Class['eyplib::service'], - # class { 'eyplib::service': } + # nothing to do here } From a50908ea621c9842fe1e149fed6169b109986acf Mon Sep 17 00:00:00 2001 From: Jordi Prats Date: Tue, 8 Mar 2016 11:35:37 +0100 Subject: [PATCH 7/7] =?UTF-8?q?corretgida=20documentaci=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- metadata.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 05f70da..6f1da40 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Just add a dependency on your metadata.json file, for example: "dependencies": [ {"name":"puppetlabs/stdlib","version_requirement":">= 4.6.0"}, {"name":"puppetlabs/concat","version_requirement":">= 1.2.3"}, - {"name":"eyp/eyplib","version_requirement":">= 0.0.1 < 0.1.0"} + {"name":"eyp/eyplib","version_requirement":">= 0.1.0 < 0.2.0"} ], ``` diff --git a/metadata.json b/metadata.json index ca8803e..d08a07f 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "eyp-eyplib", - "version": "0.1.0", + "version": "0.1.1", "author": "eyp", "summary": "Utility functions for puppet modules", "license": "Apache-2.0",