mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix seed.mkconfig yamldump
This fixes #24071 Signed-off-by: Mathieu Le Marec - Pasquet <kiorky@cryptelium.net>
This commit is contained in:
parent
76ddb683f4
commit
96b8d55f14
2 changed files with 20 additions and 6 deletions
|
@ -15,6 +15,7 @@ import tempfile
|
|||
# Import salt libs
|
||||
import salt.crypt
|
||||
import salt.utils
|
||||
import salt.utils.cloud
|
||||
import salt.config
|
||||
import salt.syspaths
|
||||
import uuid
|
||||
|
@ -203,7 +204,7 @@ def mkconfig(config=None,
|
|||
# Write the new minion's config to a tmp file
|
||||
tmp_config = os.path.join(tmp, 'minion')
|
||||
with salt.utils.fopen(tmp_config, 'w+') as fp_:
|
||||
fp_.write(yaml.dump(config, default_flow_style=False))
|
||||
fp_.write(salt.utils.cloud.salt_config_to_yaml(config))
|
||||
|
||||
# Generate keys for the minion
|
||||
pubkeyfn = os.path.join(tmp, 'minion.pub')
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from salttesting import skipIf, TestCase
|
||||
|
@ -14,14 +16,14 @@ from salttesting.mock import (
|
|||
mock_open,
|
||||
patch)
|
||||
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.utils.odict
|
||||
from salt.modules import seed
|
||||
import os
|
||||
import shutil
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Globals
|
||||
seed.__salt__ = {}
|
||||
|
@ -30,6 +32,17 @@ seed.__opts__ = {}
|
|||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class SeedTestCase(TestCase):
|
||||
def test_mkconfig(self):
|
||||
with patch.dict(seed.__opts__,
|
||||
{'master': 'foo'}):
|
||||
ddd = salt.utils.odict.OrderedDict()
|
||||
ddd['b'] = 'b'
|
||||
ddd['a'] = 'b'
|
||||
data = seed.mkconfig(ddd, approve_key=False)
|
||||
with open(data['config']) as fic:
|
||||
fdata = fic.read()
|
||||
self.assertEqual(fdata, 'b: b\na: b\nmaster: foo\n')
|
||||
|
||||
'''
|
||||
Test cases for salt.modules.seed
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue