mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Remove the loop from apply_config
This commit is contained in:
parent
743164844d
commit
c934a2bfa7
1 changed files with 12 additions and 11 deletions
|
@ -401,6 +401,9 @@ def apply_config(path, source=None, salt_env='base'):
|
|||
salt '*' dsc.run_config C:\\DSC\\WebSiteConfiguration salt://dsc/configs/WebSiteConfiguration
|
||||
|
||||
'''
|
||||
# If you're getting an error along the lines of "The client cannot connect
|
||||
# to the destination specified in the request.", try the following:
|
||||
# Enable-PSRemoting -SkipNetworkProfileCheck
|
||||
config = path
|
||||
if source:
|
||||
# Make sure the folder names match
|
||||
|
@ -430,16 +433,17 @@ def apply_config(path, source=None, salt_env='base'):
|
|||
|
||||
# Run the DSC Configuration
|
||||
# Putting quotes around the parameter protects against command injection
|
||||
cmd = '$job = Start-DscConfiguration -Path "{0}"; '.format(config)
|
||||
cmd += 'Do{ } While ($job.State -notin \'Completed\', \'Failed\'); ' \
|
||||
'return $job.State'
|
||||
cmd = 'Start-DscConfiguration -Path "{0}" -Wait -Force'.format(config)
|
||||
ret = _pshell(cmd)
|
||||
|
||||
if ret is False:
|
||||
raise CommandExecutionError('Apply Config Failed: {0}'.format(path))
|
||||
|
||||
cmd = '$status = Get-DscConfigurationStatus; $status.Status'.format(config)
|
||||
ret = _pshell(cmd)
|
||||
log.info('DSC Apply Config: {0}'.format(ret))
|
||||
|
||||
if ret == 'Completed':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return ret == 'Success'
|
||||
|
||||
|
||||
def get_config():
|
||||
|
@ -475,10 +479,7 @@ def test_config():
|
|||
'''
|
||||
cmd = 'Test-DscConfiguration *>&1'
|
||||
ret = _pshell(cmd)
|
||||
if ret == 'True':
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return ret == 'True'
|
||||
|
||||
|
||||
def get_config_status():
|
||||
|
|
Loading…
Add table
Reference in a new issue