From be09d2bcda06604d6792d4b3221a4350b0b22d22 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Tue, 18 Feb 2014 12:11:48 -0500 Subject: [PATCH] Adds ! defined() guards around a2mod declarations If you attempt to include both Zuul and Jenkins master modules in a single manifest, you will get an error about A2mod[rewrite] resource already being declared, like so: Duplicate declaration: A2mod[rewrite] is already declared in file /home/ubuntu/os-ext-testing/puppet/modules/os_ext_testing/manifests/master.pp at line 30; cannot redeclare at /root/config/modules/zuul/manifests/init.pp:236 on node undef This isn't noticed by upstream, because no server runs both a Jenkins master and a Zuul server. However, in smaller systems, where both Jenkins and Zuul can be installed on the same host, the problem becomes apparent. This patch fixes that issue by adding guards around the a2mod declarations in the Zuul init.pp and Jenkins master.pp manifests. Change-Id: I2a298eb09ec8da33caed9349f465b2d163e2c299 Closes-bug: #1281676 --- modules/jenkins/manifests/master.pp | 18 ++++++++++++------ modules/zuul/manifests/init.pp | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/modules/jenkins/manifests/master.pp b/modules/jenkins/manifests/master.pp index 9601ff5f04..a54108647b 100644 --- a/modules/jenkins/manifests/master.pp +++ b/modules/jenkins/manifests/master.pp @@ -51,14 +51,20 @@ class jenkins::master( template => 'jenkins/jenkins.vhost.erb', ssl => true, } - a2mod { 'rewrite': - ensure => present, + if ! defined(A2mod['rewrite']) { + a2mod { 'rewrite': + ensure => present, + } } - a2mod { 'proxy': - ensure => present, + if ! defined(A2mod['proxy']) { + a2mod { 'proxy': + ensure => present, + } } - a2mod { 'proxy_http': - ensure => present, + if ! defined(A2mod['proxy_http']) { + a2mod { 'proxy_http': + ensure => present, + } } if $ssl_cert_file_contents != '' { diff --git a/modules/zuul/manifests/init.pp b/modules/zuul/manifests/init.pp index b7786512f3..3bb13d9296 100644 --- a/modules/zuul/manifests/init.pp +++ b/modules/zuul/manifests/init.pp @@ -231,13 +231,19 @@ class zuul ( priority => '50', template => 'zuul/zuul.vhost.erb', } - a2mod { 'rewrite': - ensure => present, + if ! defined(A2mod['rewrite']) { + a2mod { 'rewrite': + ensure => present, + } } - a2mod { 'proxy': - ensure => present, + if ! defined(A2mod['proxy']) { + a2mod { 'proxy': + ensure => present, + } } - a2mod { 'proxy_http': - ensure => present, + if ! defined(A2mod['proxy_http']) { + a2mod { 'proxy_http': + ensure => present, + } } }