Move from template to file_line for Karaf features 94/55594/1
authorDaniel Farrell <dfarrell@redhat.com>
Thu, 4 Feb 2016 02:32:23 +0000 (21:32 -0500)
committerDaniel Farrell <dfarrell@redhat.com>
Wed, 19 Apr 2017 19:18:40 +0000 (15:18 -0400)
We were configuring the set of Karaf features to install at start (set
via featuresBoot) using a template. This template in particular
frequently exposed the major problem with templates - they override new
upstream content and need a manual update each time it changes. This
implementation uses file_line to do a sed-like replace on the
featuresBoot list, without impacting the rest of the file (the Karaf
feature repos via featuresRepositories most importantly, as it changed
every ODL version bump).

New rspec-puppet tests were added for the file_line step, and the
original file tests were updated. The Beaker tests haven't changed and
are still passing, which is desired/expected since we want the same
functional output from the two implementations.

Change-Id: I2e4fffc02989c7f790128e2b69f3c055bd32492c
Signed-off-by: Daniel Farrell <dfarrell@redhat.com>
manifests/config.pp
spec/spec_helper.rb
templates/org.apache.karaf.features.cfg.erb [deleted file]

index 009029edd34ffd5773b5d82ddd09654e7a3f72cc..3a64c68998314f1e581c6a748173b6234e64f6d5 100644 (file)
@@ -6,13 +6,17 @@
 class opendaylight::config {
   # Configuration of Karaf features to install
   file { 'org.apache.karaf.features.cfg':
-    ensure  => file,
-    path    => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+    ensure => file,
+    path   => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
     # Set user:group owners
-    owner   => 'odl',
-    group   => 'odl',
-    # Use a template to populate the content
-    content => template('opendaylight/org.apache.karaf.features.cfg.erb'),
+    owner  => 'odl',
+    group  => 'odl',
+  }
+  $features_csv = join($opendaylight::features, ',')
+  file_line { 'featuresBoot':
+    path  => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+    line  => "featuresBoot=${features_csv}",
+    match => '^featuresBoot=.*$',
   }
 
   # Configuration of ODL NB REST port to listen on
index c5e927a23b96856dd7587491889fa4402a1239d6..d541d5979b2651ff6f1131a8355f00f0dd020b28 100644 (file)
@@ -91,6 +91,7 @@ def karaf_feature_tests(options = {})
 
   # The order of this list concat matters
   features = default_features + extra_features
+  features_csv = features.join(',')
 
   # Confirm properties of Karaf features config file
   # NB: These hashes don't work with Ruby 1.8.7, but we
@@ -101,7 +102,13 @@ def karaf_feature_tests(options = {})
       'path'        => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
       'owner'   => 'odl',
       'group'   => 'odl',
-      'content'     => /^featuresBoot=#{features.join(",")}/
+    )
+  }
+  it {
+    should contain_file_line('featuresBoot').with(
+      'path'  => '/opt/opendaylight/etc/org.apache.karaf.features.cfg',
+      'line'  => "featuresBoot=#{features_csv}",
+      'match' => '^featuresBoot=.*$',
     )
   }
 end
diff --git a/templates/org.apache.karaf.features.cfg.erb b/templates/org.apache.karaf.features.cfg.erb
deleted file mode 100644 (file)
index 589b516..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-################################################################################
-#
-#    Licensed to the Apache Software Foundation (ASF) under one or more
-#    contributor license agreements.  See the NOTICE file distributed with
-#    this work for additional information regarding copyright ownership.
-#    The ASF licenses this file to You under the Apache License, Version 2.0
-#    (the "License"); you may not use this file except in compliance with
-#    the License.  You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-#
-################################################################################
-
-#
-# Defines if the startlvl should be respected during feature startup. The default value is true. The default
-# behavior for 2.x is false (!) for this property
-#
-# Be aware that this property is deprecated and will be removed in Karaf 4.0. So, if you need to
-# set this to false, please use this only as a temporary solution!
-#
-#respectStartLvlDuringFeatureStartup=true
-
-
-#
-# Defines if the startlvl should be respected during feature uninstall. The default value is true.
-# If true, means stop bundles respecting the descend order of start level in a certain feature.
-#
-#respectStartLvlDuringFeatureUninstall=true
-
-#
-# Comma separated list of features repositories to register by default
-#
-featuresRepositories = mvn:org.apache.karaf.features/standard/3.0.3/xml/features,mvn:org.apache.karaf.features/enterprise/3.0.3/xml/features,mvn:org.ops4j.pax.web/pax-web-features/3.1.4/xml/features,mvn:org.apache.karaf.features/spring/3.0.3/xml/features,mvn:org.opendaylight.integration/features-integration-index/0.4.0-Beryllium-RC1/xml/features
-
-#
-# Comma separated list of features to install at startup
-# Default features:
-# config,standard,region,package,kar,ssh,management
-#
-featuresBoot=<%= scope.lookupvar('opendaylight::features').join(",") %>
-
-#
-# Defines if the boot features are started in asynchronous mode (in a dedicated thread)
-#
-featuresBootAsynchronous=false