Browse Source

init: Install basic packages (libs, tools, core)

Sebastien Badia 8 years ago
parent
commit
a96b51ee1b
3 changed files with 50 additions and 24 deletions
  1. 17 21
      manifests/init.pp
  2. 20 0
      manifests/params.pp
  3. 13 3
      spec/classes/init_spec.rb

+ 17 - 21
manifests/init.pp

@@ -6,43 +6,39 @@
 # Parameters
 # ----------
 #
-# Document parameters here.
+# [*packages*]
+#   Packages for a ganeti cluster.
 #
-# * `sample parameter`
-# Explanation of what this parameter affects and what it defaults to.
-# e.g. "Specify one or more upstream ntp servers as an array."
+# [*packages_libs*]
+#   Libs packages for a ganeti cluster.
 #
-# Variables
-# ----------
-#
-# Here you should define a list of variables that this module would require.
-#
-# * `sample variable`
-#  Explanation of how this variable affects the function of this class and if
-#  it has a default. e.g. "The parameter enc_ntp_servers must be set by the
-#  External Node Classifier as a comma separated list of hostnames." (Note,
-#  global variables should be avoided in favor of class parameters as
-#  of Puppet 2.6.)
+# [*packages_tools*]
+#   Tools packages for a ganeti cluster.
 #
 # Examples
 # --------
 #
 # @example
-#    class { 'ganeti':
-#      servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
-#    }
+#    class { 'ganeti': }
 #
 # Authors
 # -------
 #
-# Author Name <author@domain.com>
+# Lorraine Data Network <contact@ldn-fai.net>
 #
 # Copyright
 # ---------
 #
-# Copyright 2016 Your name here, unless otherwise noted.
+# Copyright 2016 Lorraine Data Network, unless otherwise noted.
 #
-class ganeti {
+class ganeti (
+  $packages       = $ganeti::params::packages,
+  $packages_libs  = $ganeti::params::packages_libs,
+  $packages_tools = $ganeti::params::packages_tools,
+) inherits ganeti::params {
 
+  package { $packages: ensure => installed; }
+  package { $packages_libs: ensure => installed; }
+  package { $packages_tools: ensure => installed; }
 
 }

+ 20 - 0
manifests/params.pp

@@ -0,0 +1,20 @@
+# Class:: ganeti::params
+#
+class ganeti::params {
+  case $::osfamily {
+    'Debian': {
+      $packages = ['ganeti','ganeti-doc','qemu-kvm']
+      $packages_libs = ['python-openssl','python-pyparsing',
+                        'python-simplejson','python-bitarray',
+                        'python-pyinotify','python-pycurl',
+                        'python-ipaddr','python-paramiko',
+                        'python-pip','python-dev']
+      $packages_tools = ['lvm2','bridge-utils','iproute',
+                        'iputils-arping','openssl','socat',
+                        'fping','python']
+    }
+    default: {
+      fail("Unsupported osfamily: ${::osfamily}")
+    }
+  }
+} # Class:: ganeti::params

+ 13 - 3
spec/classes/init_spec.rb

@@ -1,6 +1,16 @@
 require 'spec_helper'
-describe 'ganeti' do
-  context 'with default values for all parameters' do
-    it { should contain_class('ganeti') }
+
+describe 'ganeti', :type => :class  do
+
+  describe 'On an unknown operating system' do
+    let(:facts) {{ :osfamily => 'Unknown' }}
+    it { expect { catalogue }.to raise_error(Puppet::Error, /Unsupported osfamily/) }
   end
+
+  describe "On Debian" do
+    let(:facts) {{ :osfamily => 'Debian' }}
+    it { is_expected.to contain_class("ganeti::params") }
+    it { is_expected.to contain_package('ganeti') }
+  end
+
 end