<commit_before>
---
# deploy

- name: deploy
  hosts: deploy
  gather_facts: no
  tasks:
    - name: default user
      user: name=bookmarks
            system=yes
            createhome=no
            groups=webstack
      sudo: true
      when: target_user == 'bookmarks'
    
    - name: custom user
      user: name={{target_user}}
      sudo: true
      when: target_user != 'bookmarks'
    
    - name: data dirs
      file: path={{item}} owner={{target_user}} group=webstack state=directory mode=0775
      with_items:
        - /data/deploy/bookmarks/main
        - /data/deploy/bookmarks/prev
        - /data/deploy/bookmarks/next
      sudo: true
      when: not assets_only
    
    - name: project dirs
      file: path={{item}} owner={{target_user}} group=webstack state=directory mode=0775
      with_items:
        - /home/deploy/backups/bookmarks
        - /home/deploy/projects/bookmarks
        - /home/deploy/projects/bookmarks/target
        - /home/deploy/projects/bookmarks/target/data
        - /home/deploy/projects/bookmarks/{{deploy_rev_prefix}}
      sudo: true
    
    - name: link data main
      file: src=/data/deploy/bookmarks/main
            dest=/home/deploy/projects/bookmarks/target/data/main
            owner={{target_user}}
            group=webstack
            state=link
            mode=0775
      sudo: true
      when: not assets_only
    
    - name: sync files to host
      sudo: false
      local_action: >
        command /usr/bin/rsync -az
          --rsync-path="sudo -n rsync"
          -e "ssh -p {{ ansible_port | default(ansible_ssh_port) }}"
          {% if not assets_only %}
          --include='/run.properties'
          --include='/ngx-upstream/bookmarks/upstream.conf'
          --include='/bookmarks-all/target/*jarjar.jar'
          --include='/bookmarks-ts/g/user/UserServices.json'
          {% endif %}
          --include='/bookmarks-ts/dist/**'
          --include='/bookmarks-ts/*.html'
          --include='/bookmarks-ts/favicon.ico'
          {% if nw %}
          --include='/bookmarks-ts/package.json'
          --include='/bookmarks-ts/nw/**'
          --include='/bookmarks-ts/bookmarklet/index.html'
          {% endif %}
          --filter='-! */'
          --prune-empty-dirs
          --chown={{target_user}}:webstack
          --chmod=u=rwX,g=rwX,o=rX
          {{project_dir}}/
          deploy@{{inventory_hostname}}:/home/deploy/projects/bookmarks/{{deploy_rev}}
      register: rsync
      changed_when: "'Number of files transferred: 0' not in rsync.stdout"
    
    - name: nginx domain
      lineinfile: dest=/home/deploy/projects/bookmarks/{{deploy_rev}}/ngx-upstream/bookmarks/upstream.conf
                  regexp="^  server_name bookmarks.local;$"
                  line="  server_name {{ngx_domain}};{% if ngx_certs_dir %} listen 443 ssl http2; ssl_certificate {{ngx_certs_dir}}/cert_chain.crt; ssl_certificate_key {{ngx_certs_dir}}/private.key;{% endif %}"
      sudo: true
      when: not assets_only
    
    - name: link nginx www dir
      file: src=/home/deploy/projects/bookmarks/{{deploy_rev}}/bookmarks-ts
            dest=/home/deploy/projects/bookmarks/{{deploy_rev}}/ngx-upstream/bookmarks/www
            owner={{target_user}}
            group=webstack
            state=link
            mode=0775
      sudo: true
      when: not assets_only
    
    - name: link target dir
      file: src=/home/deploy/projects/bookmarks/target
            dest=/home/deploy/projects/bookmarks/{{deploy_rev}}/target 
            owner={{target_user}}
            group=webstack 
            state=link 
            mode=0775
      sudo: true
    
    - name: link current rev
      file: src=/home/deploy/projects/bookmarks/{{deploy_rev}}
            dest=/home/deploy/projects/bookmarks/current
            owner={{target_user}}
            group=webstack
            state=link
            mode=0775
      sudo: true
      when: not assets_only<commit_msg>fix ansible bug, always link current rev<commit_after>
---
# deploy

