From 52e83e3eb877e06cd0c54c9122a3b9d7b51ddfd0 Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Mon, 18 Apr 2016 16:00:17 +0300 Subject: [PATCH] Adding gearman plugin configuration to Jenkins * Gearman plugin should be configured externally * It is needed for Nodepool integration Change-Id: Idcc7d8a84a6c9c23c9d741475415ad6a032bd3df --- .../Jenkins/package/Classes/Jenkins.yaml | 15 +++++++++++++++ .../Resources/ConfigureGearman.template | 19 +++++++++++++++++++ .../Resources/scripts/configure_gearman.pp | 6 ++++++ .../Resources/scripts/configure_gearman.sh | 11 +++++++++++ .../configure_gearman/manifests/init.pp | 17 +++++++++++++++++ ...lugins.gearman.GearmanPluginConfig.xml.erb | 6 ++++++ 6 files changed, 74 insertions(+) create mode 100644 murano-apps/Jenkins/package/Resources/ConfigureGearman.template create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_gearman.pp create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_gearman.sh create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_gearman/manifests/init.pp create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_gearman/templates/hudson.plugins.gearman.GearmanPluginConfig.xml.erb diff --git a/murano-apps/Jenkins/package/Classes/Jenkins.yaml b/murano-apps/Jenkins/package/Classes/Jenkins.yaml index ec6e87b..5e12007 100644 --- a/murano-apps/Jenkins/package/Classes/Jenkins.yaml +++ b/murano-apps/Jenkins/package/Classes/Jenkins.yaml @@ -108,6 +108,21 @@ Methods: - $template: $resources.yaml('ConfigureZMQ.template') - $.instance.agent.call($template, $resources) + configureGearmanPlugin: + Arguments: + - host: + Contract: $.string().notNull() + - port: + Contract: $.int() + Default: 4730 + Body: + - $.instance.setHieraValue('gearman_host', $host) + - $.instance.setHieraValue('gearman_port', $port) + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Configure Jenkins Gearman plugin...') + - $template: $resources.yaml('ConfigureGearman.template') + - $.instance.agent.call($template, $resources) + destroy: Body: - $.reportDestroyed() diff --git a/murano-apps/Jenkins/package/Resources/ConfigureGearman.template b/murano-apps/Jenkins/package/Resources/ConfigureGearman.template new file mode 100644 index 0000000..d7a028d --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/ConfigureGearman.template @@ -0,0 +1,19 @@ +FormatVersion: 2.1.0 +Version: 1.0.0 +Name: Configure Gearman + +Body: | + return configureGearman().stdout + +Scripts: + configureGearman: + Type: Application + Version: 1.0.0 + EntryPoint: configure_gearman.sh + Files: + - 'configure_gearman/templates/hudson.plugins.gearman.GearmanPluginConfig.xml.erb' + - 'configure_gearman/manifests/init.pp' + - 'configure_gearman.pp' + Options: + captureStdout: true + captureStderr: true \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gearman.pp b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman.pp new file mode 100644 index 0000000..78a707b --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman.pp @@ -0,0 +1,6 @@ +node default { + class { 'configure_gearman': + gearman_host => hiera('gearman_host'), + gearman_port => hiera('gearman_port') + } +} \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gearman.sh b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman.sh new file mode 100644 index 0000000..733389d --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# No error if already exists. +mkdir -p /etc/puppet/modules/configure_gearman +mkdir -p /etc/puppet/modules/configure_gearman/manifests/ +mkdir -p /etc/puppet/modules/configure_gearman/templates/ + +cp configure_gearman/manifests/init.pp /etc/puppet/modules/configure_gearman/manifests/ +cp configure_gearman/templates/hudson.plugins.gearman.GearmanPluginConfig.xml.erb /etc/puppet/modules/configure_gearman/templates/ + +puppet apply configure_gearman.pp \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gearman/manifests/init.pp b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman/manifests/init.pp new file mode 100644 index 0000000..a29fc45 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman/manifests/init.pp @@ -0,0 +1,17 @@ +class configure_gearman ( + $gearman_host = undef, + $gearman_port = undef +) { + service { 'jenkins': + ensure => running, + enable => true, + } + file { '/var/lib/jenkins/hudson.plugins.gearman.GearmanPluginConfig.xml': + notify => Service['jenkins'], + ensure => present, + owner => 'jenkins', + group => 'jenkins', + mode => '0644', + content => template('configure_gearman/hudson.plugins.gearman.GearmanPluginConfig.xml.erb'), + } +} \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_gearman/templates/hudson.plugins.gearman.GearmanPluginConfig.xml.erb b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman/templates/hudson.plugins.gearman.GearmanPluginConfig.xml.erb new file mode 100644 index 0000000..58dbebb --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_gearman/templates/hudson.plugins.gearman.GearmanPluginConfig.xml.erb @@ -0,0 +1,6 @@ + + + true + <%= gearman_host %> + <%= gearman_port %> + \ No newline at end of file