Skip to content

Commit

Permalink
Merge pull request #3 from andskli/develop
Browse files Browse the repository at this point in the history
Version 0.1.1
  • Loading branch information
andskli committed Apr 15, 2016
2 parents da15d48 + 1e589d0 commit 963407c
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 202 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.bundle/
Gemfile.lock
pkg/
51 changes: 39 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
---
language: ruby
bundler_args: --without development
sudo: false

rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.0
- ruby-head

script:
- "bundle install"
- "bundle exec rake validate"
- "bundle exec rake lint"
- "bundle exec rake spec SPEC_OPTS='--format documentation'"
- "SPEC_OPTS='--format documentation' bundle exec rake spec"

env:
- PUPPET_VERSION=3.3
- PUPPET_VERSION=3.7.2
matrix:
- PUPPET_GEM_VERSION="~> 3.1.0"
- PUPPET_GEM_VERSION="~> 3.2.0"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.0"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
- PUPPET_GEM_VERSION="~> 3.8.0"
- PUPPET_GEM_VERSION="~> 3"
- PUPPET_GEM_VERSION="~> 4.0.0"
- PUPPET_GEM_VERSION="~> 4.1.0"
- PUPPET_GEM_VERSION="~> 4.2.0"
- PUPPET_GEM_VERSION="~> 4.3.0"
- PUPPET_GEM_VERSION="~> 4"
- PUPPET_GEM_VERSION="~> 4"

matrix:
# allow_failures:
# - rvm: ruby-head
fast_finish: true
exclude:
- rvm: ruby-head
gemfile: Gemfile
# build only these
branches:
only:
- master

- rvm: 2.0.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.1.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.2.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.1.0
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 1.9.3
env: PUPPET_GE3M_VERSION="~> 4"
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ source 'https://rubygems.org'

#puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
#gem 'puppet', puppetversion
gem 'metadata-json-lint'
gem 'puppet', '>= 3.3'
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
Expand Down
23 changes: 18 additions & 5 deletions lib/facter/netbackup.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
Facter.add('netbackup_client_name') do
setcode do
client_name = Facter::Util::Resolution.exec('/usr/openv/netbackup/bin/nbgetconfig CLIENT_NAME')
client_name.split[2]
if File.exist? '/usr/openv/netbackup/bin/nbgetconfig'
client_name = Facter::Util::Resolution.exec('/usr/openv/netbackup/bin/nbgetconfig CLIENT_NAME')
client_name.split[2]
elsif File.exist? '/usr/openv/netbackup/bp.conf'
client_name = Facter::Util::Resolution.exec('/bin/grep CLIENT_NAME /usr/openv/netbackup/bp.conf')
client_name.split[2]
end
end
end


Facter.add('netbackup_serverlist') do
setcode do
server_rows = Facter::Util::Resolution.exec('/usr/openv/netbackup/bin/nbgetconfig SERVER').split("\n")
servers = server_rows.map! { |x| x.split[2] }
servers
if File.exist? '/usr/openv/netbackup/bin/nbgetconfig'
server_rows = Facter::Util::Resolution.exec('/usr/openv/netbackup/bin/nbgetconfig SERVER').split("\n")
servers = server_rows.map! { |x| x.split[2] }
servers
elsif File.exist? '/usr/openv/netbackup/bp.conf'
server_rows = Facter::Util::Resolution.exec('/bin/grep SERVER /usr/openv/netbackup/bp.conf').split("\n")
servers = server_rows.map! { |x| x.split[2] }
servers
end
end
end


