diff --git a/NATIVE_TYPES_AND_PROVIDERS.md b/NATIVE_TYPES_AND_PROVIDERS.md index 018ada7d1..fadb4b1fa 100644 --- a/NATIVE_TYPES_AND_PROVIDERS.md +++ b/NATIVE_TYPES_AND_PROVIDERS.md @@ -17,7 +17,7 @@ the module.** * [`jenkins_job`](#jenkins_job) * [`jenkins_num_executors`](#jenkins_num_executors) * [`jenkins_security_realm`](#jenkins_security_realm) - * [`jenkins_slaveagent_port`](#jenkins_slaveagent_port) + * [`jenkins_agent_port`](#jenkins_agent_port) * [`jenkins_user`](#jenkins_user) 3. [TODO](#todo) @@ -109,7 +109,7 @@ puppet resource --modulepath=/tmp/vagrant-puppet/modules-998ea1817cb4dea9c136a57 ``` All providers presently require `java`, the jenkins CLI jar, and the jenkins -master service to be running. Most require the presence of +controller service to be running. Most require the presence of `puppet_helper.groovy`. The following puppet code snippet will prepare a node sufficiently for all providers to function. @@ -492,10 +492,10 @@ jenkins_security_realm { 'hudson.security.PAMSecurityRealm': } ``` -### `jenkins_slaveagent_port` +### `jenkins_agent_port` ``` -jenkins_slaveagent_port { 44444: # name is coerced to Integer +jenkins_agent_port { 44444: # name is coerced to Integer ensure => 'present', # present is the only allowed value } ``` diff --git a/README.md b/README.md index 47f3801a7..db13e381c 100644 --- a/README.md +++ b/README.md @@ -152,24 +152,24 @@ parameters will have no effect on the plugin retrieval URL. Dependencies are not automatically installed. You need to manually determine the plugin dependencies and include those as well. The Jenkins wiki is a good place to do this. For example: The Git plugin page is at https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin. ### Slaves -You can automatically add slaves to jenkins, and have them auto register themselves. Most options are actually optional, as nodes will auto-discover the master, and connect. +You can automatically add agents to jenkins, and have them auto register themselves. Most options are actually optional, as nodes will auto-discover the controller, and connect. -Full documentation for the slave code is in jenkins::slave. +Full documentation for the agent code is in jenkins::agent. -It requires the swarm plugin on the master & the class jenkins::slave on the slaves, as below: +It requires the swarm plugin on the controller & the class jenkins::agent on the agents, as below: ```puppet - node /jenkins-slave.*/ { - class { 'jenkins::slave': - masterurl => 'http://jenkins-master1.domain.com:8080', + node /jenkins-agent.*/ { + class { 'jenkins::agent': + controllerurl => 'http://jenkins-controller1.domain.com:8080', ui_user => 'adminuser', ui_pass => 'adminpass', } } - node /jenkins-master.*/ { + node /jenkins-controller.*/ { include jenkins - include jenkins::master + include jenkins::controller } ``` diff --git a/files/puppet_helper.groovy b/files/puppet_helper.groovy index 299885c2c..8403245b3 100644 --- a/files/puppet_helper.groovy +++ b/files/puppet_helper.groovy @@ -1003,24 +1003,24 @@ class Actions { } //////////////////////// - // get_slaveagent_port + // get_agent_port //////////////////////// /* * Print the port number of the slave agent */ - void get_slaveagent_port() { + void get_agent_port() { def j = Jenkins.getInstance() def n = j.getSlaveAgentPort() out.println(n) } //////////////////////// - // set_slaveagent_port + // set_agent_port //////////////////////// /* * Set the portnumber of the slave agent */ - void set_slaveagent_port(String n) { + void set_agent_port(String n) { def j = Jenkins.getInstance() j.setSlaveAgentPort(n.toInteger()) j.save() diff --git a/lib/puppet/provider/jenkins_slaveagent_port/cli.rb b/lib/puppet/provider/jenkins_agent_port/cli.rb similarity index 58% rename from lib/puppet/provider/jenkins_slaveagent_port/cli.rb rename to lib/puppet/provider/jenkins_agent_port/cli.rb index 74e30c251..9adbc72af 100644 --- a/lib/puppet/provider/jenkins_slaveagent_port/cli.rb +++ b/lib/puppet/provider/jenkins_agent_port/cli.rb @@ -3,11 +3,11 @@ require File.join(File.dirname(__FILE__), '../../..', 'puppet/x/jenkins/util') require File.join(File.dirname(__FILE__), '../../..', 'puppet/x/jenkins/provider/cli') -Puppet::Type.type(:jenkins_slaveagent_port).provide(:cli, parent: Puppet::X::Jenkins::Provider::Cli) do +Puppet::Type.type(:jenkins_agent_port).provide(:cli, parent: Puppet::X::Jenkins::Provider::Cli) do mk_resource_methods def self.instances(catalog = nil) - n = get_slaveagent_port(catalog) + n = get_agent_port(catalog) # there can be only one value Puppet.debug("#{sname} instances: #{n}") @@ -18,7 +18,7 @@ def self.instances(catalog = nil) def flush case self.ensure when :present - set_slaveagent_port + set_agent_port else raise Puppet::Error, "invalid :ensure value: #{self.ensure}" end @@ -26,12 +26,12 @@ def flush private - def self.get_slaveagent_port(catalog = nil) - clihelper(['get_slaveagent_port'], catalog: catalog).to_i + def self.get_agent_port(catalog = nil) + clihelper(['get_agent_port'], catalog: catalog).to_i end - private_class_method :get_slaveagent_port + private_class_method :get_agent_port - def set_slaveagent_port - clihelper(['set_slaveagent_port', name]) + def set_agent_port + clihelper(['set_agent_port', name]) end end diff --git a/lib/puppet/type/jenkins_slaveagent_port.rb b/lib/puppet/type/jenkins_agent_port.rb similarity index 86% rename from lib/puppet/type/jenkins_slaveagent_port.rb rename to lib/puppet/type/jenkins_agent_port.rb index 5cb2ce607..b729598a9 100644 --- a/lib/puppet/type/jenkins_slaveagent_port.rb +++ b/lib/puppet/type/jenkins_agent_port.rb @@ -2,8 +2,8 @@ require_relative '../../puppet/x/jenkins/type/cli' -Puppet::X::Jenkins::Type::Cli.newtype(:jenkins_slaveagent_port) do - @doc = "Manage Jenkins' slave agent listening port" +Puppet::X::Jenkins::Type::Cli.newtype(:jenkins_agent_port) do + @doc = "Manage Jenkins' agent listening port" # the cli jar does not have an interface for plugin removal so the only # allowed ensure value is :present diff --git a/lib/puppet/x/jenkins/type/cli.rb b/lib/puppet/x/jenkins/type/cli.rb index 32086b8d4..bdb245cc4 100644 --- a/lib/puppet/x/jenkins/type/cli.rb +++ b/lib/puppet/x/jenkins/type/cli.rb @@ -7,7 +7,7 @@ module Puppet::X::Jenkins::Type::Cli def self.newtype(*args, &block) type = Puppet::Type.newtype(*args, &block) - # The jenkins master needs to be avaiable in order to interact with it via + # The jenkins controller needs to be avaiable in order to interact with it via # the cli jar. type.autorequire(:service) do ['jenkins'] diff --git a/manifests/slave.pp b/manifests/agent.pp similarity index 66% rename from manifests/slave.pp rename to manifests/agent.pp index 02c9a38db..7e237ae1f 100644 --- a/manifests/slave.pp +++ b/manifests/agent.pp @@ -1,18 +1,18 @@ -# == Class: jenkins::slave +# == Class: jenkins::agent # -# This module setups up a swarm client for a jenkins server. It requires the swarm plugin on the Jenkins master. +# This module setups up a swarm client for a jenkins server. It requires the swarm plugin on the Jenkins controller. # # https://wiki.jenkins-ci.org/display/JENKINS/Swarm+Plugin # -# It allows users to add more workers to Jenkins without having to specifically add them on the Jenkins master. +# It allows users to add more workers to Jenkins without having to specifically add them on the Jenkins controller. # # === Parameters # -# [*slave_name*] -# Specify the name of the slave. Not required, by default it will use the fqdn. +# [*agent_name*] +# Specify the name of the agent. Not required, by default it will use the fqdn. # -# [*masterurl*] -# Specify the URL of the master server. Not required, the plugin will do a UDP autodiscovery. If specified, the autodiscovery will +# [*controllerurl*] +# Specify the URL of the controller server. Not required, the plugin will do a UDP autodiscovery. If specified, the autodiscovery will # be skipped. # # [*autodiscoveryaddress*] @@ -22,34 +22,34 @@ # User name & password for the Jenkins UI. Not required, but may be ncessary for your config, depending on your security model. # # [*version*] -# The version of the swarm client code. Must match the pluging version on the master. Typically it's the latest available. +# The version of the swarm client code. Must match the pluging version on the controller. Typically it's the latest available. # # [*executors*] -# Number of executors for this slave. (How many jenkins jobs can run simultaneously on this host.) +# Number of executors for this agent. (How many jenkins jobs can run simultaneously on this host.) # # [*tunnel*] # Connect to the specified host and port, instead of connecting directly to Jenkins. Useful when connection to # Hudson needs to be tunneled. Can be also HOST: or :PORT, in which case the missing portion will be # auto-configured like the default behavior # -# [*manage_slave_user*] -# Should the class add a user to run the slave code? 1 is currently true +# [*manage_agent_user*] +# Should the class add a user to run the agent code? 1 is currently true # TODO: should be updated to use boolean. # -# [*slave_user*] -# Defaults to 'jenkins-slave'. Change it if you'd like.. +# [*agent_user*] +# Defaults to 'jenkins-agent'. Change it if you'd like.. # -# [*slave_groups*] -# Not required. Use to add the slave_user to other groups if you need to. Defaults to undef. +# [*agent_groups*] +# Not required. Use to add the agent_user to other groups if you need to. Defaults to undef. # -# [*slave_uid*] +# [*agent_uid*] # Not required. Puppet will let your system add the user, with the new UID if necessary. # -# [*slave_home*] -# Defaults to '/home/jenkins-slave'. This is where the code will be installed, and the workspace will end up. +# [*agent_home*] +# Defaults to '/home/jenkins-agent'. This is where the code will be installed, and the workspace will end up. # -# [*slave_mode*] -# Defaults to 'normal'. Can be either 'normal' (utilize this slave as much as possible) or 'exclusive' +# [*agent_mode*] +# Defaults to 'normal'. Can be either 'normal' (utilize this agent as much as possible) or 'exclusive' # (leave this machine for tied jobs only). # # [*disable_ssl_verification*] @@ -61,47 +61,46 @@ # Defaults to false # # [*labels*] -# Not required. String, or Array, that contains the list of labels to be assigned for this slave. +# Not required. String, or Array, that contains the list of labels to be assigned for this agent. # # [*tool_locations*] -# Not required. Single string of whitespace-separated list of tool locations to be defined on this slave. A tool location is specified +# Not required. Single string of whitespace-separated list of tool locations to be defined on this agent. A tool location is specified # as 'toolName:location'. # # [*description*] -# Not required. Description which will appear on the jenkins master UI. +# Not required. Description which will appear on the jenkins controller UI. # # [*manage_client_jar*] # Should the class download the client jar file from the web? Defaults to true. # # [*ensure*] -# Service ensure control for jenkins-slave service. Default running +# Service ensure control for jenkins-agent service. Default running # # [*enable*] -# Service enable control for jenkins-slave service. Default true. +# Service enable control for jenkins-agent service. Default true. # # [*source*] -# File source for jenkins slave jar. Default pulls from http://maven.jenkins-ci.org +# File source for jenkins agent jar. Default pulls from http://maven.jenkins-ci.org # # [*java_args*] -# Java arguments to add to slave command line. Allows configuration of heap, etc. This +# Java arguments to add to agent command line. Allows configuration of heap, etc. This # can be a String, or an Array. # # [*proxy_server*] # Serves the same function as `::jenkins::proxy_server` but is an independent # parameter so the `::jenkins` class does not need to be the catalog for -# slave only nodes. +# agent only nodes. # # [*swarm_client_args*] -# Swarm client arguments to add to slave command line. More info: https://github.com/jenkinsci/swarm-plugin/blob/master/client/src/main/java/hudson/plugins/swarm/Options.java +# Swarm client arguments to add to agent command line. More info: https://github.com/jenkinsci/swarm-plugin/blob/master/client/src/main/java/hudson/plugins/swarm/Options.java # # [*java_cmd*] -# Path to the java command in ${defaults_location}/jenkins-slave. Defaults to '/usr/bin/java' +# Path to the java command in ${defaults_location}/jenkins-agent. Defaults to '/usr/bin/java' # - # === Examples # -# class { 'jenkins::slave': -# masterurl => 'http://jenkins-master1.example.com:8080', +# class { 'jenkins::agent': +# controllerurl => 'http://jenkins-controller1.example.com:8080', # ui_user => 'adminuser', # ui_pass => 'adminpass' # } @@ -113,10 +112,10 @@ # === Copyright # # Copyright 2013 Matthew Barr , but can be used for anything by anyone.. -class jenkins::slave ( - Optional[String] $slave_name = undef, +class jenkins::agent ( + Optional[String] $agent_name = undef, Optional[String] $description = undef, - Optional[String] $masterurl = undef, + Optional[String] $controllerurl = undef, Optional[String] $autodiscoveryaddress = undef, Optional[String] $ui_user = undef, Optional[String] $ui_pass = undef, @@ -126,12 +125,12 @@ Optional[Jenkins::Tunnel] $tunnel = undef, String $version = $jenkins::params::swarm_version, Integer $executors = 2, - Boolean $manage_slave_user = true, - String $slave_user = 'jenkins-slave', - Optional[String] $slave_groups = undef, - Optional[Integer] $slave_uid = undef, - Stdlib::Absolutepath $slave_home = '/home/jenkins-slave', - Enum['normal', 'exclusive'] $slave_mode = 'normal', + Boolean $manage_agent_user = true, + String $agent_user = 'jenkins-agent', + Optional[String] $agent_groups = undef, + Optional[Integer] $agent_uid = undef, + Stdlib::Absolutepath $agent_home = '/home/jenkins-agent', + Enum['normal', 'exclusive'] $agent_mode = 'normal', Boolean $disable_ssl_verification = false, Boolean $disable_clients_unique_id = false, Array[String[1]] $labels = [], @@ -169,12 +168,12 @@ # Currently the puppetlabs/java module doesn't support installing Java on # Darwin include java - Class['java'] -> Service['jenkins-slave'] + Class['java'] -> Service['jenkins-agent'] } case $facts['kernel'] { 'Linux': { - $service_name = 'jenkins-slave' + $service_name = 'jenkins-agent' $defaults_user = 'root' $defaults_group = 'root' $manage_user_home = true @@ -185,18 +184,18 @@ default => '/etc/sysconfig', } - file { "${defaults_location}/jenkins-slave": + file { "${defaults_location}/jenkins-agent": ensure => 'file', mode => '0600', owner => $defaults_user, group => $defaults_group, - content => template("${module_name}/jenkins-slave-defaults.erb"), - notify => Service['jenkins-slave'], + content => template("${module_name}/jenkins-agent-defaults.erb"), + notify => Service['jenkins-agent'], } - file { "${slave_home}/${service_name}-run": + file { "${agent_home}/${service_name}-run": content => template("${module_name}/${service_name}-run.erb"), - owner => $slave_user, + owner => $agent_user, mode => '0755', seltype => 'bin_t', notify => Service[$service_name], @@ -208,65 +207,65 @@ } } 'Darwin': { - $service_name = 'org.jenkins-ci.slave.jnlp' + $service_name = 'org.jenkins-ci.agent.jnlp' $defaults_user = 'jenkins' $defaults_group = 'wheel' $manage_user_home = false - file { '/Library/LaunchDaemons/org.jenkins-ci.slave.jnlp.plist': + file { '/Library/LaunchDaemons/org.jenkins-ci.agent.jnlp.plist': ensure => 'file', - content => template("${module_name}/org.jenkins-ci.slave.jnlp.plist.epp"), + content => template("${module_name}/org.jenkins-ci.agent.jnlp.plist.epp"), mode => '0644', owner => 'root', group => 'wheel', } - -> Service['jenkins-slave'] + -> Service['jenkins-agent'] file { '/var/log/jenkins': ensure => 'directory', - owner => $slave_user, + owner => $agent_user, } - -> Service['jenkins-slave'] + -> Service['jenkins-agent'] - if $manage_slave_user { + if $manage_agent_user { # osx doesn't have managehome support, so create directory - file { $slave_home: + file { $agent_home: ensure => directory, mode => '0755', - owner => $slave_user, - require => User['jenkins-slave_user'], + owner => $agent_user, + require => User['jenkins-agent_user'], } } } default: {} } - #a Add jenkins slave user if necessary. - if $manage_slave_user { - user { 'jenkins-slave_user': + #a Add jenkins agent user if necessary. + if $manage_agent_user { + user { 'jenkins-agent_user': ensure => present, - name => $slave_user, - comment => 'Jenkins Slave user', - home => $slave_home, + name => $agent_user, + comment => 'Jenkins agent user', + home => $agent_home, managehome => $manage_user_home, system => true, - uid => $slave_uid, - groups => $slave_groups, + uid => $agent_uid, + groups => $agent_groups, } } if ($manage_client_jar) { archive { 'get_swarm_client': source => "${client_url}/${client_jar}", - path => "${slave_home}/${client_jar}", + path => "${agent_home}/${client_jar}", proxy_server => $proxy_server, cleanup => false, extract => false, } - -> Service['jenkins-slave'] + -> Service['jenkins-agent'] } - service { 'jenkins-slave': + service { 'jenkins-agent': ensure => $ensure, name => $service_name, enable => $enable, @@ -274,8 +273,8 @@ hasrestart => true, } - if $manage_slave_user and $manage_client_jar { - User['jenkins-slave_user'] + if $manage_agent_user and $manage_client_jar { + User['jenkins-agent_user'] -> Archive['get_swarm_client'] } } diff --git a/manifests/master.pp b/manifests/controller.pp similarity index 76% rename from manifests/master.pp rename to manifests/controller.pp index 90e39f6fd..2a78363ec 100644 --- a/manifests/master.pp +++ b/manifests/controller.pp @@ -1,8 +1,8 @@ -# @summary Install a master +# @summary Install a controller # # @param version # Version of the swarm plugin -class jenkins::master ( +class jenkins::controller ( String $version = $jenkins::params::swarm_version ) inherits jenkins::params { jenkins::plugin { 'swarm': diff --git a/manifests/init.pp b/manifests/init.pp index 0f5e89761..9677f6271 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -214,22 +214,22 @@ # and plugins # # @param executors -# number of executors on the Jenkins master +# number of executors on the Jenkins controller # -# @param slaveagentport -# jenkins slave agent +# @param agentport +# jenkins agent agent # # @param manage_user # manage the system jenkins user # # @param user -# system user that owns the jenkins master's files +# system user that owns the jenkins controller's files # # @param manage_group # manage the system jenkins group # # @param group -# system group that owns the jenkins master's files +# system group that owns the jenkins controller's files # # @param default_plugins # List of default plugins installed by this module @@ -308,7 +308,7 @@ Boolean $manage_datadirs = true, Stdlib::Absolutepath $localstatedir = '/var/lib/jenkins', Optional[Integer] $executors = undef, - Optional[Integer] $slaveagentport = undef, + Optional[Integer] $agentport = undef, Boolean $manage_user = true, String $user = 'jenkins', Boolean $manage_group = true, @@ -418,14 +418,14 @@ -> Class['jenkins::jobs'] } - if ($slaveagentport != undef) { - jenkins::cli::exec { 'set_slaveagent_port': - command => ['set_slaveagent_port', $slaveagentport], - unless => "[ \$(\$HELPER_CMD get_slaveagent_port) -eq ${slaveagentport} ]", + if ($agentport != undef) { + jenkins::cli::exec { 'set_agent_port': + command => ['set_agent_port', $agentport], + unless => "[ \$(\$HELPER_CMD get_agent_port) -eq ${agentport} ]", } Class['jenkins::cli'] - -> Jenkins::Cli::Exec['set_slaveagent_port'] + -> Jenkins::Cli::Exec['set_agent_port'] -> Class['jenkins::jobs'] } diff --git a/spec/acceptance/slave_spec.rb b/spec/acceptance/agent_spec.rb similarity index 78% rename from spec/acceptance/slave_spec.rb rename to spec/acceptance/agent_spec.rb index 558566b9b..fc5b8e78a 100644 --- a/spec/acceptance/slave_spec.rb +++ b/spec/acceptance/agent_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' -describe 'jenkins::slave class' do +describe 'jenkins::agent class' do context 'default parameters' do sysconfdirs = { 'RedHat' => '/etc/sysconfig', @@ -11,25 +11,25 @@ } include_examples 'an idempotent resource' do - let(:manifest) { 'include jenkins::slave' } + let(:manifest) { 'include jenkins::agent' } end - describe file('/etc/systemd/system/jenkins-slave.service') do + describe file('/etc/systemd/system/jenkins-agent.service') do it { is_expected.to be_file } - it { is_expected.to contain 'ExecStart=/home/jenkins-slave/jenkins-slave-run' } + it { is_expected.to contain 'ExecStart=/home/jenkins-agent/jenkins-agent-run' } end - describe file("#{sysconfdirs[fact('os.family')]}/jenkins-slave") do + describe file("#{sysconfdirs[fact('os.family')]}/jenkins-agent") do it { is_expected.to be_file } it { is_expected.to be_mode 600 } end - describe file('/home/jenkins-slave/swarm-client-2.2-jar-with-dependencies.jar') do + describe file('/home/jenkins-agent/swarm-client-2.2-jar-with-dependencies.jar') do it { is_expected.to be_file } it { is_expected.to be_mode 644 } end - describe service('jenkins-slave') do + describe service('jenkins-agent') do it { is_expected.to be_running } it { is_expected.to be_enabled } end @@ -49,7 +49,7 @@ include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': ui_user => 'imauser', ui_pass => 'imapass', } @@ -58,7 +58,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{-username imauser} } its(:args) { is_expected.to match %r{-passwordEnvVariable JENKINS_PASSWORD} } its(:args) { is_expected.not_to match %r{imapass} } @@ -70,7 +70,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': disable_clients_unique_id => true, } PUPPET @@ -78,7 +78,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{-disableClientsUniqueId} } end end @@ -87,7 +87,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': disable_clients_unique_id => false, } PUPPET @@ -95,7 +95,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.not_to match %r{-disableClientsUniqueId} } end end @@ -106,7 +106,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': disable_ssl_verification => true, } PUPPET @@ -114,7 +114,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{-disableSslVerification} } end end @@ -123,7 +123,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': disable_ssl_verification => false, } PUPPET @@ -131,7 +131,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.not_to match %r{-disableSslVerification} } end end @@ -142,7 +142,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': delete_existing_clients => true, } PUPPET @@ -150,7 +150,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{-deleteExistingClients} } end end @@ -159,7 +159,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': delete_existing_clients => false, } PUPPET @@ -167,7 +167,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.not_to match %r{-deleteExistingClients} } end end @@ -178,7 +178,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': labels => ['foo', 'bar', 'baz'], } PUPPET @@ -186,7 +186,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{-labels foo bar baz} } end end @@ -199,7 +199,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': tool_locations => '#{tool_locations}', } PUPPET @@ -207,7 +207,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{--toolLocation Python-2\.7=/usr/bin/python2\.7} } its(:args) { is_expected.to match %r{--toolLocation Java-1\.8=/usr/bin/java} } end @@ -221,7 +221,7 @@ class { 'jenkins::slave': include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET - class { 'jenkins::slave': + class { 'jenkins::agent': tunnel => '#{tunnel}', } PUPPET @@ -229,7 +229,7 @@ class { 'jenkins::slave': end describe process('java') do - its(:user) { is_expected.to eq 'jenkins-slave' } + its(:user) { is_expected.to eq 'jenkins-agent' } its(:args) { is_expected.to match %r{-tunnel localhost:9000} } end end diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 5d27842ce..d6e92adbb 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -72,12 +72,12 @@ class {'jenkins': end end - context 'slaveagentport' do + context 'agentport' do include_examples 'an idempotent resource' do let(:manifest) do <<~PUPPET class {'jenkins': - slaveagentport => 7777, + agentport => 7777, } PUPPET end diff --git a/spec/classes/jenkins_slave_spec.rb b/spec/classes/jenkins_agent_spec.rb similarity index 59% rename from spec/classes/jenkins_slave_spec.rb rename to spec/classes/jenkins_agent_spec.rb index f284f6f69..4ba0ac45c 100644 --- a/spec/classes/jenkins_slave_spec.rb +++ b/spec/classes/jenkins_agent_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' -describe 'jenkins::slave' do +describe 'jenkins::agent' do on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } - shared_context 'a jenkins::slave catalog' do + shared_context 'a jenkins::agent catalog' do it do is_expected.to contain_archive('get_swarm_client').with( cleanup: false, @@ -15,61 +15,61 @@ ) end - it { is_expected.to contain_file(slave_service_file) } - it { is_expected.to contain_service('jenkins-slave').with(enable: true, ensure: 'running') } - # Let the different platform blocks define `slave_runtime_file` separately below - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^FSROOT="/home/jenkins-slave"$}) } - it { is_expected.to contain_file(slave_runtime_file).without_content(%r{ -name }) } - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^AUTO_DISCOVERY_ADDRESS=""$}) } + it { is_expected.to contain_file(agent_service_file) } + it { is_expected.to contain_service('jenkins-agent').with(enable: true, ensure: 'running') } + # Let the different platform blocks define `agent_runtime_file` separately below + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^FSROOT="/home/jenkins-agent"$}) } + it { is_expected.to contain_file(agent_runtime_file).without_content(%r{ -name }) } + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^AUTO_DISCOVERY_ADDRESS=""$}) } - describe 'with manage_slave_user true and manage_client_jar enabled' do - let(:params) { { manage_slave_user: true, manage_client_jar: true } } + describe 'with manage_agent_user true and manage_client_jar enabled' do + let(:params) { { manage_agent_user: true, manage_client_jar: true } } - it { is_expected.to contain_user('jenkins-slave_user').with_uid(nil).that_comes_before('Archive[get_swarm_client]') } + it { is_expected.to contain_user('jenkins-agent_user').with_uid(nil).that_comes_before('Archive[get_swarm_client]') } end - describe 'with manage_slave_user true and manage_client_jar false' do - let(:params) { { manage_slave_user: true, manage_client_jar: false } } + describe 'with manage_agent_user true and manage_client_jar false' do + let(:params) { { manage_agent_user: true, manage_client_jar: false } } - it { is_expected.to contain_user('jenkins-slave_user').with_uid(nil) } + it { is_expected.to contain_user('jenkins-agent_user').with_uid(nil) } end describe 'with auto discovery address' do let(:params) { { autodiscoveryaddress: '255.255.255.0' } } - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^AUTO_DISCOVERY_ADDRESS="255.255.255.0"$}) } + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^AUTO_DISCOVERY_ADDRESS="255.255.255.0"$}) } end - describe 'slave_uid' do - let(:params) { { slave_uid: 123 } } + describe 'agent_uid' do + let(:params) { { agent_uid: 123 } } - it { is_expected.to contain_user('jenkins-slave_user').with_uid(123) } + it { is_expected.to contain_user('jenkins-agent_user').with_uid(123) } end - describe 'slave_groups' do - let(:params) { { slave_groups: 'docker' } } + describe 'agent_groups' do + let(:params) { { agent_groups: 'docker' } } - it { is_expected.to contain_user('jenkins-slave_user').with_groups('docker') } + it { is_expected.to contain_user('jenkins-agent_user').with_groups('docker') } end - describe 'with a non-default $slave_home' do + describe 'with a non-default $agent_home' do let(:home) { '/home/rspec-runner' } - let(:params) { { slave_home: home } } + let(:params) { { agent_home: home } } - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^FSROOT="#{home}"$}) } + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^FSROOT="#{home}"$}) } end describe 'with service disabled' do let(:params) { { enable: false, ensure: 'stopped' } } - it { is_expected.to contain_service('jenkins-slave').with(enable: false, ensure: 'stopped') } + it { is_expected.to contain_service('jenkins-agent').with(enable: false, ensure: 'stopped') } end describe 'with tool_locations' do let(:params) { { tool_locations: 'Python-2.7:/usr/bin/python2.7 Java-1.8:/usr/bin/java' } } it do - is_expected.to contain_file(slave_runtime_file). + is_expected.to contain_file(agent_runtime_file). with_content(%r{Python-2\.7=/usr/bin/python2\.7}). with_content(%r{Java-1\.8=/usr/bin/java}) end @@ -86,11 +86,11 @@ end it 'escapes the user' do - is_expected.to contain_file(slave_runtime_file).with_content(%r{^JENKINS_USERNAME='#{user}'$}) + is_expected.to contain_file(agent_runtime_file).with_content(%r{^JENKINS_USERNAME='#{user}'$}) end it 'escapes the password' do - is_expected.to contain_file(slave_runtime_file).with_content(%r{^JENKINS_PASSWORD="#{password}"$}) + is_expected.to contain_file(agent_runtime_file).with_content(%r{^JENKINS_PASSWORD="#{password}"$}) end end @@ -103,7 +103,7 @@ end it 'converts java_args to a string' do - is_expected.to contain_file(slave_runtime_file).with_content(%r{^JAVA_ARGS="-Xmx2g -Xms128m"$}) + is_expected.to contain_file(agent_runtime_file).with_content(%r{^JAVA_ARGS="-Xmx2g -Xms128m"$}) end end @@ -116,7 +116,7 @@ end it 'converts swarm_client_args to a string' do - is_expected.to contain_file(slave_runtime_file).with_content(%r{^OTHER_ARGS="-disableSslVerification -disableClientsUniqueId"$}) + is_expected.to contain_file(agent_runtime_file).with_content(%r{^OTHER_ARGS="-disableSslVerification -disableClientsUniqueId"$}) end end @@ -127,7 +127,7 @@ } end - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^TUNNEL="localhost:9000"$}) } + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^TUNNEL="localhost:9000"$}) } end describe 'with invalid tunnel specified' do @@ -174,7 +174,7 @@ end it 'sets LABEL as a string' do - is_expected.to contain_file(slave_runtime_file).with_content(%r{^LABELS="hello world"$}) + is_expected.to contain_file(agent_runtime_file).with_content(%r{^LABELS="hello world"$}) end end @@ -186,7 +186,7 @@ end it 'has disable variable' do - is_expected.to contain_file(slave_runtime_file). + is_expected.to contain_file(agent_runtime_file). with_content(%r{^DISABLE_CLIENTS_UNIQUE_ID="true"$}) end end @@ -196,7 +196,7 @@ let(:params) { { delete_existing_clients: true } } it do - is_expected.to contain_file(slave_runtime_file). + is_expected.to contain_file(agent_runtime_file). with_content(%r{^DELETE_EXISTING_CLIENTS="true"$}) end end @@ -205,7 +205,7 @@ let(:params) { { delete_existing_clients: false } } it do - is_expected.to contain_file(slave_runtime_file). + is_expected.to contain_file(agent_runtime_file). with_content(%r{^DELETE_EXISTING_CLIENTS=""$}) end end @@ -215,58 +215,58 @@ java_cmd = '/usr/local/bin/java' let(:params) { { java_cmd: java_cmd } } - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^JAVA=#{java_cmd}$}) } + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^JAVA=#{java_cmd}$}) } end end - shared_examples 'using slave_name' do - it { is_expected.to contain_file(slave_runtime_file).with_content(%r{^CLIENT_NAME="jenkins-slave"$}) } + shared_examples 'using agent_name' do + it { is_expected.to contain_file(agent_runtime_file).with_content(%r{^CLIENT_NAME="jenkins-agent"$}) } end case os_facts[:os]['family'] when 'RedHat' describe 'RedHat' do - let(:slave_runtime_file) { '/etc/sysconfig/jenkins-slave' } - let(:slave_service_file) { '/etc/systemd/system/jenkins-slave.service' } - let(:slave_startup_script) { '/home/jenkins-slave/jenkins-slave-run' } + let(:agent_runtime_file) { '/etc/sysconfig/jenkins-agent' } + let(:agent_service_file) { '/etc/systemd/system/jenkins-agent.service' } + let(:agent_startup_script) { '/home/jenkins-agent/jenkins-agent-run' } - it_behaves_like 'a jenkins::slave catalog' + it_behaves_like 'a jenkins::agent catalog' it do - is_expected.to contain_file(slave_startup_script). - that_notifies('Service[jenkins-slave]') + is_expected.to contain_file(agent_startup_script). + that_notifies('Service[jenkins-agent]') end it do - is_expected.to contain_systemd__unit_file('jenkins-slave.service'). - that_notifies('Service[jenkins-slave]') + is_expected.to contain_systemd__unit_file('jenkins-agent.service'). + that_notifies('Service[jenkins-agent]') end end when 'Debian' describe 'Debian' do - let(:slave_runtime_file) { '/etc/default/jenkins-slave' } - let(:slave_service_file) { '/etc/systemd/system/jenkins-slave.service' } + let(:agent_runtime_file) { '/etc/default/jenkins-agent' } + let(:agent_service_file) { '/etc/systemd/system/jenkins-agent.service' } - it_behaves_like 'a jenkins::slave catalog' + it_behaves_like 'a jenkins::agent catalog' - describe 'with slave_name' do - let(:params) { { slave_name: 'jenkins-slave' } } + describe 'with agent_name' do + let(:params) { { agent_name: 'jenkins-agent' } } - it_behaves_like 'using slave_name' + it_behaves_like 'using agent_name' end end when 'Darwin' describe 'Darwin' do - let(:home) { '/home/jenkins-slave' } - let(:slave_runtime_file) { "#{home}/jenkins-slave" } - let(:slave_service_file) { '/Library/LaunchDaemons/org.jenkins-ci.slave.jnlp.plist' } + let(:home) { '/home/jenkins-agent' } + let(:agent_runtime_file) { "#{home}/jenkins-agent" } + let(:agent_service_file) { '/Library/LaunchDaemons/org.jenkins-ci.agent.jnlp.plist' } - it_behaves_like 'a jenkins::slave catalog' + it_behaves_like 'a jenkins::agent catalog' - # NOTE: pending because jenkins-slave doesn't get installed on Darwin - describe 'with slave_name' do - let(:params) { { slave_name: 'jenkins-slave' } } + # NOTE: pending because jenkins-agent doesn't get installed on Darwin + describe 'with agent_name' do + let(:params) { { agent_name: 'jenkins-agent' } } - it_behaves_like 'using slave_name' + it_behaves_like 'using agent_name' end end end diff --git a/spec/classes/jenkins_master_spec.rb b/spec/classes/jenkins_controller_spec.rb similarity index 91% rename from spec/classes/jenkins_master_spec.rb rename to spec/classes/jenkins_controller_spec.rb index 8e56e1a0f..238331eed 100644 --- a/spec/classes/jenkins_master_spec.rb +++ b/spec/classes/jenkins_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'jenkins::master' do +describe 'jenkins::controller' do on_supported_os.each do |os, os_facts| context "on #{os}" do let(:facts) { os_facts } diff --git a/spec/classes/jenkins_spec.rb b/spec/classes/jenkins_spec.rb index 5a15efa5e..47063efc9 100755 --- a/spec/classes/jenkins_spec.rb +++ b/spec/classes/jenkins_spec.rb @@ -111,24 +111,24 @@ end end - describe 'slaveagentport =>' do + describe 'agentport =>' do context 'undef' do - it { is_expected.not_to contain_jenkins__cli__exec('set_slaveagent_port') } + it { is_expected.not_to contain_jenkins__cli__exec('set_agent_port') } end context '7777' do let(:port) { 7777 } - let(:params) { { slaveagentport: port } } + let(:params) { { agentport: port } } it do - is_expected.to contain_jenkins__cli__exec('set_slaveagent_port').with( - command: ['set_slaveagent_port', port], - unless: "[ $($HELPER_CMD get_slaveagent_port) -eq #{port} ]" + is_expected.to contain_jenkins__cli__exec('set_agent_port').with( + command: ['set_agent_port', port], + unless: "[ $($HELPER_CMD get_agent_port) -eq #{port} ]" ) end - it { is_expected.to contain_jenkins__cli__exec('set_slaveagent_port').that_requires('Class[jenkins::cli]') } - it { is_expected.to contain_jenkins__cli__exec('set_slaveagent_port').that_comes_before('Class[jenkins::jobs]') } + it { is_expected.to contain_jenkins__cli__exec('set_agent_port').that_requires('Class[jenkins::cli]') } + it { is_expected.to contain_jenkins__cli__exec('set_agent_port').that_comes_before('Class[jenkins::jobs]') } end end diff --git a/spec/unit/puppet/provider/jenkins_slaveagent_port/cli_spec.rb b/spec/unit/puppet/provider/jenkins_agent_port/cli_spec.rb similarity index 69% rename from spec/unit/puppet/provider/jenkins_slaveagent_port/cli_spec.rb rename to spec/unit/puppet/provider/jenkins_agent_port/cli_spec.rb index 17d5a8b6d..695c6e014 100644 --- a/spec/unit/puppet/provider/jenkins_slaveagent_port/cli_spec.rb +++ b/spec/unit/puppet/provider/jenkins_agent_port/cli_spec.rb @@ -3,11 +3,11 @@ require 'spec_helper' require 'json' -describe Puppet::Type.type(:jenkins_slaveagent_port).provider(:cli) do +describe Puppet::Type.type(:jenkins_agent_port).provider(:cli) do describe '::instances' do context 'without any params' do before do - expect(described_class).to receive(:get_slaveagent_port). + expect(described_class).to receive(:get_agent_port). with(nil).and_return(42) end @@ -23,10 +23,10 @@ end context 'when called with a catalog param' do - it 'passes it on ::get_slaveagent_port' do + it 'passes it on ::get_agent_port' do catalog = Puppet::Resource::Catalog.new - expect(described_class).to receive(:get_slaveagent_port). + expect(described_class).to receive(:get_agent_port). with(catalog).and_return(42) described_class.instances(catalog) @@ -35,11 +35,11 @@ end describe '#flush' do - it 'calls set_slaveagent_port' do + it 'calls set_agent_port' do provider = described_class.new provider.create - expect(provider).to receive(:set_slaveagent_port).with(no_args) + expect(provider).to receive(:set_agent_port).with(no_args) provider.flush end @@ -56,12 +56,12 @@ # private methods # - describe '::get_slaveagent_port' do + describe '::get_agent_port' do it do expect(described_class).to receive(:clihelper). - with(['get_slaveagent_port'], catalog: nil).and_return(42) + with(['get_agent_port'], catalog: nil).and_return(42) - n = described_class.send :get_slaveagent_port + n = described_class.send :get_agent_port expect(n).to eq 42 end end @@ -70,9 +70,9 @@ it do provider = described_class.new(name: 42) - expect(described_class).to receive(:clihelper).with(['set_slaveagent_port', 42]) + expect(described_class).to receive(:clihelper).with(['set_agent_port', 42]) - provider.send :set_slaveagent_port + provider.send :set_agent_port end end end diff --git a/spec/unit/puppet/type/jenkins_slaveagent_port_spec.rb b/spec/unit/puppet/type/jenkins_agent_port_spec.rb similarity index 92% rename from spec/unit/puppet/type/jenkins_slaveagent_port_spec.rb rename to spec/unit/puppet/type/jenkins_agent_port_spec.rb index 8f03737aa..7b33a3429 100644 --- a/spec/unit/puppet/type/jenkins_slaveagent_port_spec.rb +++ b/spec/unit/puppet/type/jenkins_agent_port_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'unit/puppet/x/spec_jenkins_types' -describe Puppet::Type.type(:jenkins_slaveagent_port) do +describe Puppet::Type.type(:jenkins_agent_port) do before { Facter.clear } describe 'parameters' do diff --git a/templates/jenkins-slave-defaults.erb b/templates/jenkins-agent-defaults.erb similarity index 81% rename from templates/jenkins-slave-defaults.erb rename to templates/jenkins-agent-defaults.erb index 5e4168c01..059a2efd0 100644 --- a/templates/jenkins-slave-defaults.erb +++ b/templates/jenkins-agent-defaults.erb @@ -1,4 +1,4 @@ -# defaults for jenkins slave swarm clients +# defaults for jenkins agent swarm clients # XXX due to the use of conditional statements and variable interpolation, # this file can not be used in its current state as a systemd EnvironmentFile. @@ -14,17 +14,17 @@ JAVA_ARGS="<%= @java_args.join(' ') -%>" <% end -%> # user id to be invoked as (otherwise will run as root; not wise!) -JENKINS_SLAVE_USER=<%= @slave_user -%> +JENKINS_AGENT_USER=<%= @agent_user -%> # location of the jenkins war file -JENKINS_SLAVE_JAR="<%= @slave_home -%>/<%= @client_jar -%>" +JENKINS_AGENT_JAR="<%= @agent_home -%>/<%= @client_jar -%>" # log location. this may be a syslog facility.priority -JENKINS_SLAVE_LOG=/var/log/jenkins-slave/jenkins-slave.log +JENKINS_AGENT_LOG=/var/log/jenkins-agent/jenkins-agent.log -# slave mode, can be either 'normal' (utilize this slave as much as possible) +# agent mode, can be either 'normal' (utilize this agent as much as possible) # or 'exclusive' (leave this machine for tied jobs only). -JENKINS_SLAVE_MODE=<%= @slave_mode -%> +JENKINS_AGENT_MODE=<%= @agent_mode -%> # OS LIMITS SETUP # comment this out to observe /etc/security/limits.conf @@ -33,15 +33,15 @@ JENKINS_SLAVE_MODE=<%= @slave_mode -%> # descriptors are forced to 1024 regardless of /etc/security/limits.conf MAXOPENFILES=8192 -MASTER_URL="<%= @masterurl -%>" +CONTROLLER_URL="<%= @controllerurl -%>" AUTO_DISCOVERY_ADDRESS="<%= @autodiscoveryaddress -%>" LABELS="<%= @labels.join(' ') -%>" EXECUTORS=<%= @executors -%> -CLIENT_NAME="<%= @slave_name -%>" +CLIENT_NAME="<%= @agent_name -%>" -FSROOT="<%= @slave_home -%>" +FSROOT="<%= @agent_home -%>" DESCRIPTION="<%= @description -%>" diff --git a/templates/jenkins-agent-run.erb b/templates/jenkins-agent-run.erb new file mode 100644 index 000000000..0c9fd48f8 --- /dev/null +++ b/templates/jenkins-agent-run.erb @@ -0,0 +1,72 @@ +#!/bin/bash + +set -e + +fail() { + echo -e "$@" + exit 1 +} + +# mandatory input vars +[[ -x "$JAVA" ]] || (fail "$JAVA is not executable") +[[ -f "$JENKINS_AGENT_JAR" ]] || (fail "$JENKINS_AGENT_JAR not accessible") + +AGENT_ARGS=() + +[[ -n "$JAVA_ARGS" ]] && + AGENT_ARGS+=("$JAVA_ARGS") + +AGENT_ARGS+=(-jar "$JENKINS_AGENT_JAR") + +[[ -n "$JENKINS_AGENT_MODE" ]] && + AGENT_ARGS+=(-mode "$JENKINS_AGENT_MODE") + +[[ -n "$EXECUTORS" ]] && + AGENT_ARGS+=(-executors "$EXECUTORS") + +[[ -n "$JENKINS_USERNAME" ]] && + AGENT_ARGS+=(-username "$JENKINS_USERNAME") + +[[ -n "$JENKINS_PASSWORD" ]] && + AGENT_ARGS+=(-passwordEnvVariable JENKINS_PASSWORD) + +[[ -n "$CLIENT_NAME" ]] && + AGENT_ARGS+=(-name "$CLIENT_NAME") + +[[ -n "$CONTROLLER_URL" ]] && + AGENT_ARGS+=(-controller "$CONTROLLER_URL") + +[[ -n "$LABELS" ]] && + AGENT_ARGS+=(-labels "$LABELS") + +[[ -n "$FSROOT" ]] && + AGENT_ARGS+=(-fsroot "$FSROOT") + +[[ "$DISABLE_CLIENTS_UNIQUE_ID" == true ]] && + AGENT_ARGS+=(-disableClientsUniqueId) + +[[ "$DISABLE_SSL_VERIFICATION" == true ]] && + AGENT_ARGS+=(-disableSslVerification) + +[[ "$DELETE_EXISTING_CLIENTS" == true ]] && + AGENT_ARGS+=(-deleteExistingClients) + +[[ -n "$DESCRIPTION" ]] && + AGENT_ARGS+=(-description "$DESCRIPTION") + +[[ -n "$TUNNEL" ]] && + AGENT_ARGS+=(-tunnel "$TUNNEL") + +[[ -n "$AUTO_DISCOVERY_ADDRESS" ]] && + AGENT_ARGS+=(-autoDiscoveryAddress "$AUTO_DISCOVERY_ADDRESS") + +if [ -n "$TOOL_LOCATIONS" ]; then + for t in $TOOL_LOCATIONS; do + AGENT_ARGS+=(--toolLocation "$t") + done +fi + +[[ -n "$OTHER_ARGS" ]] && + AGENT_ARGS+=($OTHER_ARGS) + +$JAVA "${AGENT_ARGS[@]}" diff --git a/templates/jenkins-agent.service.erb b/templates/jenkins-agent.service.erb new file mode 100644 index 000000000..d410991fe --- /dev/null +++ b/templates/jenkins-agent.service.erb @@ -0,0 +1,17 @@ +[Unit] +Description=Jenkins agent service +Requires=network.target +After=network.target + +[Service] +Type=simple +User=<%= scope['jenkins::agent::agent_user'] %> +EnvironmentFile=<%= scope['jenkins::agent::defaults_location'] %>/jenkins-agent +ExecStart=<%= scope['jenkins::agent::agent_home'] %>/jenkins-agent-run +Restart=always +RestartSec=60 +StartLimitInterval=0 +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target diff --git a/templates/jenkins-slave-run.erb b/templates/jenkins-slave-run.erb deleted file mode 100644 index a52a6eecf..000000000 --- a/templates/jenkins-slave-run.erb +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -set -e - -fail() { - echo -e "$@" - exit 1 -} - -# mandatory input vars -[[ -x "$JAVA" ]] || (fail "$JAVA is not executable") -[[ -f "$JENKINS_SLAVE_JAR" ]] || (fail "$JENKINS_SLAVE_JAR not accessible") - -SLAVE_ARGS=() - -[[ -n "$JAVA_ARGS" ]] && - SLAVE_ARGS+=("$JAVA_ARGS") - -SLAVE_ARGS+=(-jar "$JENKINS_SLAVE_JAR") - -[[ -n "$JENKINS_SLAVE_MODE" ]] && - SLAVE_ARGS+=(-mode "$JENKINS_SLAVE_MODE") - -[[ -n "$EXECUTORS" ]] && - SLAVE_ARGS+=(-executors "$EXECUTORS") - -[[ -n "$JENKINS_USERNAME" ]] && - SLAVE_ARGS+=(-username "$JENKINS_USERNAME") - -[[ -n "$JENKINS_PASSWORD" ]] && - SLAVE_ARGS+=(-passwordEnvVariable JENKINS_PASSWORD) - -[[ -n "$CLIENT_NAME" ]] && - SLAVE_ARGS+=(-name "$CLIENT_NAME") - -[[ -n "$MASTER_URL" ]] && - SLAVE_ARGS+=(-master "$MASTER_URL") - -[[ -n "$LABELS" ]] && - SLAVE_ARGS+=(-labels "$LABELS") - -[[ -n "$FSROOT" ]] && - SLAVE_ARGS+=(-fsroot "$FSROOT") - -[[ "$DISABLE_CLIENTS_UNIQUE_ID" == true ]] && - SLAVE_ARGS+=(-disableClientsUniqueId) - -[[ "$DISABLE_SSL_VERIFICATION" == true ]] && - SLAVE_ARGS+=(-disableSslVerification) - -[[ "$DELETE_EXISTING_CLIENTS" == true ]] && - SLAVE_ARGS+=(-deleteExistingClients) - -[[ -n "$DESCRIPTION" ]] && - SLAVE_ARGS+=(-description "$DESCRIPTION") - -[[ -n "$TUNNEL" ]] && - SLAVE_ARGS+=(-tunnel "$TUNNEL") - -[[ -n "$AUTO_DISCOVERY_ADDRESS" ]] && - SLAVE_ARGS+=(-autoDiscoveryAddress "$AUTO_DISCOVERY_ADDRESS") - -if [ -n "$TOOL_LOCATIONS" ]; then - for t in $TOOL_LOCATIONS; do - SLAVE_ARGS+=(--toolLocation "$t") - done -fi - -[[ -n "$OTHER_ARGS" ]] && - SLAVE_ARGS+=($OTHER_ARGS) - -$JAVA "${SLAVE_ARGS[@]}" diff --git a/templates/jenkins-slave.service.erb b/templates/jenkins-slave.service.erb deleted file mode 100644 index 913b7c0c5..000000000 --- a/templates/jenkins-slave.service.erb +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=Jenkins slave service -Requires=network.target -After=network.target - -[Service] -Type=simple -User=<%= scope['jenkins::slave::slave_user'] %> -EnvironmentFile=<%= scope['jenkins::slave::defaults_location'] %>/jenkins-slave -ExecStart=<%= scope['jenkins::slave::slave_home'] %>/jenkins-slave-run -Restart=always -RestartSec=60 -StartLimitInterval=0 -SuccessExitStatus=143 - -[Install] -WantedBy=multi-user.target diff --git a/templates/org.jenkins-ci.agent.jnlp.plist.epp b/templates/org.jenkins-ci.agent.jnlp.plist.epp new file mode 100644 index 000000000..759a2aa06 --- /dev/null +++ b/templates/org.jenkins-ci.agent.jnlp.plist.epp @@ -0,0 +1,94 @@ + + + + + <% if $jenkins::agent::quoted_ui_pass { -%> + EnvironmentVariables + + JENKINS_PASSWORD + <%= $jenkins::agent::quoted_ui_pass -%> + + <% } -%> + Label + org.jenkins-ci.agent.jnlp + ProgramArguments + + /usr/bin/java + <% unless empty($jenkins::agent::java_args) { -%> + <%= join($jenkins::agent::java_args, ' ') -%> + <% } -%> + -jar + <%= $jenkins::agent::agent_home -%>/<%= $jenkins::agent::client_jar -%> + <% if $jenkins::agent::agent_mode { -%> + -mode + <%= $jenkins::agent::agent_mode -%> + <% } -%> + <% if $jenkins::agent::executors { -%> + -executors + <%= $jenkins::agent::executors -%> + <% } -%> + <% if $jenkins::agent::quoted_ui_user { -%> + -username + <%= $jenkins::agent::quoted_ui_user -%> + <% } -%> + <% if $jenkins::agent::quoted_ui_pass { -%> + -passwordEnvVariable + JENKINS_PASSWORD + <% } -%> + <% if $jenkins::agent::agent_name { -%> + -name + <%= $jenkins::agent::agent_name -%> + <% } -%> + <% if $jenkins::agent::controllerurl { -%> + -controller + <%= $jenkins::agent::controllerurl -%> + <% } -%> + <% if $jenkins::agent::agent_home { -%> + -fsroot + <%= $jenkins::agent::agent_home -%> + <% } -%> + <% if $jenkins::agent::disable_clients_unique_id { -%> + -disableClientsUniqueId + <% } -%> + <% if $jenkins::agent::disable_ssl_verification { -%> + -disableSslVerification + <% } -%> + <% if $jenkins::agent::delete_existing_clients { -%> + -deleteExistingClients + <% } -%> + <% if $jenkins::agent::description { -%> + -description + <%= $jenkins::agent::description -%> + <% } -%> + <% if $jenkins::agent::autodiscoveryaddress { -%> + -autoDiscoveryAddress + <%= $jenkins::agent::autodiscoveryaddress -%> + <% } -%> + <% if $jenkins::agent::_real_tool_locations { -%> + <% $jenkins::agent::_real_tool_locations.each |$location| { -%> + -toolLocation + <%= $location -%> + <% } -%> + <% } -%> + <% unless empty($jenkins::agent::swarm_client_args) { -%> + <%= join($jenkins::agent::swarm_client_args, ' ') -%> + <% } -%> + + KeepAlive + + RunAtLoad + + UserName + <%= $jenkins::agent::agent_user %> + WorkingDirectory + <%= $jenkins::agent::agent_home %> + SessionCreate + + StandardInPath + /dev/null + StandardErrorPath + /var/log/jenkins/org.jenkins-ci.agent.jnlp.log + StandardOutPath + /var/log/jenkins/org.jenkins-ci.agent.jnlp.log + + diff --git a/templates/org.jenkins-ci.slave.jnlp.plist.epp b/templates/org.jenkins-ci.slave.jnlp.plist.epp deleted file mode 100644 index fd65e485e..000000000 --- a/templates/org.jenkins-ci.slave.jnlp.plist.epp +++ /dev/null @@ -1,94 +0,0 @@ - - - - - <% if $jenkins::slave::quoted_ui_pass { -%> - EnvironmentVariables - - JENKINS_PASSWORD - <%= $jenkins::slave::quoted_ui_pass -%> - - <% } -%> - Label - org.jenkins-ci.slave.jnlp - ProgramArguments - - /usr/bin/java - <% unless empty($jenkins::slave::java_args) { -%> - <%= join($jenkins::slave::java_args, ' ') -%> - <% } -%> - -jar - <%= $jenkins::slave::slave_home -%>/<%= $jenkins::slave::client_jar -%> - <% if $jenkins::slave::slave_mode { -%> - -mode - <%= $jenkins::slave::slave_mode -%> - <% } -%> - <% if $jenkins::slave::executors { -%> - -executors - <%= $jenkins::slave::executors -%> - <% } -%> - <% if $jenkins::slave::quoted_ui_user { -%> - -username - <%= $jenkins::slave::quoted_ui_user -%> - <% } -%> - <% if $jenkins::slave::quoted_ui_pass { -%> - -passwordEnvVariable - JENKINS_PASSWORD - <% } -%> - <% if $jenkins::slave::slave_name { -%> - -name - <%= $jenkins::slave::slave_name -%> - <% } -%> - <% if $jenkins::slave::masterurl { -%> - -master - <%= $jenkins::slave::masterurl -%> - <% } -%> - <% if $jenkins::slave::slave_home { -%> - -fsroot - <%= $jenkins::slave::slave_home -%> - <% } -%> - <% if $jenkins::slave::disable_clients_unique_id { -%> - -disableClientsUniqueId - <% } -%> - <% if $jenkins::slave::disable_ssl_verification { -%> - -disableSslVerification - <% } -%> - <% if $jenkins::slave::delete_existing_clients { -%> - -deleteExistingClients - <% } -%> - <% if $jenkins::slave::description { -%> - -description - <%= $jenkins::slave::description -%> - <% } -%> - <% if $jenkins::slave::autodiscoveryaddress { -%> - -autoDiscoveryAddress - <%= $jenkins::slave::autodiscoveryaddress -%> - <% } -%> - <% if $jenkins::slave::_real_tool_locations { -%> - <% $jenkins::slave::_real_tool_locations.each |$location| { -%> - -toolLocation - <%= $location -%> - <% } -%> - <% } -%> - <% unless empty($jenkins::slave::swarm_client_args) { -%> - <%= join($jenkins::slave::swarm_client_args, ' ') -%> - <% } -%> - - KeepAlive - - RunAtLoad - - UserName - <%= $jenkins::slave::slave_user %> - WorkingDirectory - <%= $jenkins::slave::slave_home %> - SessionCreate - - StandardInPath - /dev/null - StandardErrorPath - /var/log/jenkins/org.jenkins-ci.slave.jnlp.log - StandardOutPath - /var/log/jenkins/org.jenkins-ci.slave.jnlp.log - -