mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Backport changes from #45308
This commit is contained in:
parent
f7da716d32
commit
0356b3d56f
4 changed files with 23 additions and 16 deletions
|
@ -2332,9 +2332,17 @@ def managed(name,
|
|||
)
|
||||
|
||||
if salt.utils.is_windows():
|
||||
ret = __salt__['file.check_perms'](
|
||||
name, ret, win_owner, win_perms, win_deny_perms,
|
||||
win_inheritance)
|
||||
try:
|
||||
ret = __salt__['file.check_perms'](
|
||||
path=name,
|
||||
ret=ret,
|
||||
owner=win_owner,
|
||||
grant_perms=win_perms,
|
||||
deny_perms=win_deny_perms,
|
||||
inheritance=win_inheritance)
|
||||
except CommandExecutionError as exc:
|
||||
if exc.strerror.startswith('Path not found'):
|
||||
ret['pchanges'] = '{0} will be created'.format(name)
|
||||
|
||||
if isinstance(ret['pchanges'], tuple):
|
||||
ret['result'], ret['comment'] = ret['pchanges']
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# | | |
|
||||
# B --------+ | |
|
||||
# | |
|
||||
# D-------------+ |
|
||||
# D-------------+ |
|
||||
# |
|
||||
# E-----------------+
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
test_file:
|
||||
file.managed:
|
||||
- name: /tmp/nonbase_env
|
||||
- name: {{ salt['runtests_helpers.get_salt_temp_dir_for_path']('nonbase_env') }}
|
||||
- source: salt://nonbase_env
|
||||
|
|
|
@ -206,12 +206,7 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
||||
debian_chroot=$(cat /etc/debian_chroot)
|
||||
fi
|
||||
''')
|
||||
|
||||
if not salt.utils.is_windows():
|
||||
contents += os.linesep
|
||||
|
||||
contents += textwrap.dedent('''\
|
||||
# enable bash completion in interactive shells
|
||||
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
||||
. /etc/bash_completion
|
||||
|
@ -956,7 +951,8 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
self.assertIn('Gromit', data)
|
||||
self.assertIn('Comte', data)
|
||||
finally:
|
||||
os.unlink(tgt)
|
||||
if os.path.islink(tgt):
|
||||
os.unlink(tgt)
|
||||
|
||||
# onchanges tests
|
||||
|
||||
|
@ -1258,17 +1254,20 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
test state.sls with saltenv using a nonbase environment
|
||||
with a salt source
|
||||
'''
|
||||
file_name = os.path.join(TMP, 'nonbase_env')
|
||||
state_run = self.run_function(
|
||||
'state.sls',
|
||||
mods='non-base-env',
|
||||
saltenv='prod'
|
||||
)
|
||||
state_id = 'file_|-test_file_|-/tmp/nonbase_env_|-managed'
|
||||
self.assertEqual(state_run[state_id]['comment'], 'File /tmp/nonbase_env updated')
|
||||
self.assertTrue(state_run['file_|-test_file_|-/tmp/nonbase_env_|-managed']['result'])
|
||||
self.assertTrue(os.path.isfile('/tmp/nonbase_env'))
|
||||
state_id = 'file_|-test_file_|-{0}_|-managed'.format(file_name)
|
||||
self.assertEqual(state_run[state_id]['comment'],
|
||||
'File {0} updated'.format(file_name))
|
||||
self.assertTrue(
|
||||
state_run['file_|-test_file_|-{0}_|-managed'.format(file_name)]['result'])
|
||||
self.assertTrue(os.path.isfile(file_name))
|
||||
|
||||
def tearDown(self):
|
||||
nonbase_file = '/tmp/nonbase_env'
|
||||
nonbase_file = os.path.join(TMP, 'nonbase_env')
|
||||
if os.path.isfile(nonbase_file):
|
||||
os.remove(nonbase_file)
|
||||
|
|
Loading…
Add table
Reference in a new issue