# @todo Ugly code?
Facter.add('netbackup_version') do
setcode do
Expand Down
47 changes: 7 additions & 40 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,17 @@
$mediaservers = undef,
$service_enabled = true,
$excludes = undef,
) {
$tmpinstaller = '/tmp'
)
{

if versioncmp($version, $::netbackup_version) < 1 {
notice("Installed version ${::netbackup_version} newer or equal to ${version}, not installing")
class { 'netbackup::client::config': }
}
if versioncmp($version, $::netbackup_version) == 1 {
else {
notice ("Found NetBackup version: ${::netbackup_version}, have newer ${version} which I'll install using class netbackup::client::install")
class { 'netbackup::client::install': }
class { 'netbackup::client::install': } -> class { 'netbackup::client::config': }
}

file { '/usr/openv/netbackup':
ensure => directory,
}

file { 'bp.conf':
ensure => file,
path => '/usr/openv/netbackup/bp.conf',
owner => 'root',
group => 'root',
mode => '0644',
content => template('netbackup/bp.conf.erb'),
require => File['/usr/openv/netbackup'],
}

# Only define netbackup init service if netbackup_version fact is set
if $::netbackup_version != undef {
service { 'netbackup-client':
ensure => $service_enabled,
name => 'netbackup',
hasrestart => false,
hasstatus => false,
pattern => 'bpcd',
}
}

if $excludes != undef {
file { 'exclude_list':
ensure => file,
path => '/usr/openv/netbackup/exclude_list',
owner => 'root',
group => 'root',
mode => '0644',
content => template('netbackup/exclude_list.erb'),
}
}


}
41 changes: 41 additions & 0 deletions manifests/client/config.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class netbackup::client::config (
$clientname = $netbackup::client::clientname,
$masterserver = $netbackup::client::masterserver,
$mediaservers = $netbackup::client::mediaservers,
$service_enabled = $netbackup::client::service_enabled,
$excludes = $netbackup::client::excludes,
){

file { 'bp.conf':
ensure => file,
path => '/usr/openv/netbackup/bp.conf',
owner => 'root',
group => 'root',
mode => '0644',
content => template('netbackup/bp.conf.erb'),
}

# Only define netbackup init service if netbackup_version fact is set
if $::netbackup_version != undef {
service { 'netbackup-client':
ensure => $service_enabled,
name => 'netbackup',
hasrestart => false,
hasstatus => false,
pattern => 'bpcd',
provider => init,
require => File['bp.conf']
}
}

if $excludes != undef {
file { 'exclude_list':
ensure => file,
path => '/usr/openv/netbackup/exclude_list',
owner => 'root',
group => 'root',
mode => '0644',
content => template('netbackup/exclude_list.erb'),
}
}
}
19 changes: 10 additions & 9 deletions manifests/client/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
$version = $netbackup::client::version,
$masterserver = $netbackup::client::masterserver,
$clientname = $netbackup::client::clientname,
$tmpinstaller = $netbackup::client::tmpinstaller
){

file { 'install_netbackup_client.expect':
path => '/tmp/install_netbackup_client.expect',
owner => 'root',
group => 'root',
mode => '0744',
content => template('netbackup/install_netbackup_client.expect.erb'),
path => "${tmpinstaller}/install_netbackup_client.expect",
owner => 'root',
group => 'root',
mode => '0744',
content => template('netbackup/install_netbackup_client.expect.erb'),
}

package { 'expect':
ensure => installed,
}

exec { 'run-netbackup-install':
command => 'expect /tmp/install_netbackup_client.expect',
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
require => [Package['expect'], File['install_netbackup_client.expect']],
unless => "grep ${version} /usr/openv/netbackup/bin/version",
command => "expect ${tmpinstaller}/install_netbackup_client.expect",
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
require => [Package['expect'], File['install_netbackup_client.expect']],
unless => "grep ${version} /usr/openv/netbackup/bin/version",
}

}
10 changes: 5 additions & 5 deletions manifests/server/prepare.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# START Pre-checks
include limits
limits::limits { 'netbackup_nofile':
ensure => present,
user => '*',
limit_type => 'nofile',
hard => 65440,
soft => 8000,
ensure => present,
user => '*',
limit_type => 'nofile',
hard => 65440,
soft => 8000,
}

sysctl { 'kernel.sem': value => '300 307200 32 1024', }
Expand Down
Loading

0 comments on commit 963407c

Please sign in to comment.