Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import

  • Loading branch information...
commit 2e339364ab04eeb1c237b7855e71617f92de0d9b 0 parents
@bklang bklang authored
2  .gitignore
@@ -0,0 +1,2 @@
+/Gemfile.lock
+.*.sw*
8 Gemfile
@@ -0,0 +1,8 @@
+source :rubygems
+
+gem 'puppet'
+
+group :development, :test do
+ gem 'rspec'
+ gem 'rspec-puppet'
+end
10 Modulefile
@@ -0,0 +1,10 @@
+name 'asterisk'
+version '0.1.0'
+source 'git://github.com/mojolingo/asterisk.git'
+author 'Ben Klang'
+license 'MIT'
+summary 'Module for installing Asterisk'
+description 'Sets up the Digium package repository where appropriate and ensures Asterisk packages are installed'
+project_page 'https://github.com/mojolingo/puppet-asterisk'
+#dependency 'puppetlabs/stdlib'
+dependency 'puppetlabs/apt'
22 Rakefile
@@ -0,0 +1,22 @@
+require 'rubygems'
+require 'rake'
+require 'rspec/core/rake_task'
+
+task :default do
+ system("rake -T")
+end
+
+task :specs => [:spec]
+
+desc "Run all rspec-puppet tests"
+RSpec::Core::RakeTask.new(:spec) do |t|
+ t.rspec_opts = ['--color']
+ # ignores fixtures directory.
+ t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
+end
+
+desc "Build package"
+task :build do
+ system("puppet-module build")
+end
+
19 manifests/init.pp
@@ -0,0 +1,19 @@
+class asterisk(
+ $packager = 'digium,
+ $version = '1.8',
+) {
+
+ asterisk::source($packager)
+
+ package { "asterisk-${version}":
+ # TODO Support CentOS/RedHat
+ require => Apt::Source['digium'],
+ ensure => latest,
+ }
+
+ service { "asterisk":
+ ensure => running,
+ subscribe => Package["asterisk-${version}"],
+ }
+
+}
19 manifests/source.pp
@@ -0,0 +1,19 @@
+define asterisk::source(
+ $packager = 'digium',
+) {
+ case $operatingsystem {
+ debian, ubuntu: {
+ case $packager {
+ digium: {
+ import 'apt'
+ apt::source { 'digium':
+ location => "http://packages.asterisk.org/deb",
+ release => $lsbdistcodename,
+ repos => 'main',
+ key => '175E41DF',
+ }
+ }
+ }
+ }
+ }
+}
27 spec/classes/asterisk_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+describe 'asterisk' do
+ let :pre_condition do
+ 'class { "apt": }'
+ end
+
+ let :facts do
+ {:lsbdistcodename => 'karmic'}
+ end
+
+ describe 'sources' do
+ it { should contain_apt__add(
+ "deb http://packages.asterisk.org/deb lucid main").with(
+ "apt_name" => "digium")}
+
+ it { should contain_apt__add(
+ "deb-src http://packages.asterisk.org/deb lucid main").with(
+ "apt_name" => "digum-src",
+ "require" => "Apt::Add[deb http://packages.asterisk.org/deb lucid main]")}
+
+ it { should contain_package(
+ "asterisk-1.8").with(
+ "ensure" => "installed",
+ "require" => "Exec[apt-update-key]")}
+ end
+
+end
0  spec/fixtures/manifests/site.pp
No changes.
14 spec/spec_helper.rb
@@ -0,0 +1,14 @@
+require 'puppet'
+require 'rubygems'
+require 'rspec-puppet'
+
+def param_value(subject, type, title, param)
+ subject.resource(type, title).send(:parameters)[param.to_sym]
+end
+
+RSpec.configure do |c|
+ c.module_path = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
+# c.module_path = File.expand_path(File.join(File.dirname(__FILE__), '../../puppet-apt'))
+ # Using an empty site.pp file to avoid: https://github.com/rodjek/rspec-puppet/issues/15
+ c.manifest_dir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/manifests'))
+end
Please sign in to comment.
Something went wrong with that request. Please try again.