From 59338c0a5db7844a9e9f179e860417318697157d Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Tue, 12 Apr 2016 14:38:30 +0300 Subject: [PATCH] Adding configuration of ZMQ Event publisher plugin * Added ZMQ event publisher plugin for Jenkins * It is needed for Nodepool Change-Id: I2c136878a68d863451a0eca5314546f2595b1f06 --- .../Jenkins/package/Classes/Jenkins.yaml | 15 +++++++++++++++ .../package/Resources/ConfigureZMQ.template | 19 +++++++++++++++++++ .../Resources/scripts/configure_zmq.pp | 5 +++++ .../Resources/scripts/configure_zmq.sh | 11 +++++++++++ .../scripts/configure_zmq/manifests/init.pp | 16 ++++++++++++++++ ...blisher.HudsonNotificationProperty.xml.erb | 5 +++++ 6 files changed, 71 insertions(+) create mode 100644 murano-apps/Jenkins/package/Resources/ConfigureZMQ.template create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_zmq.pp create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_zmq.sh create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_zmq/manifests/init.pp create mode 100644 murano-apps/Jenkins/package/Resources/scripts/configure_zmq/templates/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb diff --git a/murano-apps/Jenkins/package/Classes/Jenkins.yaml b/murano-apps/Jenkins/package/Classes/Jenkins.yaml index adc5cc8..ec6e87b 100644 --- a/murano-apps/Jenkins/package/Classes/Jenkins.yaml +++ b/murano-apps/Jenkins/package/Classes/Jenkins.yaml @@ -63,6 +63,7 @@ Methods: - $template: $resources.yaml('InstallCFPlugin.template') - $.instance.agent.call($template, $resources) + - $.configureZMQPlugin() - If: $.instance.assignFloatingIp Then: @@ -92,6 +93,20 @@ Methods: - $.instance.agent.call($template, $resources) - $._environment.reporter.report($this, 'Jenkins is connected to OpenLDAP server!') + configureZMQPlugin: + Body: + - $._environment.reporter.report($this, 'Creating security group for ZMQ Event publisher') + - $securityGroupIngress: + - ToPort: 8888 + FromPort: 8888 + IpProtocol: tcp + External: true + - $._environment.securityGroupManager.addGroupIngress($securityGroupIngress) + - $._environment.stack.push() + - $resources: new(sys:Resources) + - $._environment.reporter.report($this, 'Configure Jenkins ZMQ Event Publisher plugin...') + - $template: $resources.yaml('ConfigureZMQ.template') + - $.instance.agent.call($template, $resources) destroy: Body: diff --git a/murano-apps/Jenkins/package/Resources/ConfigureZMQ.template b/murano-apps/Jenkins/package/Resources/ConfigureZMQ.template new file mode 100644 index 0000000..4c458ab --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/ConfigureZMQ.template @@ -0,0 +1,19 @@ +FormatVersion: 2.1.0 +Version: 1.0.0 +Name: Configure ZMQ + +Body: | + return configureZMQ().stdout + +Scripts: + configureZMQ: + Type: Application + Version: 1.0.0 + EntryPoint: configure_zmq.sh + Files: + - 'configure_zmq/templates/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb' + - 'configure_zmq/manifests/init.pp' + - 'configure_zmq.pp' + Options: + captureStdout: true + captureStderr: true \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_zmq.pp b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq.pp new file mode 100644 index 0000000..43c2ae8 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq.pp @@ -0,0 +1,5 @@ +node default { + class { 'configure_zmq': + zmq_port => 8888, + } +} \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_zmq.sh b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq.sh new file mode 100644 index 0000000..9bfc61c --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# No error if already exists. +mkdir -p /etc/puppet/modules/configure_zmq +mkdir -p /etc/puppet/modules/configure_zmq/manifests/ +mkdir -p /etc/puppet/modules/configure_zmq/templates/ + +cp configure_zmq/manifests/init.pp /etc/puppet/modules/configure_zmq/manifests/ +cp configure_zmq/templates/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb /etc/puppet/modules/configure_zmq/templates/ + +puppet apply configure_zmq.pp \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_zmq/manifests/init.pp b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq/manifests/init.pp new file mode 100644 index 0000000..197f00d --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq/manifests/init.pp @@ -0,0 +1,16 @@ +class configure_zmq ( + $zmq_port = undef, +) { + service { 'jenkins': + ensure => running, + enable => true, + } + file { '/var/lib/jenkins/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml': + notify => Service['jenkins'], + ensure => present, + owner => 'jenkins', + group => 'jenkins', + mode => '0644', + content => template('configure_zmq/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb'), + } +} \ No newline at end of file diff --git a/murano-apps/Jenkins/package/Resources/scripts/configure_zmq/templates/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq/templates/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb new file mode 100644 index 0000000..a7018d0 --- /dev/null +++ b/murano-apps/Jenkins/package/Resources/scripts/configure_zmq/templates/org.jenkinsci.plugins.ZMQEventPublisher.HudsonNotificationProperty.xml.erb @@ -0,0 +1,5 @@ + + + true + <%= zmq_port %> + \ No newline at end of file