aboutsummaryrefslogtreecommitdiffstats
path: root/manifests/firewall
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2016-07-20 10:05:47 -0400
committerEmilien Macchi <emilien@redhat.com>2016-07-21 17:35:13 +0000
commit5881826559a01b987348b273877e4ebc1e748d22 (patch)
treecfc2950a0e2518f48c3b3caf4332f53f42f88e22 /manifests/firewall
parente2fe8ce79906c105e793752df8f32560fbce602c (diff)
Add firewall::service_rules define
This patch updates the tripleo::firewall class so that it will support loading firewall rules defined in composable services via the following hiera keys (for nova-api for example): tripleo.nova_api.firewall_rules This patch relies on a new 'service_names' hiera array that should be provided on all TripleO overcloud nodes. Depends-On: I60861c5aa760534db3e314bba16a13b90ea72f0c Change-Id: Id370362ab57347b75b1ab25afda877885b047263
Diffstat (limited to 'manifests/firewall')
-rw-r--r--manifests/firewall/service_rules.pp38
1 files changed, 38 insertions, 0 deletions
diff --git a/manifests/firewall/service_rules.pp b/manifests/firewall/service_rules.pp
new file mode 100644
index 0000000..4739f16
--- /dev/null
+++ b/manifests/firewall/service_rules.pp
@@ -0,0 +1,38 @@
+# Copyright 2016 Red Hat, Inc.
+#
+# Licensed 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.
+#
+# == Define: tripleo::firewall::service_rules
+#
+# Define used to create firewall rules for composable services.
+#
+# === Parameters:
+#
+# [*service_name*]
+# (optional) The service_name to load firewall rules for.
+# Defaults to $title
+#
+define tripleo::firewall::service_rules ($service_name = $title) {
+
+ $underscore_name = regsubst($service_name, '-', '_')
+
+ # This allows each composable service to load its own custom rules by
+ # creating its own flat hiera key named:
+ # tripleo.<service name with underscores>.firewall_rules
+ $service_firewall_rules = hiera("tripleo.${underscore_name}.firewall_rules", {})
+
+ if !empty($service_firewall_rules) {
+ create_resources('tripleo::firewall::rule', $service_firewall_rules)
+ }
+
+}