Skip to content

Commit

Permalink
Merge pull request #53 from petems/add_redhat_support_for_cirunner
Browse files Browse the repository at this point in the history
Add RedHat support for cirunner
  • Loading branch information
tobru committed Feb 18, 2016
2 parents 0953992 + b6dbe16 commit 4663568
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ fixtures:
docker:
repo: "https://github.com/garethr/garethr-docker.git"
ref: "v4.1.1"
epel:
repo: "https://github.com/stahnma/puppet-module-epel"
ref: "1.2.2"
symlinks:
gitlab: "#{source_dir}"
69 changes: 52 additions & 17 deletions manifests/cirunner.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# === Parameters
#
# [*hiera_default_config_key*]
# Default: gitlab_ci_runners_defaults
# Default: gitlab_ci_runners_defaults
# Name of hiera hash with default configs for CI Runners.
# The config is the parameters for the /usr/bin/gitlab-ci-multi-runner register
# command.
Expand Down Expand Up @@ -34,7 +34,8 @@
validate_string($hiera_runners_key)
validate_bool($manage_docker)
validate_bool($manage_repo)
unless ($::osfamily == 'Debian') {

unless ($::osfamily == 'Debian' or $::osfamily == 'RedHat') {
fail ("OS family ${::osfamily} is not supported. Only Debian is suppported.")
}

Expand All @@ -52,25 +53,59 @@
}
}

$distid = downcase($::lsbdistid)
if $manage_repo {
::apt::source { 'apt_gitlabci':
comment => 'GitlabCI Runner Repo',
location => "https://packages.gitlab.com/runner/gitlab-ci-multi-runner/${distid}/",
release => $::lsbdistcodename,
repos => 'main',
key => {
'id' => '1A4C919DB987D435939638B914219A96E15E78F4',
'server' => 'keys.gnupg.net',
},
include => {
'src' => false,
'deb' => true,
case $::osfamily {
'Debian': {
$distid = downcase($::lsbdistid)

::apt::source { 'apt_gitlabci':
comment => 'GitlabCI Runner Repo',
location => "https://packages.gitlab.com/runner/gitlab-ci-multi-runner/${distid}/",
release => $::lsbdistcodename,
repos => 'main',
key => {
'id' => '1A4C919DB987D435939638B914219A96E15E78F4',
'server' => 'keys.gnupg.net',
},
include => {
'src' => false,
'deb' => true,
}
}
Apt::Source['apt_gitlabci'] -> Package['gitlab-ci-multi-runner']
Exec['apt_update'] -> Package['gitlab-ci-multi-runner']
}
'RedHat': {
yumrepo { 'runner_gitlab-ci-multi-runner':
ensure => 'present',
baseurl => "https://packages.gitlab.com/runner/gitlab-ci-multi-runner/el/${::operatingsystemmajrelease}/\$basearch",
descr => 'runner_gitlab-ci-multi-runner',
enabled => '1',
gpgcheck => '0',
gpgkey => 'https://packages.gitlab.com/gpg.key',
repo_gpgcheck => '1',
sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
sslverify => '1',
}

yumrepo { 'runner_gitlab-ci-multi-runner-source':
ensure => 'present',
baseurl => "https://packages.gitlab.com/runner/gitlab-ci-multi-runner/el/${::operatingsystemmajrelease}/SRPMS",
descr => 'runner_gitlab-ci-multi-runner-source',
enabled => '1',
gpgcheck => '0',
gpgkey => 'https://packages.gitlab.com/gpg.key',
repo_gpgcheck => '1',
sslcacert => '/etc/pki/tls/certs/ca-bundle.crt',
sslverify => '1',
}
}
default: {
fail ("gitlab::cirunner::manage_repo parameter for ${::osfamily} is not supported.")
}
}
Apt::Source['apt_gitlabci'] -> Package['gitlab-ci-multi-runner']
Exec['apt_update'] -> Package['gitlab-ci-multi-runner']
}

package { 'gitlab-ci-multi-runner':
ensure => 'present',
}
Expand Down
21 changes: 21 additions & 0 deletions spec/acceptance/gitlabci_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper_acceptance'

describe 'gitlab:;cirunner class' do

context 'default parameters' do
# Using puppet_apply as a helper
it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'gitlab::cirunner': }
EOS

# Run it twice and test for idempotency
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end

describe package('gitlab-ci-multi-runner') do
it { is_expected.to be_installed }
end
end
end
14 changes: 13 additions & 1 deletion spec/classes/cirunner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@
:enabled => false
}
},
:osfamily => 'RedHat',
:operatingsystemmajrelease => '6',
:operatingsystemrelease => '6.5',
:kernelversion => '2.6.32',
:kernelrelease => '2.6.32-573.8.1.el6.x86_64'
}}

it { expect { is_expected.to contain_package('gitlab') }.to raise_error(Puppet::Error, /OS family redhat is not supported. Only Debian is suppported./) }
it { is_expected.to compile.with_all_deps }

it { is_expected.to contain_class('docker') }
it { is_expected.to contain_class('docker::images') }
it { is_expected.to contain_yumrepo('runner_gitlab-ci-multi-runner').with_baseurl('https://packages.gitlab.com/runner/gitlab-ci-multi-runner/el/6/$basearch') }

it { is_expected.to contain_package('gitlab-ci-multi-runner').with_ensure('present') }

end
end

Expand Down

0 comments on commit 4663568

Please sign in to comment.