-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move complex dependency to a separate class
This commit allow end users to easily disable/replace the dependency management of GitLab module. Retro-compatibility is kept and by default puppet-gitlab take care of GitLab dependency. To override internal puppet-gitlab class, we can use this call: class {'gitlab': gitlab_dependency => 'mydepsclass' } Refs: #35, #102
- Loading branch information
Showing
6 changed files
with
152 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Class:: gitlab::dependency inherits gitlab | ||
# | ||
# | ||
class gitlab::dependency inherits gitlab { | ||
|
||
include logrotate | ||
|
||
# database dependencies | ||
case $gitlab_dbtype { | ||
'mysql': { | ||
case $::osfamily { | ||
'Debian': { | ||
ensure_packages(['libmysql++-dev','libmysqlclient-dev']) | ||
} | ||
'RedHat': { | ||
ensure_packages(['mysql-devel']) | ||
} | ||
default: { | ||
err "${::osfamily} not supported yet for mysql" | ||
} | ||
} # Case $::osfamily | ||
|
||
} # mysql | ||
'pgsql': { | ||
case $::osfamily { | ||
'Debian': { | ||
ensure_packages(['libpq-dev']) | ||
} | ||
'RedHat': { | ||
ensure_packages(['postgresql-devel']) | ||
} | ||
default: { | ||
err "${::osfamily} not supported yet for pgsql" | ||
} | ||
} # Case $::osfamily | ||
|
||
} # pgsql | ||
default: { | ||
err "${gitlab_dbtype} not supported yet" | ||
} | ||
} # Case $::gitlab_dbtype | ||
|
||
# other packages | ||
ensure_packages([$git_package_name,'postfix','curl']) | ||
|
||
# dev. dependencies | ||
ensure_packages($system_packages) | ||
|
||
case $::operatingsystem { | ||
'ubuntu': { | ||
class { 'ruby': | ||
ruby_package => 'ruby1.9.3', | ||
rubygems_package => 'rubygems1.9.1', | ||
rubygems_update => false, | ||
} | ||
Package <| name == 'ruby1.9.3' |> { | ||
notify +> [ Exec['ruby-version'], Exec['gem-version'] ], | ||
} | ||
exec { 'ruby-version': | ||
command => '/usr/bin/update-alternatives --set ruby /usr/bin/ruby1.9.1', | ||
user => root, | ||
refreshonly => true, | ||
before => Class['Ruby::Dev'], | ||
} | ||
exec { 'gem-version': | ||
command => '/usr/bin/update-alternatives --set gem /usr/bin/gem1.9.1', | ||
user => root, | ||
refreshonly => true, | ||
before => Class['Ruby::Dev'], | ||
} | ||
} | ||
default: { | ||
class { 'ruby': | ||
version => '1:1.9.3', | ||
rubygems_update => false; | ||
} | ||
} | ||
} | ||
|
||
class { 'ruby::dev': } | ||
|
||
} # Class:: gitlab::dependency inherits gitlab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
class gitlab::params { | ||
|
||
$ensure = 'present' | ||
$gitlab_dependency = 'gitlab::dependency' | ||
$git_user = 'git' | ||
$git_home = '/home/git' | ||
$git_email = '[email protected]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require 'spec_helper' | ||
|
||
# Gitlab | ||
describe 'gitlab' do | ||
|
||
## Gitlab::setup | ||
describe 'gitlab::dependency' do | ||
|
||
### Packages setup | ||
#= Packages helper | ||
p = { | ||
'Debian' => { | ||
'db_packages' => { | ||
'mysql' => ['libmysql++-dev','libmysqlclient-dev'], | ||
'pgsql' => ['libpq-dev'] | ||
}, | ||
'system_packages' => ['libicu-dev', 'python2.7','python-docutils', | ||
'libxml2-dev','libxslt1-dev','python-dev'], | ||
'git_packages' => ['git-core'] | ||
}, | ||
'RedHat' => { | ||
'db_packages' => { | ||
'mysql' => ['mysql-devel'], | ||
'pgsql' => ['postgresql-devel'] | ||
}, | ||
'system_packages' => ['libicu-devel','perl-Time-HiRes','libxml2-devel', | ||
'libxslt-devel','python-devel','libcurl-devel', | ||
'readline-devel','openssl-devel','zlib-devel', | ||
'libyaml-devel','patch','gcc-c++'], | ||
'git_packages' => ['git'] | ||
} | ||
} | ||
|
||
#### Db and devel packages | ||
describe 'packages' do | ||
#= On each distro | ||
['Debian','RedHat'].each do |distro| | ||
#= With each dbtype | ||
['mysql','pgsql'].each do |dbtype| | ||
context "for #{dbtype} devel on #{distro}" do | ||
let(:facts) {{ :osfamily => distro }} | ||
let(:params) {{ :gitlab_dbtype => dbtype }} | ||
p[distro]['db_packages'][dbtype].each do |pkg| | ||
it { should contain_package(pkg) } | ||
end | ||
end | ||
end | ||
context "for devel dependencies on #{distro}" do | ||
let(:facts) {{ :osfamily => distro }} | ||
p[distro]['system_packages'].each do |pkg| | ||
it { should contain_package(pkg) } | ||
end | ||
p[distro]['git_packages'].each do |pkg| | ||
it { should contain_package(pkg) } | ||
end | ||
end | ||
end | ||
#### Commons packages (all dist.) | ||
describe 'commons packages' do | ||
['git-core','postfix','curl'].each do |pkg| | ||
it { should contain_package(pkg) } | ||
end | ||
end | ||
end # packages | ||
end # gitlab::dependency | ||
end # gitlab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters