cmd.run cwd should not be checked before preconditions
See original GitHub issueInteresting catch-22 issue here. Say you have:
TaskA:
cmd.run:
- name: mkdir /tmp/a
- unless: which B
TaskB:
cmd.run:
- name: echo "hello" > /bin/B
- unless: which B
- cwd: /tmp/a
- require:
- TaskA
The first time this provisions, it works fine. Then the machine reboots and /tmp is gone.
The next time it provisions, it will fail because the cwd for TaskB no longer exists, and wont be created because the ‘unless’ precondition of TaskA is now fulfilled. We’re stuck.
I know this seems a silly case, but you can conceivably see a number of chained build steps doing something like this.
I’ve had a stab at fixing this here at eeaston/salt@3273ae on the 2014.1 branch, but it’s a bit of an API change. The changes were to move the cwd existence checking until after the precondition checking, and also remove the cwd from the context of the ‘unless’ and ‘onlyif’ tests.
If you’d like me to continue on this I can (I’ll write some tests and stuff), but the removal of the cwd from the ‘unless’ and ‘onlyif’ checks will need to be documented. What say ye? Cheers, Ed
Issue Analytics
- State:
- Created 9 years ago
- Comments:8 (5 by maintainers)
I’m seeing something similar to this with cmd.run + cwd + onlyif
I would expect that the state is skipped if the onlyif test fails, but instead I’m getting:
My version
I’'m having this same issue on 2016.03.0