From 02dc1b4221ab60857c37d2e79f29c9b9de00d2b7 Mon Sep 17 00:00:00 2001 From: Luis Osses Lopez Date: Tue, 2 Jun 2015 19:41:24 +0200 Subject: [PATCH] Added the possibility to specify the package names This will update the compatibility to be used in Debian 8.0 (or possibly others) and using specific versions of the Python packages --- manifests/deps/debian.pp | 8 ++++---- manifests/deps/osx.pp | 8 ++++---- manifests/deps/redhat.pp | 8 ++++---- manifests/init.pp | 16 ++++++++++++++-- manifests/params.pp | 22 ++++++++++++++++++++++ tests/params.pp | 15 +++++++++++++++ 6 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 manifests/params.pp create mode 100644 tests/params.pp diff --git a/manifests/deps/debian.pp b/manifests/deps/debian.pp index e9f85ef..9dd2683 100644 --- a/manifests/deps/debian.pp +++ b/manifests/deps/debian.pp @@ -3,10 +3,10 @@ # This module manages awscli dependencies for Debian $::osfamily. # class awscli::deps::debian { - if ! defined(Package['python-dev']) { - package { 'python-dev': ensure => installed } + if ! defined(Package[ $awscli::pkg_dev ]) { + package { $awscli::pkg_dev: ensure => installed } } - if ! defined(Package['python-pip']) { - package { 'python-pip': ensure => installed } + if ! defined(Package[ $awscli::pkg_pip ]) { + package { $awscli::pkg_pip: ensure => installed } } } diff --git a/manifests/deps/osx.pp b/manifests/deps/osx.pp index 71775ef..49f5638 100644 --- a/manifests/deps/osx.pp +++ b/manifests/deps/osx.pp @@ -3,10 +3,10 @@ # This module manages awscli dependencies for Darwin $::osfamily. # class awscli::deps::osx { - if ! defined(Package['python']) { - package { 'python': ensure => installed, provider => homebrew } + if ! defined(Package[ $awscli::pkg_dev ]) { + package { $awscli::pkg_dev: ensure => installed, provider => homebrew } } - if ! defined(Package['brew-pip']) { - package { 'brew-pip': ensure => installed, provider => homebrew } + if ! defined(Package[ $awscli::pkg_pip ]) { + package { $awscli::pkg_pip: ensure => installed, provider => homebrew } } } diff --git a/manifests/deps/redhat.pp b/manifests/deps/redhat.pp index 21b9bca..f0e7ba9 100644 --- a/manifests/deps/redhat.pp +++ b/manifests/deps/redhat.pp @@ -6,10 +6,10 @@ include ::epel Package { require => Class['epel'] } - if ! defined(Package['python-devel']) { - package { 'python-devel': ensure => installed } + if ! defined(Package[ $awscli::pkg_dev ]) { + package { $awscli::pkg_dev: ensure => installed } } - if ! defined(Package['python-pip']) { - package { 'python-pip': ensure => installed } + if ! defined(Package[ $awscli::pkg_pip ]) { + package { $awscli::pkg_pip: ensure => installed } } } diff --git a/manifests/init.pp b/manifests/init.pp index 7c027a5..cff2ae9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -9,6 +9,16 @@ # Default: 'present' # This variable is required. # +# [$pkg_dev] +# Provides ability to install a specific Dev package by name. +# Default: See awscli::params Class +# This variable is optional. +# +# [$pkg_pip] +# Provides ability to install a specific PIP package by name. +# Default: See awscli::params Class +# This variable is optional. +# # === Examples # # class { awscli: } @@ -22,8 +32,10 @@ # Copyright 2014 Justin Downing # class awscli ( - $version = 'present' -) { + $version = 'present', + $pkg_dev = $awscli::params::pkg_dev, + $pkg_pip = $awscli::params::pkg_pip +) inherits awscli::params { include awscli::deps package { 'awscli': diff --git a/manifests/params.pp b/manifests/params.pp new file mode 100644 index 0000000..fd2bdd0 --- /dev/null +++ b/manifests/params.pp @@ -0,0 +1,22 @@ +# == Class: awscli::params +# +# This class manages awscli parameters depending on the platform and +# should *not* be called directly. +# +class awscli::params { + case $::osfamily { + 'Debian': { + $pkg_dev = 'python-dev' + $pkg_pip = 'python-pip' + } + 'RedHat': { + $pkg_dev = 'python-devel' + $pkg_pip = 'python-pip' + } + 'Darwin': { + $pkg_dev = 'python' + $pkg_pip = 'brew-pip' + } + default: { fail("The awscli module does not support ${::osfamily}") } + } +} diff --git a/tests/params.pp b/tests/params.pp new file mode 100644 index 0000000..c871326 --- /dev/null +++ b/tests/params.pp @@ -0,0 +1,15 @@ +# 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 +# +class {'awscli': + pkg_dev => 'python', + pkg_pip => 'brew-pip' +}