<commit_before>{% set armada = salt["pillar.get"]("armada", {}) %}
platform dependencies:
  pkg.installed:
    - names: 
      - git
      - nginx
      - nodejs
      - nodejs-legacy
      - npm

armada service directory:
  file.directory:
    - name: /srv/www/armada
    - makedirs: True
    - user: {{ armada.static_user }}
    - group: {{ armada.static_group }}
    
javascript tools:
  npm.installed:
    - pkgs:
      - grunt-cli
      - bower
    - require:
      - pkg: platform dependencies

#
# Code checkout and nginx config
#

{% if not armada.debug %}
armada code:
  git.latest:
    - name: https://github.com/kriberg/armada.git
    - target: /srv/www/armada/
    - user: {{ armada.static_user }}
    - require:
      - pkg: platform dependencies
      - file: armada service directory

armada site config:
  file.managed:
    - name: /etc/nginx/sites-available/armada-site
    - source: salt://armada/armada-site.jinja
    - template: jinja
    - context:
      armada: {{ armada|yaml }}
    - require:
      - pkg: platform dependencies

enabled site:
  file.symlink:
    - name: /etc/nginx/sites-enabled/armada-site
    - target: /etc/nginx/sites-available/armada-site
    - require:
      - file: armada site config

npm bootstrap:
  npm.bootstrap:
    - name: /srv/www/armada
    - require:
      - npm: javascript tools
      - file: armada service directory

bower bootstrap:
  cmd.run:
    - name: bower install --allow-root
    - cwd: /srv/www/armada
    - require:
      - npm: npm bootstrap

proper rights:
  file.recurse:
    - name: /srv/www/armada
    - user: {{ armada.static_user }}
    - group: {{ armada.static_group }}

{% else %}

armada site config:
  file.managed:
    - name: /etc/nginx/sites-available/armada-debug
    - source: salt://armada/armada-debug.jinja
    - template: jinja
    - context:
      armada: {{ armada|yaml }}
    - require:
      - pkg: platform dependencies

enabled site:
  file.symlink:
    - name: /etc/nginx/sites-enabled/armada-debug
    - target: /etc/nginx/sites-available/armada-debug
    - require:
      - file: armada site config
{% endif %}

#
# Restart nginx<commit_msg>Propagate ownership correctly<commit_after>{% set armada = salt["pillar.get"]("armada", {}) %}
platform dependencies:
  pkg.installed:
    - names: 
      - git
      - nginx
      - nodejs
      - nodejs-legacy
      - npm

armada service directory:
  file.directory:
    - name: /srv/www/armada
    - makedirs: True
    - user: {{ armada.static_user }}
    - group: {{ armada.static_group }}
    
javascript tools:
  npm.installed:
    - pkgs:
      - grunt-cli
      - bower
    - require:
      - pkg: platform dependencies

#
# Code checkout and nginx config
#

{% if not armada.debug %}
armada code:
  git.latest:
    - name: https://github.com/kriberg/armada.git
    - target: /srv/www/armada/
    - user: {{ armada.static_user }}
    - require:
      - pkg: platform dependencies
      - file: armada service directory

armada site config:
  file.managed:
    - name: /etc/nginx/sites-available/armada-site
    - source: salt://armada/armada-site.jinja
    - template: jinja
    - context:
      armada: {{ armada|yaml }}
    - require:
      - pkg: platform dependencies

enabled site:
  file.symlink:
    - name: /etc/nginx/sites-enabled/armada-site
    - target: /etc/nginx/sites-available/armada-site
    - require:
      - file: armada site config

npm bootstrap:
  npm.bootstrap:
    - name: /srv/www/armada
    - require:
      - npm: javascript tools
      - file: armada service directory

bower bootstrap:
  cmd.run:
    - name: bower install --allow-root
    - cwd: /srv/www/armada
    - require:
      - npm: npm bootstrap

proper rights:
  file.directory:
    - name: /srv/www/armada
    - user: {{ armada.static_user }}
    - group: {{ armada.static_group }}
    - recurse:
      - user
      - group

{% else %}

armada site config:
  file.managed:
    - name: /etc/nginx/sites-available/armada-debug
    - source: salt://armada/armada-debug.jinja
    - template: jinja
    - context:
      armada: {{ armada|yaml }}
    - require:
      - pkg: platform dependencies

enabled site:
  file.symlink:
    - name: /etc/nginx/sites-enabled/armada-debug
    - target: /etc/nginx/sites-available/armada-debug
    - require:
      - file: armada site config
{% endif %}

#
# Restart nginx
{'fraction_non_alphanumeric': 0.13023469857340084, 'fraction_numerical': 0.0, 'mean_word_length': 2.163755458515284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3170378', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1482, 'n_words': 318}