Skip to content

Commit bc0b2b4

Browse files
committed
Merge pull request #143 from rwaffen/fix_things
Fix things
2 parents 78c10b8 + 15772f2 commit bc0b2b4

10 files changed

Lines changed: 76 additions & 26 deletions

File tree

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
22

33
group :development, :test do
44
gem 'rake', :require => false
5-
gem 'rspec-puppet', :require => false, :git => 'https://github.com/rodjek/rspec-puppet.git'
5+
gem 'rspec-puppet', :require => false
66
gem 'puppetlabs_spec_helper', :require => false
77
gem 'puppet-lint', :require => false
88
gem 'simplecov', :require => false

Vagrantfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
2626
config.vm.define "centos" do |centos|
2727
centos.vm.box = "centos65_64"
2828
centos.vm.box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-puppet.box'
29-
centos.vm.provision "shell", inline: '/usr/bin/yum -y install https://yum.puppetlabs.com/el/6.5/products/x86_64/puppetlabs-release-6-10.noarch.rpm'
3029
centos.vm.provision "shell", inline: '/usr/bin/yum -y install puppet epel-release'
3130
centos.vm.provision "shell", inline: 'puppet module install puppetlabs-stdlib'
3231
centos.vm.provision "puppet" do |puppet|
3332
puppet.manifests_path = "manifests"
3433
puppet.manifest_file = "init.pp"
35-
puppet.options = ['--verbose', "-e 'class { one: oned => true, sunstone => true, }'"]
34+
puppet.options = [
35+
'--verbose',
36+
"-e 'class { one: oned => true, node => false, sunstone => true, }'"
37+
]
3638
end
3739
end
3840
end

manifests/compute_node/config.pp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,6 @@
114114
mode => '0771',
115115
}
116116

117-
file { '/var/lib/one/bin':
118-
ensure => directory,
119-
owner => 'oneadmin',
120-
group => 'oneadmin',
121-
mode => '0755',
122-
}
123-
124-
file { '/var/lib/one/etc':
125-
ensure => directory,
126-
owner => 'oneadmin',
127-
group => 'oneadmin',
128-
}
129-
130117
file { ['/var/lib/one/etc/kickstart.d',
131118
'/var/lib/one/etc/preseed.d']:
132119
ensure => directory,

manifests/config.pp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,17 @@
3939
file { '/var/lib/one/.ssh/config':
4040
source => 'puppet:///modules/one/ssh_one_config',
4141
}
42+
43+
file { '/var/lib/one/bin':
44+
ensure => directory,
45+
owner => 'oneadmin',
46+
group => 'oneadmin',
47+
mode => '0755',
48+
}
49+
50+
file { '/var/lib/one/etc':
51+
ensure => directory,
52+
owner => 'oneadmin',
53+
group => 'oneadmin',
54+
}
4255
}

