When using a state like
/tmp/foo:
file.append:
text: bar
in salt-ssh 2016.3.5, the state would fail in test=True mode, but succeed in regular mode.
This is similar to #1864, but specifically applies to the test mode.
Can you elaborate on what error you are receiving? I would expect that state to fail because its not formed as a list but you are stating you get an error when the file does not exist?
I have encountered the same issue:
twig.ini:
file.append:
<ul>
<li>name: /etc/php5/mods-available/twig.ini</li>
<li>text: |<br />
extension=twig.so<br />
test=True----------
ID: twig.ini
Function: file.append
Name: /etc/php5/mods-available/twig.ini
Result: False
Comment: /etc/php5/mods-available/twig.ini: file not found
Started: 12:30:05.862804
Duration: 0.964 ms
Changes:
Whithout test=True
``` ID: twig.ini
Function: file.append
Name: /etc/php5/mods-available/twig.ini
Result: True
Comment: Appended 1 lines
Started: 12:35:02.202383
Duration: 2.254 ms
Changes:
----------
diff:
---
+++
@@ -0,0 +1 @@
+extension=twig.so
The salt master version is salt 2016.3.3 (Boron), minion is salt-call 2016.11.1 (Carbon)
@sblargaba i am only able to replicate your test case if the file does not exist already on first run with test=True. Is that the case for you as well?
I can see that the call: touch(name, makedirs=makedirs) returns {'comment': 'File /tmp/test is set to be created', 'changes': {}, 'name': '/tmp/test', 'result': None} , and then it checks for the result which is none so it returns a failure. We could do some better checking here when the file doesn't exist currently when run with test=True
Yes, I can confirm the issue is only when the file is not present and test=True
Still an issue.
I.e.
# File does not exist - Fails with "/tmp/foo: file not found"
salt-call state.single file.append /tmp/foo text="bar" test=True
# Neither directory nor file does exist - Fails with "/tmp/foo/bar: file not found"
salt-call state.single file.append /tmp/foo text="bar" test=True
Could perhaps modify the error message so that it says "/tmp/foo: file not found - directory does not exist"
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
Most helpful comment
I have encountered the same issue:
twig.ini: file.append: <ul> <li>name: /etc/php5/mods-available/twig.ini</li> <li>text: |<br /> extension=twig.so<br />test=True---------- ID: twig.ini Function: file.append Name: /etc/php5/mods-available/twig.ini Result: False Comment: /etc/php5/mods-available/twig.ini: file not found Started: 12:30:05.862804 Duration: 0.964 ms Changes:Whithout
test=True``` ID: twig.ini
Function: file.append
Name: /etc/php5/mods-available/twig.ini
Result: True
Comment: Appended 1 lines
Started: 12:35:02.202383
Duration: 2.254 ms
Changes:
----------
diff:
---
```
The salt master version is
salt 2016.3.3 (Boron), minion issalt-call 2016.11.1 (Carbon)