diff --git a/salt/manager/tools/sbin/so-minion b/salt/manager/tools/sbin/so-minion index 417b1eaf3..2d5ef448e 100755 --- a/salt/manager/tools/sbin/so-minion +++ b/salt/manager/tools/sbin/so-minion @@ -462,19 +462,14 @@ function add_sensor_to_minion() { echo " lb_procs: '$CORECOUNT'" echo "suricata:" echo " enabled: True " + echo " pcap:" + echo " enabled: True" if [[ $is_pcaplimit ]]; then - echo " pcap:" echo " maxsize: $MAX_PCAP_SPACE" fi echo " config:" echo " af-packet:" echo " threads: '$CORECOUNT'" - echo "pcap:" - echo " enabled: True" - if [[ $is_pcaplimit ]]; then - echo " config:" - echo " diskfreepercentage: $DFREEPERCENT" - fi echo " " } >> $PILLARFILE if [ $? -ne 0 ]; then diff --git a/salt/manager/tools/sbin/so-yaml.py b/salt/manager/tools/sbin/so-yaml.py index fd5d8b056..598948119 100755 --- a/salt/manager/tools/sbin/so-yaml.py +++ b/salt/manager/tools/sbin/so-yaml.py @@ -256,7 +256,7 @@ def replacelistobject(args): def addKey(content, key, value): pieces = key.split(".", 1) if len(pieces) > 1: - if not pieces[0] in content: + if pieces[0] not in content or content[pieces[0]] is None: content[pieces[0]] = {} addKey(content[pieces[0]], pieces[1], value) elif key in content: @@ -346,7 +346,12 @@ def get(args): print(f"Key '{key}' not found by so-yaml.py", file=sys.stderr) return 2 - print(yaml.safe_dump(output)) + if isinstance(output, bool): + print(str(output).lower()) + elif isinstance(output, (dict, list)): + print(yaml.safe_dump(output).strip()) + else: + print(output) return 0 diff --git a/salt/manager/tools/sbin/so-yaml_test.py b/salt/manager/tools/sbin/so-yaml_test.py index 6f479921b..b829108a0 100644 --- a/salt/manager/tools/sbin/so-yaml_test.py +++ b/salt/manager/tools/sbin/so-yaml_test.py @@ -393,7 +393,7 @@ class TestRemove(unittest.TestCase): result = soyaml.get([filename, "key1.child2.deep1"]) self.assertEqual(result, 0) - self.assertIn("45\n...", mock_stdout.getvalue()) + self.assertEqual("45\n", mock_stdout.getvalue()) def test_get_str(self): with patch('sys.stdout', new=StringIO()) as mock_stdout: @@ -404,7 +404,18 @@ class TestRemove(unittest.TestCase): result = soyaml.get([filename, "key1.child2.deep1"]) self.assertEqual(result, 0) - self.assertIn("hello\n...", mock_stdout.getvalue()) + self.assertEqual("hello\n", mock_stdout.getvalue()) + + def test_get_bool(self): + with patch('sys.stdout', new=StringIO()) as mock_stdout: + filename = "/tmp/so-yaml_test-get.yaml" + file = open(filename, "w") + file.write("{key1: { child1: 123, child2: { deep1: 45 } }, key2: false, key3: [e,f,g]}") + file.close() + + result = soyaml.get([filename, "key2"]) + self.assertEqual(result, 0) + self.assertEqual("false\n", mock_stdout.getvalue()) def test_get_list(self): with patch('sys.stdout', new=StringIO()) as mock_stdout: