mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
prevent exception when test=True
This commit is contained in:
parent
cfe37916c3
commit
d68c5c4be0
1 changed files with 6 additions and 5 deletions
|
@ -368,15 +368,16 @@ class _Ini(_Section):
|
|||
super(_Ini, self).__init__(name, inicontents, separator, commenter)
|
||||
|
||||
def refresh(self, inicontents=None):
|
||||
if inicontents is None and __opts__['test'] is False:
|
||||
if inicontents is None:
|
||||
try:
|
||||
with salt.utils.fopen(self.name) as rfh:
|
||||
inicontents = rfh.read()
|
||||
except (OSError, IOError) as exc:
|
||||
raise CommandExecutionError(
|
||||
"Unable to open file '{0}'. "
|
||||
"Exception: {1}".format(self.name, exc)
|
||||
)
|
||||
if __opts__['test'] is False:
|
||||
raise CommandExecutionError(
|
||||
"Unable to open file '{0}'. "
|
||||
"Exception: {1}".format(self.name, exc)
|
||||
)
|
||||
if not inicontents:
|
||||
return
|
||||
# Remove anything left behind from a previous run.
|
||||
|
|
Loading…
Add table
Reference in a new issue