- name: deploy
  hosts: deploy
  gather_facts: no
  tasks:
    - name: default user
      user: name=bookmarks
            system=yes
            createhome=no
            groups=webstack
      sudo: true
      when: target_user == 'bookmarks'
    
    - name: custom user
      user: name={{target_user}}
      sudo: true
      when: target_user != 'bookmarks'
    
    - name: data dirs
      file: path={{item}} owner={{target_user}} group=webstack state=directory mode=0775
      with_items:
        - /data/deploy/bookmarks/main
        - /data/deploy/bookmarks/prev
        - /data/deploy/bookmarks/next
      sudo: true
      when: not assets_only
    
    - name: project dirs
      file: path={{item}} owner={{target_user}} group=webstack state=directory mode=0775
      with_items:
        - /home/deploy/backups/bookmarks
        - /home/deploy/projects/bookmarks
        - /home/deploy/projects/bookmarks/target
        - /home/deploy/projects/bookmarks/target/data
        - /home/deploy/projects/bookmarks/{{deploy_rev_prefix}}
      sudo: true
    
    - name: link data main
      file: src=/data/deploy/bookmarks/main
            dest=/home/deploy/projects/bookmarks/target/data/main
            owner={{target_user}}
            group=webstack
            state=link
            mode=0775
      sudo: true
      when: not assets_only
    
    - name: sync files to host
      sudo: false
      local_action: >
        command /usr/bin/rsync -az
          --rsync-path="sudo -n rsync"
          -e "ssh -p {{ ansible_port | default(ansible_ssh_port) }}"
          {% if not assets_only %}
          --include='/run.properties'
          --include='/ngx-upstream/bookmarks/upstream.conf'
          --include='/bookmarks-all/target/*jarjar.jar'
          --include='/bookmarks-ts/g/user/UserServices.json'
          {% endif %}
          --include='/bookmarks-ts/dist/**'
          --include='/bookmarks-ts/*.html'
          --include='/bookmarks-ts/favicon.ico'
          {% if nw %}
          --include='/bookmarks-ts/package.json'
          --include='/bookmarks-ts/nw/**'
          --include='/bookmarks-ts/bookmarklet/index.html'
          {% endif %}
          --filter='-! */'
          --prune-empty-dirs
          --chown={{target_user}}:webstack
          --chmod=u=rwX,g=rwX,o=rX
          {{project_dir}}/
          deploy@{{inventory_hostname}}:/home/deploy/projects/bookmarks/{{deploy_rev}}
      register: rsync
      changed_when: "'Number of files transferred: 0' not in rsync.stdout"
    
    - name: nginx domain
      lineinfile: dest=/home/deploy/projects/bookmarks/{{deploy_rev}}/ngx-upstream/bookmarks/upstream.conf
                  regexp="^  server_name bookmarks.local;$"
                  line="  server_name {{ngx_domain}};{% if ngx_certs_dir %} listen 443 ssl http2; ssl_certificate {{ngx_certs_dir}}/cert_chain.crt; ssl_certificate_key {{ngx_certs_dir}}/private.key;{% endif %}"
      sudo: true
      when: not assets_only
    
    - name: link nginx www dir
      file: src=/home/deploy/projects/bookmarks/{{deploy_rev}}/bookmarks-ts
            dest=/home/deploy/projects/bookmarks/{{deploy_rev}}/ngx-upstream/bookmarks/www
            owner={{target_user}}
            group=webstack
            state=link
            mode=0775
      sudo: true
      when: not assets_only
    
    - name: link target dir
      file: src=/home/deploy/projects/bookmarks/target
            dest=/home/deploy/projects/bookmarks/{{deploy_rev}}/target 
            owner={{target_user}}
            group=webstack 
            state=link 
            mode=0775
      sudo: true
      when: not assets_only
    
    - name: link current rev
      file: src=/home/deploy/projects/bookmarks/{{deploy_rev}}
            dest=/home/deploy/projects/bookmarks/current
            owner={{target_user}}
            group=webstack
            state=link
            mode=0775
      sudo: true
{'fraction_non_alphanumeric': 0.1271261181806728, 'fraction_numerical': 0.00730754693209021, 'mean_word_length': 1.9410892923304928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1501915', 'n_tokens_mistral': 2585, 'n_tokens_neox': 2418, 'n_words': 423}