diff --git a/.fixtures.yml b/.fixtures.yml index 65b2475..cfb33a1 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,7 +1,16 @@ fixtures: symlinks: - "gitlab": "#{source_dir}" + gitlab: "#{source_dir}" repositories: - "stdlib": "git://github.com/puppetlabs/puppetlabs-stdlib.git" - "vcsrepo": "git://github.com/puppetlabs/puppetlabs-vcsrepo.git" - "git": "git://github.com/puppetlabs/puppetlabs-git.git" + git: + repo: "git://github.com/puppetlabs/puppetlabs-git.git" + ref: "0.0.3" + rbenv: + repo: "git://github.com/alup/puppet-rbenv.git" + ref: "6628a24" + stdlib: + repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git" + ref: "4.2.1" + vcsrepo: + repo: "git://github.com/puppetlabs/puppetlabs-vcsrepo.git" + ref: "0.2.0" diff --git a/.travis.yml b/.travis.yml index 3ea2c5d..2803a50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ rvm: - 1.8.7 - 1.9.3 - 2.0.0 + - 2.1.2 env: matrix: - PUPPET_GEM_VERSION="~> 2.7.0" @@ -16,5 +17,10 @@ matrix: env: PUPPET_GEM_VERSION="~> 2.7.0" - rvm: 2.0.0 env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.1.2 + env: PUPPET_GEM_VERSION="~> 2.7.0" + - rvm: 2.1.2 + env: PUPPET_GEM_VERSION="~> 3.3.0" + notifications: email: false diff --git a/Modulefile b/Modulefile index a7759a2..2bdf529 100644 --- a/Modulefile +++ b/Modulefile @@ -7,6 +7,7 @@ summary 'Puppet GitLab Module' description 'Module to install GitLab using puppet' project_page 'https://github.com/sbadia/puppet-gitlab/' +dependency 'alup/rbenv', '>= 1.2.0' dependency 'puppetlabs/stdlib', '>= 3.1.0' dependency 'puppetlabs/vcsrepo', '>= 0.2.0' dependency 'puppetlabs/git', '>= 0.0.3' diff --git a/manifests/init.pp b/manifests/init.pp index c475e7a..2af460c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -156,16 +156,20 @@ # # [*gitlab_unicorn_port*] # Port that unicorn listens on 172.0.0.1 for HTTP traffic -# (default: 8080) +# default: 8080 # # [*gitlab_bundler_flags*] # Flags that should be passed to bundler when installing gems -# (default: --deployment) +# default: --deployment # # [*gitlab_bundler_jobs*] # Number of jobs to use while installing gems. Should match number of # procs on your system (default: 1) # +# [*gitlab_ruby_version*] +# Ruby version to install with rbenv for Gitlab user +# default: 2.1.2 +# # [*gitlab_ensure_postfix*] # Whether or not this module should ensure the postfix package is # installed (used to manage conflicts with other modules) @@ -304,6 +308,7 @@ $gitlab_unicorn_worker = $gitlab::params::gitlab_unicorn_worker, $gitlab_bundler_flags = $gitlab::params::gitlab_bundler_flags, $gitlab_bundler_jobs = $gitlab::params::gitlab_bundler_jobs, + $gitlab_ruby_version = $gitlab::params::gitlab_ruby_version, $gitlab_ensure_postfix = $gitlab::params::gitlab_ensure_postfix, $exec_path = $gitlab::params::exec_path, $ldap_enabled = $gitlab::params::ldap_enabled, diff --git a/manifests/install.pp b/manifests/install.pp index 6e8deca..832a1b6 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -3,6 +3,7 @@ # class gitlab::install inherits gitlab { + # note that this is *without* $gitlab_without_gems = $gitlab_dbtype ? { 'mysql' => 'postgres', 'pgsql' => 'mysql', @@ -58,7 +59,7 @@ file { "${git_home}/gitlab/config/initializers/rack_attack.rb": ensure => file, - source => "${git_home}/gitlab/config/initializers/rack_attack.rb.example" + source => "${git_home}/gitlab/config/initializers/rack_attack.rb.example", } if $gitlab_relative_url_root or $use_exim { diff --git a/manifests/params.pp b/manifests/params.pp index fa6c1f8..97dcb10 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,7 +2,6 @@ # # class gitlab::params { - $ensure = 'present' $git_user = 'git' $git_home = '/home/git' @@ -43,8 +42,9 @@ $gitlab_unicorn_worker = '2' $gitlab_bundler_flags = '--deployment' $gitlab_bundler_jobs = 1 + $gitlab_ruby_version = '2.1.2' $gitlab_ensure_postfix = true - $exec_path = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' + $exec_path = "${git_home}/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" $ldap_enabled = false $ldap_host = 'ldap.domain.com' $ldap_base = 'dc=domain,dc=com' diff --git a/manifests/setup.pp b/manifests/setup.pp index c64c634..6752be8 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -77,18 +77,40 @@ } } # Case $::osfamily - # system packages - package { 'bundler': - ensure => installed, - provider => gem, - } - # dev. dependencies ensure_packages($system_packages) - package { 'charlock_holmes': - ensure => '0.6.9.4', - provider => gem, + rbenv::install { $git_user: + group => $git_user, + home => $git_home, + + } + + # By default, puppet-rbenv sets ~/.profile to load rbenv, which is + # read when bash is invoked as an interactive login shell, but we + # also need ~/.bashrc to load rbenv (which is read by interactive + # but non-login shells). This works, but may not be the best + # solution, please see issue #114 if you have a better solution. + file { "${git_home}/.bashrc": + ensure => link, + target => "${git_home}/.profile", + require => Rbenv::Install[$git_user], + } + + rbenv::compile { 'gitlab/ruby': + user => $git_user, + home => $git_home, + ruby => $gitlab_ruby_version, + global => true, + notify => [ Exec['install gitlab-shell'], + Exec['install gitlab'] ], + } + + rbenv::gem { 'charlock_holmes': + ensure => '0.6.9.4', + user => $git_user, + home => $git_home, + ruby => $gitlab_ruby_version, } # other packages diff --git a/spec/classes/gitlab_install_spec.rb b/spec/classes/gitlab_install_spec.rb index 830075a..072c692 100644 --- a/spec/classes/gitlab_install_spec.rb +++ b/spec/classes/gitlab_install_spec.rb @@ -81,7 +81,7 @@ it { should contain_file('/home/git/gitlab-shell/config.yml').with_content(/^\s*port: 6379$/)} it { should contain_exec('install gitlab-shell').with( :user => 'git', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :path => '/home/git/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :command => 'ruby /home/git/gitlab-shell/bin/install', :cwd => '/home/git', :creates => '/home/git/repositories', @@ -159,7 +159,7 @@ describe 'install gitlab' do it { should contain_exec('install gitlab').with( :user => 'git', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :path => '/home/git/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :command => "bundle install --without development aws test postgres --deployment", :unless => 'bundle check', :cwd => '/home/git/gitlab', @@ -180,7 +180,7 @@ let(:params) {{ :gitlab_dbtype => 'pgsql' }} it { should contain_exec('install gitlab').with( :user => 'git', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :path => '/home/git/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :command => "bundle install --without development aws test mysql --deployment", :unless => 'bundle check', :cwd => '/home/git/gitlab', @@ -195,7 +195,7 @@ describe 'setup gitlab database' do it { should contain_exec('setup gitlab database').with( :user => 'git', - :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + :path => '/home/git/.rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', :command => '/usr/bin/yes yes | bundle exec rake gitlab:setup RAILS_ENV=production', :cwd => '/home/git/gitlab', :creates => '/home/git/.gitlab_setup_done', diff --git a/spec/classes/gitlab_setup_spec.rb b/spec/classes/gitlab_setup_spec.rb index 76377b4..b68ac75 100644 --- a/spec/classes/gitlab_setup_spec.rb +++ b/spec/classes/gitlab_setup_spec.rb @@ -13,11 +13,12 @@ # a non-default common parameter set let :params_set do { - :git_user => 'gitlab', - :git_home => '/srv/gitlab', - :git_comment => 'Labfooboozoo', - :git_email => 'gitlab@fooboozoo.fr', - :git_proxy => 'http://proxy.fooboozoo.fr:3128' + :git_user => 'gitlab', + :git_home => '/srv/gitlab', + :git_comment => 'Labfooboozoo', + :git_email => 'gitlab@fooboozoo.fr', + :git_proxy => 'http://proxy.fooboozoo.fr:3128', + :gitlab_ruby_version => '2.0.0' } end @@ -41,7 +42,7 @@ it { should contain_file('/home/git').with(:ensure => 'directory', :mode => '0755')} it { should contain_file('/home/git/gitlab-satellites').with(:ensure => 'directory', :mode => '0750')} end - context 'with specifics params' do + context 'with specific params' do let(:params) { params_set } it { should contain_user(params_set[:git_user]).with( :ensure => 'present', @@ -59,8 +60,50 @@ end end + ### Ruby + describe 'rbenv' do + context 'with default params' do + it { should contain_rbenv__install('git').with( + :group => 'git', + :home => '/home/git' + )} + it { should contain_file('/home/git/.bashrc').with( + :ensure => 'link', + :target => '/home/git/.profile', + :require => 'Rbenv::Install[git]' + )} + it { should contain_rbenv__compile('gitlab/ruby').with( + :user => 'git', + :home => '/home/git', + :ruby => '2.1.2', + :global => true, + :notify => ['Exec[install gitlab-shell]', 'Exec[install gitlab]'] + )} + + end + context 'with specific params' do + let(:params) { params_set } + it { should contain_rbenv__install(params_set[:git_user]).with( + :group => params_set[:git_user], + :home => params_set[:git_home] + )} + it { should contain_file('/srv/gitlab/.bashrc').with( + :ensure => 'link', + :target => '/srv/gitlab/.profile', + :require => 'Rbenv::Install[gitlab]' + )} + it { should contain_rbenv__compile('gitlab/ruby').with( + :user => params_set[:git_user], + :home => params_set[:git_home], + :ruby => '2.0.0', + :global => true, + :notify => ['Exec[install gitlab-shell]', 'Exec[install gitlab]'] + )} + end + end + ### Sshkey - describe 'sshkey (hostfile)' do + describe 'sshkey (hostfile)' do it { should contain_sshkey('localhost').with( :ensure => 'present', :host_aliases => 'gitlab.fooboozoo.fr', @@ -118,13 +161,8 @@ end #### Gems (all dist.) describe 'commons gems' do - it { should contain_package('bundler').with( - :ensure => 'installed', - :provider => 'gem' - )} - it { should contain_package('charlock_holmes').with( - :ensure => '0.6.9.4', - :provider => 'gem' + it { should contain_rbenv__gem('charlock_holmes').with( + :ensure => '0.6.9.4' )} end #### Commons packages (all dist.)