Skip to content

Commit

Permalink
Begin migration to exclusive puppet4 support
Browse files Browse the repository at this point in the history
This work drops support for puppet 3.x, using native type validation and
data in modules, updates build matrix to drop older Puppet builds, uses
rspec-puppet-facts to improve testing.
  • Loading branch information
zachfi committed Jul 29, 2016
1 parent 3427e0d commit bb1a2cc
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 696 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Gemfile.lock
.bundle
pkg/
spec/fixtures/manifests
spec/fixtures/modules
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ rvm:
- 2.1.0
script: bundle exec rake test
env:
- PUPPET_VERSION="~> 3.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.6.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.7.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 3.8.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 4.0.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 4.1.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 4.2.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 4.3.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 4.4.0" STRICT_VARIABLES=yes
- PUPPET_VERSION="~> 4.5.0" STRICT_VARIABLES=yes
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased
- native puppet4
- external database
- drop suppoort for puppet 3.x
- database maketables script has been removed in favor of packaged scripts
- changelog

## 2016-04-04 3.0.1
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"

group :test do
gem "rake"
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.8.0'
gem "puppet", ENV['PUPPET_VERSION'] || '~> 4.5.0'
gem "puppet-lint"
gem 'rspec'
gem 'rspec-core'
Expand All @@ -13,6 +13,7 @@ group :test do
gem "metadata-json-lint"
gem "puppet-syntax"
gem "puppetlabs_spec_helper"
gem "rspec-puppet-facts"
gem 'json', '~>1.0' if RUBY_VERSION == '1.9.3'
gem 'json_pure', '~>1.0' if RUBY_VERSION == '1.9.3'
end
Expand Down
128 changes: 0 additions & 128 deletions Gemfile.lock

This file was deleted.

2 changes: 2 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
bacula::director::postgresql::make_bacula_tables: ''
2 changes: 2 additions & 0 deletions data/os/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
bacula::director::postgresql::make_bacula_tables: '/usr/share/bacula-director/make_postgresql_tables'
2 changes: 2 additions & 0 deletions data/os/FreeBSD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
bacula::director::postgresql::make_bacula_tables: '/usr/local/share/bacula/make_postgresql_tables'
2 changes: 2 additions & 0 deletions data/os/OpenBSD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
bacula::director::postgresql::make_bacula_tables: '/usr/local/libexec/bacula/make_postgresql_tables'
3 changes: 3 additions & 0 deletions data/os/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bacula::director::postgresql::make_bacula_tables: '/usr/libexec/bacula/make_bacula_tables.postgresql'

9 changes: 9 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
version: 4
datadir: data
hierarchy:
- name: "OS family"
backend: yaml
path: "os/%{facts.os.family}"
- name: "common"
backend: yaml
1 change: 1 addition & 0 deletions manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

case $db_type {
/^(pgsql|postgresql)$/: { include bacula::director::postgresql }
'none': { }
default: { fail('No db_type set') }
}

Expand Down
20 changes: 6 additions & 14 deletions manifests/director/postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
# none
#
class bacula::director::postgresql(
$make_bacula_tables = "${bacula::params::homedir}/make_bacula_tables",
$db_name = $bacula::director::db_name,
$db_pw = $bacula::director::db_pw,
$db_user = $bacula::director::db_user,
$services = $bacula::params::bacula_director_services,
$user = $bacula::params::bacula_user,
String $make_bacula_tables = '',
String $db_name = $bacula::director::db_name,
String $db_pw = $bacula::director::db_pw,
String $db_user = $bacula::director::db_user,
Array $services = $bacula::params::bacula_director_services,
String $user = $bacula::params::bacula_user,
) inherits bacula::params {

require postgresql::server
Expand All @@ -25,20 +25,12 @@
locale => 'C',
}

file { $make_bacula_tables:
content => template('bacula/make_bacula_postgresql_tables.erb'),
owner => $user,
mode => '0750',
before => Exec["/bin/sh ${make_bacula_tables}"]
}

exec { "/bin/sh ${make_bacula_tables}":
user => $user,
refreshonly => true,
subscribe => Postgresql::Server::Db[$db_name],
notify => Service[$services],
require => [
File[$make_bacula_tables],
Postgresql::Server::Db[$db_name],
]
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

validate_bool($ssl)

if $::operatingsystem in ['RedHat', 'CentOS', 'Fedora', 'Scientific'] {
if $facts['operatingsystem'] in ['RedHat', 'CentOS', 'Fedora', 'Scientific'] {
$db_type = hiera('bacula::params::db_type', 'postgresql')
} else {
$db_type = hiera('bacula::params::db_type', 'pgsql')
Expand All @@ -24,7 +24,7 @@
$director_address = hiera('bacula::params::director_address', $director)
$job_tag = hiera('bacula::params::job_tag', '')

case $::operatingsystem {
case $facts['operatingsystem'] {
'Ubuntu','Debian': {
$bacula_director_packages = [ 'bacula-director-common', "bacula-director-${db_type}", 'bacula-console' ]
$bacula_director_services = [ 'bacula-director' ]
Expand Down Expand Up @@ -56,7 +56,7 @@
$bacula_group = $bacula_user
}
'RedHat','CentOS','Fedora','Scientific': {
if 0 + $::operatingsystemmajrelease < 7 or ($::operatingsystem == 'Fedora' and 0 + $::operatingsystemmajrelease < 17) {
if 0 + $facts['operatingsystemmajrelease'] < 7 or ($facts['operatingsystem'] == 'Fedora' and 0 + $facts['operatingsystemmajrelease'] < 17) {
$bacula_director_packages = [ 'bacula-director-common', "bacula-director-${db_type}", 'bacula-console' ]
$bacula_storage_packages = [ 'bacula-storage-common', "bacula-storage-${db_type}" ]
} else {
Expand Down Expand Up @@ -105,7 +105,7 @@
$bacula_user = '_bacula'
$bacula_group = '_bacula'
}
default: { fail("bacula::params has no love for ${::operatingsystem}") }
default: { fail("bacula::params has no love for ${facts['operatingsystem']}") }
}

$certfile = "${conf_dir}/ssl/${::clientcert}_cert.pem"
Expand Down
1 change: 1 addition & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"project_page": "https://github.com/xaque208/puppet-bacula",
"issues_url": "https://github.com/xaque208/puppet-bacula/issues",
"description": "It comes in the night...",
"data_provider": "hiera",
"dependencies": [
{"name":"puppetlabs/concat","version_requirement":">=1.0.0"},
{"name":"puppetlabs/stdlib","version_requirement":">=4.4.0"},
Expand Down
15 changes: 6 additions & 9 deletions spec/classes/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
require 'spec_helper'

describe 'bacula::client' do
require 'hiera'
let(:facts) {
{
:operatingsystem => 'Debian',
:concat_basedir => '/dne',
:ipaddress => '10.0.0.1'
}
}
it { should contain_class('bacula::client') }
on_supported_os.each do |os, facts|
let(:facts) { facts }
context "on #{os}" do
it { should contain_class('bacula::client') }
end
end
end

53 changes: 8 additions & 45 deletions spec/classes/director_spec.rb
Original file line number Diff line number Diff line change
@@ -1,52 +1,15 @@
require 'spec_helper'

describe 'bacula::director' do
require 'hiera'
context 'Debian' do
let(:facts) {
{
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:operatingsystemrelease => '7.0',
:concat_basedir => '/dne',
:ipaddress => '10.0.0.1'
}
}
it { should contain_class('bacula::director') }
end
context 'RedHat' do
let(:facts) {
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7.0',
:operatingsystemmajrelease => '7',
:concat_basedir => '/dne',
:ipaddress => '10.0.0.1'
}
}
it { should contain_class('bacula::director') }
context 'New packages' do
it { should contain_package('bacula-director').with(
'ensure' => 'present',
)
}
it { should_not contain_package('bacula-director-common') }
end
context 'Old packages' do
let(:facts) do
super().merge(
{
:operatingsystemrelease => '6.0',
:operatingsystemmajrelease => '6',
}
)
on_supported_os.each do |os, facts|
let(:facts) { facts }
context "on #{os}" do

case facts[:osfamily]
when 'Debian'
it { should contain_class('bacula::director') }
end
it { should contain_package('bacula-director-common').with(
'ensure' => 'present',
)
}
it { should_not contain_package('bacula-director') }

end
end
end
1 change: 1 addition & 0 deletions spec/classes/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

describe 'bacula::storage' do
require 'hiera'
let(:hiera_config) { 'hiera.yaml' }
context 'Debian' do
let(:facts) {
{
Expand Down
7 changes: 0 additions & 7 deletions spec/fixtures/hiera/hiera.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions spec/fixtures/hiera/test.yaml

This file was deleted.

Loading

0 comments on commit bb1a2cc

Please sign in to comment.