Skip to content

Commit

Permalink
Merge pull request #16 from sugarlosses/dynamic_pkg_name
Browse files Browse the repository at this point in the history
Added the possibility to specify the package names
  • Loading branch information
jdowning committed Feb 26, 2016
2 parents f4cdb91 + 02dc1b4 commit 5997a17
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 14 deletions.
8 changes: 4 additions & 4 deletions manifests/deps/debian.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
8 changes: 4 additions & 4 deletions manifests/deps/osx.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
8 changes: 4 additions & 4 deletions manifests/deps/redhat.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
16 changes: 14 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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: }
Expand All @@ -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':
Expand Down
22 changes: 22 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -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}") }
}
}
15 changes: 15 additions & 0 deletions tests/params.pp
Original file line number Diff line number Diff line change
@@ -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'
}

0 comments on commit 5997a17

Please sign in to comment.