manifests/init.pp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@
120120
$debug_level = '0',
121121
) {
122122
include one::params
123+
include one::install
124+
include one::config
125+
include one::service
126+
127+
Class['one::params'] ->
128+
Class['one::install']->
129+
Class['one::config']->
130+
Class['one::service']
131+
123132
if ($oned) {
124133
if ( member(['kvm','xen3','xen4','vmware','ec2', 'qemu'], $vtype) ) {
125134
if ( member(['802.1Q','ebtables','firewall','ovswitch'], $ntype) ) {
@@ -143,7 +152,4 @@
143152
if($onegate) {
144153
class {'one::oned::onegate': }
145154
}
146-
include one::install
147-
include one::config
148-
include one::service
149155
}

manifests/oned.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737
include one::params
3838
include one::install
3939
include one::service
40+
include one::config
4041
include one::oned::install
4142
include one::oned::config
4243
include one::oned::service
4344

4445
Class['one::prerequisites'] ->
4546
Class['one::params'] ->
4647
Class['one::install'] ->
48+
Class['one::config'] ->
4749
Class['one::oned::install'] ->
4850
Class['one::oned::config'] ~>
4951
Class['one::oned::service'] ~>

manifests/oned/config.pp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
$backup_intervall = $one::params::backup_intervall,
3636
$backup_keep = $one::params::backup_keep,
3737
$debug_level = $one::debug_level,
38+
$backend = $one::backend,
3839
) {
3940

4041
File {
@@ -43,9 +44,10 @@
4344
}
4445

4546
file { '/etc/one/oned.conf':
46-
content => template('one/oned.conf.erb'),
47+
ensure => 'file',
4748
owner => 'root',
4849
mode => '0640',
50+
content => template('one/oned.conf.erb'),
4951
}
5052

5153
file { '/usr/share/one':
@@ -63,14 +65,14 @@
6365
source => $hook_scripts_path,
6466
}
6567

66-
if ($one::backend == 'mysql') {
68+
if ($backend == 'mysql') {
6769
file { $backup_dir:
6870
ensure => 'directory',
6971
mode => '0700'
7072
}
7173

7274
file { $backup_script_path:
73-
ensure => present,
75+
ensure => 'file',
7476
mode => '0700',
7577
content => template('one/one_db_backup.sh.erb'),
7678
}

manifests/params.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
$one_repo_enable = hiera('one::enable_opennebula_repo', 'true' ),
4949

5050
$backup_script_path = hiera ('one::oned::backup::script_path', '/var/lib/one/bin/one_db_backup.sh'),
51-
$ssh_priv_key_param = hiera('one::head::ssh_priv_key',undef),
52-
$ssh_pub_key = hiera('one::head::ssh_pub_key',undef),
51+
$ssh_priv_key_param = hiera('one::head::ssh_priv_key',undef),
52+
$ssh_pub_key = hiera('one::head::ssh_pub_key',undef),
5353

5454
$xmlrpc_maxconn = hiera('one::oned::xmlrpc_maxconn', '15'),
5555
$xmlrpc_maxconn_backlog = hiera('one::oned::xmlrpc_maxconn_backlog', '15'),
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'spec_helper'
2+
require 'rspec-puppet'
3+
require 'hiera'
4+
require 'facter'
5+
6+
hiera_config = 'spec/fixtures/hiera/hiera.yaml'
7+
8+
describe 'one::oned::config' do
9+
let (:facts) { {:osfamily => 'RedHat'} }
10+
let (:hiera_config) { hiera_config }
11+
context 'general' do
12+
end
13+
context 'general' do
14+
it { should contain_class('one::oned::config') }
15+
it { should contain_file('/etc/one/oned.conf') \
16+
.with_ensure('file' )\
17+
.with_owner('root') \
18+
.with_mode('0640')
19+
}
20+
it { should contain_file('/usr/share/one/hooks') \
21+
.with_ensure('directory') \
22+
.with_mode('0750')
23+
}
24+
it { should contain_file('/usr/share/one').with_ensure('directory') }
25+
end
26+
context 'with mysql backend' do
27+
let (:params) { {
28+
:backend => 'mysql',
29+
:backup_script_path => '/var/lib/one/bin/one_db_backup.sh',
30+
:backup_dir => '/srv/backup'
31+
} }
32+
it { should contain_file('/srv/backup') }
33+
it { should contain_file('/var/lib/one/bin/one_db_backup.sh') }
34+
it { should contain_cron('one_db_backup')}
35+
36+
end
37+
end

templates/one_db_backup.sh.erb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ DB_BACKUP='<%= @backup_db %>'
88
BACKUP_DIR='<%= @backup_dir %>'
99
BACKUP_FILE=$(hostname)-$(date +%F_%H-%M-%S).sql
1010
BACKUP_OPTS='<%= @backup_opts %>'
11+
BACKUP_KEEP='<%= @backup_keep %>'
1112

1213
if [ -d $BACKUP_DIR ]; then
1314
mysqldump -h $DB_HOST -u $DB_USER -p$DB_PASSWORD $BACKUP_OPTS -r $BACKUP_DIR/$BACKUP_FILE -B $DB_BACKUP
14-
bzip2 -9 $BACKUP_DIR/$BACKUP_FILE
15-
find $BACKUP_DIR -type f -mtime +15 -exec rm {} +
15+
gzip $BACKUP_DIR/$BACKUP_FILE
16+
find $BACKUP_DIR -type f $BACKUP_KEEP -delete
1617
else
1718
echo 'Backup directory does not exist.'
1819
exit 1

0 commit comments

Comments
 (0)