summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeoffrey B <jeoffrey54@gmail.com>2016-01-28 10:45:14 +0100
committerJeoffrey B <jeoffrey54@gmail.com>2016-01-28 10:45:14 +0100
commit2b5f5f257d950091b5a5a515daab7addea39025b (patch)
treee81ff8445b167c62c36e217c857d518a0be6fc98
parenta89c460e0f630d778513a3b07a33f150b79d2aae (diff)
parentc45d8e2f43919785134f02ca34c98ca943c82166 (diff)
Merge pull request #1 from rchicoli/fix-travis-ci
fix all puppet-lint error messages
-rw-r--r--.fixtures.yml4
-rw-r--r--manifests/config.pp14
-rw-r--r--manifests/init.pp47
-rw-r--r--manifests/install.pp7
-rw-r--r--manifests/params.pp21
-rw-r--r--manifests/repo.pp30
-rw-r--r--manifests/repo/apt.pp24
-rw-r--r--manifests/runner.pp73
-rw-r--r--manifests/service.pp9
-rw-r--r--spec/classes/example_spec.rb35
-rw-r--r--spec/classes/gitlab_ci_multi_runner_spec.rb56
11 files changed, 203 insertions, 117 deletions
diff --git a/.fixtures.yml b/.fixtures.yml
index a5e0e10..9de578d 100644
--- a/.fixtures.yml
+++ b/.fixtures.yml
@@ -1,5 +1,9 @@
fixtures:
repositories:
+ concat: "git://github.com/puppetlabs/puppetlabs-concat.git"
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
+ apt:
+ repo: "git://github.com/puppetlabs/puppetlabs-apt.git"
+ ref: 2.2.1
symlinks:
gitlab_ci_multi_runner: "#{source_dir}"
diff --git a/manifests/config.pp b/manifests/config.pp
index 5cf7525..c8a6fbd 100644
--- a/manifests/config.pp
+++ b/manifests/config.pp
@@ -7,19 +7,21 @@ class gitlab_ci_multi_runner::config (
$runners = $gitlab_ci_multi_runner::runners,
) {
- concat { $::gitlab_ci_multi_runner::config_file:
+ concat { $gitlab_ci_multi_runner::config_file:
ensure => present,
- owner => $::gitlab_ci_multi_runner::user,
- group => $::gitlab_ci_multi_runner::group,
+ owner => $gitlab_ci_multi_runner::user,
+ group => $gitlab_ci_multi_runner::group,
require => Package[$gitlab_ci_multi_runner::package_name],
notify => Service[$gitlab_ci_multi_runner::service_name],
}
- concat::fragment { "header_$::gitlab_ci_multi_runner::config_file":
- target => $::gitlab_ci_multi_runner::config_file,
+ concat::fragment { "header_${::gitlab_ci_multi_runner::config_file}":
+ target => $gitlab_ci_multi_runner::config_file,
content => template('gitlab_ci_multi_runner/fragment_header_config.toml.erb'),
order => '01',
}
- create_resources(gitlab_ci_multi_runner::runner, $runners)
+ if $gitlab_ci_multi_runner::runners {
+ create_resources(gitlab_ci_multi_runner::runner, $runners)
+ }
}
diff --git a/manifests/init.pp b/manifests/init.pp
index 77dcf73..1670d98 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -4,32 +4,53 @@
#
# === Parameters
#
-# [*package_name*] - Specify gitlab multi runner package name
-# Defaults to gitlab-ci-multi-runner
-# [*service_name*] - Specify the service name for gitlab multi runner
-# Defaults to gitlab-runner
-# [*manage_package_repo*] - Manage package repository for multi runner
-# Defaults to undef
-# [*user*] - Default user for multi runner
-# Defaults to gitlab-runner
-# [*group*] - Default group for multi runner
-# Defaults to gitlab-runner
-# [*concurrent*] - Number of concurrents jobs
-# Defaults to 1
+# [*package_name*]
+# Specify gitlab multi runner package name
+# Defaults to gitlab-ci-multi-runner
+#
+# [*service_name*]
+# Specify the service name for gitlab multi runner
+# Defaults to gitlab-runner
+#
+# [*manage_package_repo*]
+# Manage package repository for multi runner
+# Defaults to undef
+#
+# [*user*]
+# Default user for multi runner
+# Defaults to gitlab-runner
+#
+# [*group*]
+# Default group for multi runner
+# Defaults to gitlab-runner
+#
+# [*concurrent*]
+# Number of concurrents jobs
+# Defaults to 1
+#
class gitlab_ci_multi_runner (
$package_name = $gitlab_ci_multi_runner::params::package_name,
$service_name = $gitlab_ci_multi_runner::params::service_name,
+ $service_ensure = $gitlab_ci_multi_runner::params::service_ensure,
+ $service_enable = $gitlab_ci_multi_runner::params::service_enable,
+ $service_start = $gitlab_ci_multi_runner::params::service_start,
+ $service_stop = $gitlab_ci_multi_runner::params::service_stop,
+ $service_status = $gitlab_ci_multi_runner::params::service_status,
+ $service_restart = $gitlab_ci_multi_runner::params::service_restart,
$manage_package_repo = $gitlab_ci_multi_runner::params::manage_package_repo,
$user = $gitlab_ci_multi_runner::params::user,
$group = $gitlab_ci_multi_runner::params::group,
$concurrent = $gitlab_ci_multi_runner::params::concurrent,
$runners = $gitlab_ci_multi_runner::params::runners,
+ $config_file = $gitlab_ci_multi_runner::params::config_file,
) inherits gitlab_ci_multi_runner::params {
# validate parameters here
+ anchor { 'before_gitlab_ci_multi_runner': } ->
class { 'gitlab_ci_multi_runner::install': } ->
class { 'gitlab_ci_multi_runner::config': } ~>
class { 'gitlab_ci_multi_runner::service': } ->
- Class['gitlab_ci_multi_runner']
+ anchor { 'after_gitlab_ci_multi_runner': }
+
}
diff --git a/manifests/install.pp b/manifests/install.pp
index 128b5a1..3fb8a0a 100644
--- a/manifests/install.pp
+++ b/manifests/install.pp
@@ -2,11 +2,8 @@
#
class gitlab_ci_multi_runner::install {
- ensure_packages('apt-transport-https')
-
- if($::gitlab_ci_multi_runner::manage_package_repo) {
- class { 'gitlab_ci_multi_runner::repo':
- }
+ if( $gitlab_ci_multi_runner::manage_package_repo ) {
+ class { 'gitlab_ci_multi_runner::repo': }
}
package { $gitlab_ci_multi_runner::package_name:
diff --git a/manifests/params.pp b/manifests/params.pp
index 8913977..d883d12 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -6,21 +6,30 @@
class gitlab_ci_multi_runner::params {
$config_file = '/etc/gitlab-runner/config.toml'
- $manage_package_repo = undef
$user = 'gitlab-runner'
$group = 'gitlab-runner'
$concurrent = 1
- $runnners = undef
+ $runners = undef
+
+ $service_ensure = true
+ $service_start = '/usr/bin/gitlab-ci-multi-runner start'
+ $service_stop = '/usr/bin/gitlab-ci-multi-runner stop'
+ $service_status = '/usr/bin/gitlab-ci-multi-runner status'
+ $service_restart = '/usr/bin/gitlab-ci-multi-runner restart'
case $::osfamily {
'Debian': {
- $package_name = 'gitlab-ci-multi-runner'
- $service_name = 'gitlab-runner'
+ $package_name = 'gitlab-ci-multi-runner'
+ $service_name = 'gitlab-runner'
+ $manage_package_repo = true
+ $service_enable = false
}
'RedHat': {
- $package_name = 'gitlab_ci_multi_runner'
- $service_name = 'gitlab_ci_multi_runner'
+ $package_name = 'gitlab_ci_multi_runner'
+ $service_name = 'gitlab_ci_multi_runner'
+ $manage_package_repo = false
+ $service_enable = true
}
default: {
fail("${::operatingsystem} not supported")
diff --git a/manifests/repo.pp b/manifests/repo.pp
index 2263170..55e73df 100644
--- a/manifests/repo.pp
+++ b/manifests/repo.pp
@@ -5,7 +5,33 @@
class gitlab_ci_multi_runner::repo {
case $::osfamily {
'Debian': {
- class { 'gitlab_ci_multi_runner::repo::apt': }
+
+ include apt
+ # apt-transport-https is required by the apt to get the sources
+ ensure_packages('apt-transport-https')
+
+ Package['apt-transport-https'] ->
+ Apt::Source['gitlab-ci-multi-runner'] ->
+ Package['gitlab-ci-multi-runner']
+
+ apt::source { 'gitlab-ci-multi-runner':
+ comment => 'This is an officiel apt repo for Gitlab Ci Multi Runner',
+ location => 'https://packages.gitlab.com/runner/gitlab-ci-multi-runner/debian/',
+ release => $::lsbdistcodename,
+ repos => 'main',
+ key => {
+ 'id' => '1A4C919DB987D435939638B914219A96E15E78F4',
+ 'source' => 'https://packages.gitlab.com/gpg.key',
+ },
+ include => {
+ 'src' => true,
+ 'deb' => true,
+ },
+ }
+ }
+ default: {
+ fail("${::operatingsystem} not supported")
}
}
-} \ No newline at end of file
+
+}
diff --git a/manifests/repo/apt.pp b/manifests/repo/apt.pp
deleted file mode 100644
index af7b073..0000000
--- a/manifests/repo/apt.pp
+++ /dev/null
@@ -1,24 +0,0 @@
-# == Class gitlab_ci_multi_runner::repo::apt
-#
-# This class is private, do not use directly
-#
-class gitlab_ci_multi_runner::repo::apt {
- include apt
-
- apt::source { 'gitlab-ci-multi-runner':
- comment => 'This is an officiel apt repo for Gitlab Ci Multi Runner',
- location => 'https://packages.gitlab.com/runner/gitlab-ci-multi-runner/debian/',
- release => $::lsbdistcodename,
- repos => 'main',
- key => {
- 'id' => '1A4C919DB987D435939638B914219A96E15E78F4',
- 'source' => 'https://packages.gitlab.com/gpg.key',
- },
- include => {
- 'src' => true,
- 'deb' => true,
- },
- }
-
- Apt::Source['gitlab-ci-multi-runner']->Package<|tag == 'gitlab-ci-multi-runner'|>
-} \ No newline at end of file
diff --git a/manifests/runner.pp b/manifests/runner.pp
index f14cd06..2af8271 100644
--- a/manifests/runner.pp
+++ b/manifests/runner.pp
@@ -2,28 +2,53 @@
#
# Class for creating runners in multi-runner's config file.
#
-# [*url*] - CI URL
-# Defaults to http://gitlab.example.com
-# [*token*] - runner token
-# Defaults to 'XXXX'
-# [*limit*] - limit how many jobs can be handled concurrently by this token. 0 simply means don't limit
-# Defaults to undef
-# [*shell*] - the name of shell to generate the script (default value is platform dependent) (bash, cmd, powershell)
-# Defaults to undef
-# [*executor*] - select how a project should be built (shell, docker, docker-ssh, ssh, parallels)
-# Defaults to shell
-# [*builds_dir*] - directory where builds will be stored in context of selected executor (Locally, Docker, SSH)
-# Defaults to undef
-# [*environment*] - append or overwrite environment variables
-# Defaults to undef
-# [*disable_verbose*] - don't print run commands
-# Defaults to undef
-# [*output_limit*] - set maximum build log size in kilobytes, by default set to 4096 (4MB)
-# Defaults to undef
-# [*docker_params*] - Docker params (image, allowed_images, allowed_services, volumes, ...). Need executor_docker to true.
-# Defaults to undef
+# [*url*]
+# CI URL
+# Defaults to http://gitlab.example.com
+# [*token*]
+# runner token
+# Defaults to 'XXXX'
+#
+# [*limit*]
+# limit how many jobs can be handled concurrently by this token.
+# 0 simply means don't limit
+# Defaults to undef
+#
+# [*shell*]
+# the name of shell to generate the script
+# (default value is platform dependent) (bash, cmd, powershell)
+# Defaults to undef
+#
+# [*executor*]
+# select how a project should be built
+# (shell, docker, docker-ssh, ssh, parallels)
+# Defaults to shell
+#
+# [*builds_dir*]
+# directory where builds will be stored in context of selected executor
+# (Locally, Docker, SSH)
+# Defaults to undef
+#
+# [*environment*]
+# append or overwrite environment variables
+# Defaults to undef
+#
+# [*disable_verbose*]
+# don't print run commands
+# Defaults to undef
+#
+# [*output_limit*]
+# set maximum build log size in kilobytes, by default set to 4096 (4MB)
+# Defaults to undef
+#
+# [*docker_params*]
+# Docker params (image, allowed_images, allowed_services, volumes, ...).
+# Need executor_docker to true.
+# Defaults to undef
+#
# [*config_file*] - Path for Gitlab Multi Runner config file
-# Default value in params.
+# Default value in params.
+#
define gitlab_ci_multi_runner::runner (
$url = 'http://gitlab.example.com',
$token = 'XXXX',
@@ -39,9 +64,9 @@ define gitlab_ci_multi_runner::runner (
$config_file = $gitlab_ci_multi_runner::params::config_file,
){
- concat::fragment { "${name}_$::gitlab_ci_multi_runner::config_file":
- target => $::gitlab_ci_multi_runner::config_file,
+ concat::fragment { "${name}_${gitlab_ci_multi_runner::config_file}":
+ target => $gitlab_ci_multi_runner::config_file,
content => template('gitlab_ci_multi_runner/fragment_runner_config.toml.erb'),
}
-} \ No newline at end of file
+}
diff --git a/manifests/service.pp b/manifests/service.pp
index 8ac2727..c0d4e95 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -6,9 +6,14 @@
class gitlab_ci_multi_runner::service {
service { $gitlab_ci_multi_runner::service_name:
- ensure => running,
- enable => true,
+ ensure => $gitlab_ci_multi_runner::service_ensure,
+ enable => $gitlab_ci_multi_runner::service_enable,
+ start => $gitlab_ci_multi_runner::service_start,
+ stop => $gitlab_ci_multi_runner::service_stop,
+ status => $gitlab_ci_multi_runner::service_status,
+ restart => $gitlab_ci_multi_runner::service_restart,
hasstatus => true,
hasrestart => true,
}
+
}
diff --git a/spec/classes/example_spec.rb b/spec/classes/example_spec.rb
deleted file mode 100644
index 7dc8942..0000000
--- a/spec/classes/example_spec.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-require 'spec_helper'
-
-describe 'gitlab_ci_multi_runner' do
- context 'supported operating systems' do
- ['Debian', 'RedHat'].each do |osfamily|
- describe "gitlab_ci_multi_runner class without any parameters on #{osfamily}" do
- let(:params) {{ }}
- let(:facts) {{
- :osfamily => osfamily,
- }}
-
- it { should compile.with_all_deps }
-
- it { should contain_class('gitlab_ci_multi_runner::params') }
- it { should contain_class('gitlab_ci_multi_runner::install').that_comes_before('gitlab_ci_multi_runner::config') }
- it { should contain_class('gitlab_ci_multi_runner::config') }
- it { should contain_class('gitlab_ci_multi_runner::service').that_subscribes_to('gitlab_ci_multi_runner::config') }
-
- it { should contain_service('gitlab_ci_multi_runner') }
- it { should contain_package('gitlab_ci_multi_runner').with_ensure('present') }
- end
- end
- end
-
- context 'unsupported operating system' do
- describe 'gitlab_ci_multi_runner class without any parameters on Solaris/Nexenta' do
- let(:facts) {{
- :osfamily => 'Solaris',
- :operatingsystem => 'Nexenta',
- }}
-
- it { expect { should contain_package('gitlab_ci_multi_runner') }.to raise_error(Puppet::Error, /Nexenta not supported/) }
- end
- end
-end
diff --git a/spec/classes/gitlab_ci_multi_runner_spec.rb b/spec/classes/gitlab_ci_multi_runner_spec.rb
new file mode 100644
index 0000000..2092e9f
--- /dev/null
+++ b/spec/classes/gitlab_ci_multi_runner_spec.rb
@@ -0,0 +1,56 @@
+require 'spec_helper'
+
+describe 'gitlab_ci_multi_runner', :type => :class do
+
+ ['Debian', 'RedHat'].each do |osfamily|
+ context "on #{osfamily}" do
+
+ if osfamily == 'Debian'
+ describe "gitlab_ci_multi_runner class without any parameters on #{osfamily}" do
+ let(:params) {{ }}
+ let(:facts) {{
+ :osfamily => 'Debian',
+ :concat_basedir => '/dne',
+ :operatingsystem => 'Debian',
+ :lsbdistid => 'Debian',
+ :lsbdistcodename => 'jessie',
+ :operatingsystemmajrelease => '8',
+ }}
+
+ it { should compile.with_all_deps }
+
+ it { should contain_class('gitlab_ci_multi_runner::params') }
+ it { should contain_class('gitlab_ci_multi_runner::install').that_comes_before('gitlab_ci_multi_runner::config') }
+ it { should contain_class('gitlab_ci_multi_runner::config') }
+ it { should contain_class('gitlab_ci_multi_runner::service').that_subscribes_to('gitlab_ci_multi_runner::config') }
+
+ it { should contain_class('apt') }
+ it { should contain_package('apt-transport-https').that_comes_before('Apt::Source[gitlab-ci-multi-runner]').that_comes_before('Package[gitlab-ci-multi-runner]') }
+ it { should contain_apt__source('gitlab-ci-multi-runner').with_location('https://packages.gitlab.com/runner/gitlab-ci-multi-runner/debian/') }
+
+ it { should contain_service('gitlab-runner') }
+ it { should contain_package('gitlab-ci-multi-runner').with_name('gitlab-ci-multi-runner').with_ensure('present') }
+
+ it { should contain_package('apt-transport-https').with_ensure('present') }
+
+ context 'with service_enable set to false' do
+ let(:params) { {'service_enable' => false} }
+ it { should_not contain_service('gitlab-ci-multi-runner') }
+ end
+
+ end
+ end
+ end
+ end
+
+ context 'unsupported operating system' do
+ describe 'gitlab_ci_multi_runner class without any parameters on Solaris/Nexenta' do
+ let(:facts) {{
+ :osfamily => 'Solaris',
+ :operatingsystem => 'Nexenta',
+ }}
+
+ it { expect { should contain_package('gitlab_ci_multi_runner') }.to raise_error(Puppet::Error, /Nexenta not supported/) }
+ end
+ end
+end