Closed vkurup closed 8 years ago
This worked for me on a project where letsencrypt was already there, but failed when I removed letsencrypt and tried deploying. The onlyif doesn't seem to be having the desired effect:
----------
ID: really_reset_letsencrypt
Function: cmd.run
Name: git reset --hard HEAD
Result: False
Comment: Desired working directory "/var/www/edxpass/letsencrypt" is not available
Started: 21:01:01.900810
Duration: 1.102 ms
Changes:
----------
I just pushed a version that removes the cwd
param because salt tries to apply that before running the onlyif
clause.
I tested it in a minimal fashion by creating a test file named /srv/salt/vinod.sls
with these contents:
reset_repo
cmd.run:
- name: cd /fakedir && git reset --hard HEAD
- onlyif: test -e /fakedir/.git
install_letsencrypt:
git.latest:
- name: https://github.com/letsencrypt/letsencrypt/
- target: /fakedir
- require:
- cmd: reset_repo
I then ran: sudo salt '*' state.apply vinod
It seems to work as expected. If /fakedir
is not there, the reset is skipped and the repo is cloned. If /fakedir/.git
is there, then the reset occurs and the repo is updated.
This seems reasonable-ish according to the standards of Salt. :+1:
I upgraded epicallies staging to use this PR (1.7.2) and it was successful. I deleted the directory and redeployed and that was also successful.
I haven't had a chance to test this yet.
I'm hoping that on a first run, the
onlyif
test would return false, so thegit reset
would NOT get run, and onlyinstall_letsencrypt
would get run. Every subsequent run, theonlyif
test would return true, so thegit reset
would run before theinstall_letsencrypt
This is another attempt at fixing #133 since it seems the salt version didn't work. (per testing on edxpass)