From e22c8bb5b0166b625dc90ecaa4a4db94f8b7eb8f Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Mon, 17 Nov 2014 18:35:49 -0500 Subject: [PATCH] Move worker pieces that are only need once to init.pp This commit moves all the pieces from worker.pp which are used by all the worker process into init.pp. This was not done before because the package definitions would conflict with those in logstash.o.o's manifest. However with the if not defined checks we can have them in init.pp, so let's move everything in there. Change-Id: I5048604ce64bb52f463397c6a37b4a19a0bab8bb --- modules/subunit2sql/manifests/init.pp | 50 +++++++++++++++++++ modules/subunit2sql/manifests/worker.pp | 65 +++---------------------- 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/modules/subunit2sql/manifests/init.pp b/modules/subunit2sql/manifests/init.pp index ad0279cf83..c0a78f49eb 100644 --- a/modules/subunit2sql/manifests/init.pp +++ b/modules/subunit2sql/manifests/init.pp @@ -49,4 +49,54 @@ class subunit2sql ( require => Class['pip'], } + if ! defined(Package['python-daemon']) { + package { 'python-daemon': + ensure => present, + } + } + + if ! defined(Package['python-zmq']) { + package { 'python-zmq': + ensure => present, + } + } + + if ! defined(Package['python-yaml']) { + package { 'python-yaml': + ensure => present, + } + } + + if ! defined(Package['gear']) { + package { 'gear': + ensure => latest, + provider => 'pip', + require => Class['pip'], + } + } + + if ! defined(Package['statsd']) { + package { 'statsd': + ensure => latest, + provider => 'pip', + require => Class['pip'] + } + } + + file { '/usr/local/bin/subunit-gearman-worker.py': + ensure => present, + owner => 'root', + group => 'root', + mode => '0755', + source => 'puppet:///modules/log_processor/subunit-gearman-worker.py', + require => [ + Package['python-daemon'], + Package['python-zmq'], + Package['python-yaml'], + Package['gear'], + Package['subunit2sql'], + Package['python-subunit'], + Package['testtools'] + ], + } } diff --git a/modules/subunit2sql/manifests/worker.pp b/modules/subunit2sql/manifests/worker.pp index 7161b06cff..a18e8811fd 100644 --- a/modules/subunit2sql/manifests/worker.pp +++ b/modules/subunit2sql/manifests/worker.pp @@ -21,66 +21,17 @@ define subunit2sql::worker ( ) { $suffix = "-${name}" - if ! defined(Package['python-daemon']) { - package { 'python-daemon': - ensure => present, + if ! defined(File['/etc/logstash/subunit2sql.conf']) { + file { '/etc/logstash/subunit2sql.conf': + ensure => present, + owner => 'root', + group => 'root', + mode => '0555', + content => template('subunit2sql/subunit2sql.conf.erb'), + require => Class['logstash::indexer'], } } - if ! defined(Package['python-zmq']) { - package { 'python-zmq': - ensure => present, - } - } - - if ! defined(Package['python-yaml']) { - package { 'python-yaml': - ensure => present, - } - } - - if ! defined(Package['gear']) { - package { 'gear': - ensure => latest, - provider => 'pip', - require => Class['pip'], - } - } - - if ! defined(Package['statsd']) { - package { 'statsd': - ensure => latest, - provider => 'pip', - require => Class['pip'] - } - } - - file { '/usr/local/bin/subunit-gearman-worker.py': - ensure => present, - owner => 'root', - group => 'root', - mode => '0755', - source => 'puppet:///modules/log_processor/subunit-gearman-worker.py', - require => [ - Package['python-daemon'], - Package['python-zmq'], - Package['python-yaml'], - Package['gear'], - Package['subunit2sql'], - Package['python-subunit'], - Package['testtools'] - ], - } - - file { '/etc/logstash/subunit2sql.conf': - ensure => present, - owner => 'root', - group => 'root', - mode => '0555', - content => template('subunit2sql/subunit2sql.conf.erb'), - require => Class['logstash::indexer'], - } - file { "/etc/logstash/jenkins-subunit-worker${suffix}.yaml": ensure => present, owner => 'root',