Browse Source

Puppet default execution involves the definition of none modules.

The Puppet executor has been modified to consider if the recipe is empty.

Closes Bug: #1477482

Change-Id: I23aad503a758e95729b0fb3108049a6652becb32
Henar Muñoz Frutos 3 years ago
parent
commit
5fc7584583

+ 4
- 2
muranoagent/executors/puppet/__init__.py View File

@@ -86,8 +86,10 @@ class PuppetExecutor(chef_puppet_executor_base.ChefPuppetExecutorBase):
86 86
 
87 87
     def _create_manifest(self, module_name, module_recipe):
88 88
 
89
-        return "node 'default' { class  { " + module_name + '::' +\
90
-               module_recipe + ':}}'
89
+        if len(module_recipe) == 0:
90
+            return "node 'default' {{ class {{ {0}:}}}}".format(module_name)
91
+        return "node 'default' {{ class {{ {0}::{1}:}}}}".\
92
+            format(module_name, module_recipe)
91 93
 
92 94
     def _create_hiera_data(self, cookbook_name,
93 95
                            recipe_attributes):

+ 9
- 1
muranoagent/tests/unit/executors/test_puppet.py View File

@@ -33,6 +33,10 @@ class TestPuppetExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
33 33
         node = self.puppet_executor._create_manifest('cookbook', 'recipe')
34 34
         self.assertEqual(node, self.get_manifest('cookbook', 'recipe'))
35 35
 
36
+    def test_create_manifest_norecipe(self):
37
+        node = self.puppet_executor._create_manifest('cookbook', '')
38
+        self.assertEqual(node, self.get_manifest_norecipe('cookbook'))
39
+
36 40
     def test_create_hierdata(self):
37 41
         atts = {
38 42
             'att1': 'value1',
@@ -126,4 +130,8 @@ class TestPuppetExecutor(base.MuranoAgentTestCase, fixtures.TestWithFixtures):
126 130
 
127 131
     def get_manifest(self, cookbook, recipe):
128 132
         return "node \'default\' { " \
129
-               "class  { " + cookbook + '::' + recipe + ':}}'
133
+               "class { " + cookbook + '::' + recipe + ':}}'
134
+
135
+    def get_manifest_norecipe(self, cookbook):
136
+        return "node \'default\' { " \
137
+               "class { " + cookbook + ':}}'

Loading…
Cancel
Save