Move has_static_component function to modules/staticsync
authorPeter Palfrader <peter@palfrader.org>
Mon, 7 Oct 2019 11:12:31 +0000 (13:12 +0200)
committerPeter Palfrader <peter@palfrader.org>
Mon, 7 Oct 2019 11:12:31 +0000 (13:12 +0200)
modules/puppetmaster/lib/puppet/parser/functions/has_static_component.rb [deleted file]
modules/staticsync/lib/puppet/parser/functions/has_static_component.rb [new file with mode: 0644]

diff --git a/modules/puppetmaster/lib/puppet/parser/functions/has_static_component.rb b/modules/puppetmaster/lib/puppet/parser/functions/has_static_component.rb
deleted file mode 100644 (file)
index ded96ce..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-module Puppet::Parser::Functions
-  newfunction(:has_static_component, :type => :rvalue) do |args|
-      static_component = args[0]
-      fqdn = lookupvar('fqdn')
-
-      cfg = YAML.load(File.open('/etc/puppet/modules/roles/misc/static-components.yaml').read)
-
-      if cfg.include?('mirrors')
-        if cfg['mirrors'].include?(fqdn)
-          if cfg['mirrors'][fqdn].include?('components-include')
-            if cfg['mirrors'][fqdn]['components-include'].include?(static_component)
-              return true
-            else
-              return false
-            end
-          end
-        end
-      end
-
-      if cfg.include?('components')
-        if cfg['components'].include?(static_component)
-          if cfg['components'][static_component].include?('limit-mirrors')
-            return (cfg['components'][static_component]['limit-mirrors'].include?(fqdn))
-          elsif cfg['components'][static_component].include?('exclude-mirrors')
-            return (not cfg['components'][static_component]['exclude-mirrors'].include?(fqdn))
-          else
-            return true
-          end
-        end
-      end
-
-      err "Static component #{static_component} appears to be not defined"
-      return false
-  end
-end
diff --git a/modules/staticsync/lib/puppet/parser/functions/has_static_component.rb b/modules/staticsync/lib/puppet/parser/functions/has_static_component.rb
new file mode 100644 (file)
index 0000000..ded96ce
--- /dev/null
@@ -0,0 +1,35 @@
+module Puppet::Parser::Functions
+  newfunction(:has_static_component, :type => :rvalue) do |args|
+      static_component = args[0]
+      fqdn = lookupvar('fqdn')
+
+      cfg = YAML.load(File.open('/etc/puppet/modules/roles/misc/static-components.yaml').read)
+
+      if cfg.include?('mirrors')
+        if cfg['mirrors'].include?(fqdn)
+          if cfg['mirrors'][fqdn].include?('components-include')
+            if cfg['mirrors'][fqdn]['components-include'].include?(static_component)
+              return true
+            else
+              return false
+            end
+          end
+        end
+      end
+
+      if cfg.include?('components')
+        if cfg['components'].include?(static_component)
+          if cfg['components'][static_component].include?('limit-mirrors')
+            return (cfg['components'][static_component]['limit-mirrors'].include?(fqdn))
+          elsif cfg['components'][static_component].include?('exclude-mirrors')
+            return (not cfg['components'][static_component]['exclude-mirrors'].include?(fqdn))
+          else
+            return true
+          end
+        end
+      end
+
+      err "Static component #{static_component} appears to be not defined"
+      return false
+  end
+end