Dzahn has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/382217 )
Change subject: jenkins: switch to Java8 ...................................................................... jenkins: switch to Java8 The next Jenkins version requires Java 8 and we thus have to switch to it before upgrading. We were stuck to Java 7 since we had slaves on Trusty which lacked Java 8 but they have all been decommissioned. master (::jenkins) and slaves (::jenkins::slave::requisites) are switched to java 8, be it on Jessie or Stretch. Thus remove the stretch conditional. The Jenkins master is driven by systemd which uses /usr/bin/java and the slaves use /usr/bin/java to start. Thus select the Java 8 alternative for /usr/bin/java Add a spec to ensure the catalog pass when an host has both master and slave classes. NOTE: for other tools, one would have to manually run: update-java-alternatives --set java-1.8.0-openjdk-amd64 The reason it is done manually is that there is no good way to list all the alternatives and the version they point to. That does not affect the service though, setting the alternative is merely a convenience for interactive use. Bug: T162828 Change-Id: I7f761484f092e3c04ee6d8069ecbb653248cb85f --- A modules/jenkins/manifests/common.pp M modules/jenkins/manifests/init.pp M modules/jenkins/manifests/slave.pp D modules/jenkins/manifests/slave/requisites.pp A modules/jenkins/spec/classes/jenkins_common_spec.rb D modules/jenkins/spec/classes/jenkins_slave_requisites_spec.rb A modules/jenkins/spec/hosts/master_and_slave_spec.rb M modules/role/manifests/ci/slave/labs/common.pp 8 files changed, 40 insertions(+), 34 deletions(-) Approvals: Hashar: Looks good to me, but someone else must approve jenkins-bot: Verified Dzahn: Looks good to me, approved diff --git a/modules/jenkins/manifests/common.pp b/modules/jenkins/manifests/common.pp new file mode 100644 index 0000000..06b2bd3 --- /dev/null +++ b/modules/jenkins/manifests/common.pp @@ -0,0 +1,12 @@ +# == Class: jenkins::common +# +# Dependency common to master and slaves +# +class jenkins::common { + ensure_packages('openjdk-8-jre-headless') + + alternatives::select { 'java': + path => '/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java', + require => Package['openjdk-8-jre-headless'], + } +} diff --git a/modules/jenkins/manifests/init.pp b/modules/jenkins/manifests/init.pp index df9e2a3..fd3bd96 100644 --- a/modules/jenkins/manifests/init.pp +++ b/modules/jenkins/manifests/init.pp @@ -43,6 +43,8 @@ $umask = '0002' ) { + include ::jenkins::common + user { 'jenkins': home => '/var/lib/jenkins', shell => '/bin/bash', # admins need to be able to login @@ -59,22 +61,14 @@ allowdupe => false, } - # We want to run Jenkins under Java 7. - # (unless when we are on stretch and there is no Java 7 anymore) - if os_version('debian >= stretch') { - $jdk_version = '8' - } else { - $jdk_version = '7' - } - $jdk_package = "openjdk-${jdk_version}-jdk" - ensure_packages($jdk_package) + ensure_packages('openjdk-8-jdk') # Upgrades are usually done manually by upload the Jenkins # package at apt.wikimedia.org then restarting jenkins and # double checking everything went fine. package { 'jenkins': ensure => present, - require => Package[$jdk_package], + require => Package['openjdk-8-jdk'], } file { '/var/lib/jenkins/.daemonrc': @@ -149,6 +143,7 @@ require => [ Systemd::Syslog['jenkins'], File['/etc/default/jenkins'], + Class['jenkins::common'], ], } diff --git a/modules/jenkins/manifests/slave.pp b/modules/jenkins/manifests/slave.pp index f07e3dd..a97533b 100644 --- a/modules/jenkins/manifests/slave.pp +++ b/modules/jenkins/manifests/slave.pp @@ -6,7 +6,7 @@ $workdir = '/var/lib/jenkins-slave', ) { - include ::jenkins::slave::requisites + include ::jenkins::common group { $user: ensure => present, diff --git a/modules/jenkins/manifests/slave/requisites.pp b/modules/jenkins/manifests/slave/requisites.pp deleted file mode 100644 index 9eea8a1..0000000 --- a/modules/jenkins/manifests/slave/requisites.pp +++ /dev/null @@ -1,16 +0,0 @@ -# == Class: jenkins::slave::requisites -# -# Dependency for the Jenkins agent on slaves -# -class jenkins::slave::requisites() { - - if os_version('debian >= stretch') { - $jdk_version = '8' - } else { - $jdk_version = '7' - } - - $jdk_package = "openjdk-${jdk_version}-jre-headless" - - ensure_packages($jdk_package) -} diff --git a/modules/jenkins/spec/classes/jenkins_common_spec.rb b/modules/jenkins/spec/classes/jenkins_common_spec.rb new file mode 100644 index 0000000..b285904 --- /dev/null +++ b/modules/jenkins/spec/classes/jenkins_common_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe 'jenkins::common' do + it { should compile } +end diff --git a/modules/jenkins/spec/classes/jenkins_slave_requisites_spec.rb b/modules/jenkins/spec/classes/jenkins_slave_requisites_spec.rb deleted file mode 100644 index 5bdf36d..0000000 --- a/modules/jenkins/spec/classes/jenkins_slave_requisites_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe 'jenkins::slave::requisites' do - it { should compile } -end diff --git a/modules/jenkins/spec/hosts/master_and_slave_spec.rb b/modules/jenkins/spec/hosts/master_and_slave_spec.rb new file mode 100644 index 0000000..f1ec814 --- /dev/null +++ b/modules/jenkins/spec/hosts/master_and_slave_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe 'Host being both a Jenkins master and a slave' do + let(:pre_condition) { + """ + class { 'jenkins': + prefix => '/jenkins', + } + class { 'jenkins::slave': + ssh_key => 'fake ssh key', + } + """ + } + it { should compile } +end diff --git a/modules/role/manifests/ci/slave/labs/common.pp b/modules/role/manifests/ci/slave/labs/common.pp index 3e31bce..f128047 100644 --- a/modules/role/manifests/ci/slave/labs/common.pp +++ b/modules/role/manifests/ci/slave/labs/common.pp @@ -57,7 +57,7 @@ # The slaves on labs use the `jenkins-deploy` user which is already # configured in labs LDAP. Thus, we only need to install the dependencies - # needed by the slave agent. - include jenkins::slave::requisites + # needed by the slave agent, eg the java jre. + include jenkins::common } -- To view, visit https://gerrit.wikimedia.org/r/382217 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7f761484f092e3c04ee6d8069ecbb653248cb85f Gerrit-PatchSet: 10 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Hashar <has...@free.fr> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Dzahn <dz...@wikimedia.org> Gerrit-Reviewer: Gehel <guillaume.leder...@wikimedia.org> Gerrit-Reviewer: Hashar <has...@free.fr> Gerrit-Reviewer: Muehlenhoff <mmuhlenh...@wikimedia.org> Gerrit-Reviewer: Paladox <thomasmulhall...@yahoo.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits