I am trying to write a deploy script with salt. It mostly works. I have to run highstate a couple of times for it work all the way. My biggest issue is working through how to execute commands one after another based on specific first one, and them actually finishing/working.

Here is my demo.sls salt state:

{% set web_root = "/var/www/demo/" %}

    - system_site_packages: False
    - require:
      - pkg: python-virtualenv

    - name: git://localhost/demo.git
    - target: {{ web_root }}

    - name: 'source /var/www/venv/demo/bin/activate && pip install -r requirements.txt'
    - cwd: {{ web_root }}
    - watch:
      - git: demo

    - name: 'source /var/www/venv/demo/bin/activate && python manage.py syncdb --noinput'
    - cwd: {{ web_root }}
    - watch:
      - cmd: demo_pip

    - name: supervisorctl restart gunicorn
    - watch:
      - cmd: run_migrations

I have set it so that demo_pip runs after the git call (which works great), but to be honest demo_pip doesn't actually run. The output from salt is that it ran, but none of the requirements in requirements.txt were installed.

I have tried to put the requirements in the virtualenv.managed section so that runs it, but I have to run 2 highstates at that point. 1) to get the latest from git, seems to run bot exclusivly 2) to install the requirements. For some reason even after putting the virtualenv.managed section after demo it still doesn't register the new requirements file.

Am I using the wrong cmd? Or do I have an order problem?


I finally figured this out. It looks like it was a file/folder permissions problem. I set a file.managed for all folders in /var/www to be in group www-data. Also made sure everything executed as www-data, and after that things started working like expected.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.