discourse:
  pkg.installed:
    - pkgs:
      - git
      - ruby
      - bundler
      - imagemagick
      - advancecomp
      - gifsicle
      - jhead
      - jpegoptim
      - libjpeg-turbo-progs
      - optipng
      - pngcrush
      - pngquant
      - libpq-dev
      - nodejs
      - npm

  git.latest:
    - name: https://github.com/discourse/discourse.git
    - rev: v1.5.3
    - target: /srv/discourse
    - require:
      - pkg: discourse


discourse-ruby-install:
  cmd.run:
    - name: "bundle install --deployment --without test --without development"
    - cwd: /srv/discourse
    - onchanges:
      - git: discourse


discourse-node-install:
  cmd.run:
    - name: "npm install -g svgo phantomjs-prebuilt"
    - cwd: /srv/discourse
    - onchanges:
      - git: discourse


discourse-migrate:
  cmd.run:
    - name: "bundle exec rake db:migrate"
    - cwd: /srv/discourse
    - onchanges:
      - cmd: discourse-ruby-install

discourse:
  pkg.installed:
    - pkgs:
      - git
      - ruby
      - bundler
      - imagemagick
      - advancecomp
      - gifsicle
      - jhead
      - jpegoptim
      - libjpeg-turbo-progs
      - optipng
      - pngcrush
      - pngquant
      - libpq-dev
      - nodejs
      - npm

  git.latest:
    - name: https://github.com/discourse/discourse.git
    - rev: v1.5.3
    - target: /srv/discourse
    - require:
      - pkg: discourse


discourse-ruby-install:
  cmd.run:
    - name: "bundle install --deployment --without test --without development"
    - cwd: /srv/discourse
    - env:
      - DISCOURSE_DB_SOCKET: ''
      - DISCOURSE_DB_USERNAME: discourse
      - DISCOURSE_DB_PASSWORD: {{ pillar["postgresql-users"]["discourse"] }}
      - DISCOURSE_DB_HOST: {{ salt["mine.get"](pillar["roles"]["postgresql"], "psf_internal").values()|first }}
      - DISCOURSE_DB_PORT: {{ pillar["postgresql"]["port"] }}
    - onchanges:
      - git: discourse


discourse-node-install:
  cmd.run:
    - name: "npm install -g svgo phantomjs-prebuilt"
    - cwd: /srv/discourse
    - onchanges:
      - git: discourse


discourse-migrate:
  cmd.run:
    - name: "bundle exec rake db:migrate"
    - cwd: /srv/discourse
    - onchanges:
      - cmd: discourse-ruby-install

Add database credentials to the migrate call
Add database credentials to the migrate call

zware/psf-salt,python/psf-salt,zware/psf-salt,zware/psf-salt,python/psf-salt,python/psf-salt,python/psf-salt,zware/psf-salt