<commit_before>---
- connection: local
  hosts: localhost
  gather_facts: False
  sudo_user: www-data

  tasks:
{% if autodeploy_external_asset_storage_enabled %}
    - name: External Asset Storage | Disconnect from Deployment Path
      file:
        state: absent
        path: "{{ autodeploy_external_asset_storage_destination }}"

{% endif %}
   - name: Fetch Application Code from git
      git:
        repo: "{{ autodeploy_repository_origin }}"
        accept_hostkey: yes
        dest: "{{ autodeploy_docroot }}"
        key_file: "{{ autodeploy_key }}"
        update: yes
        force: yes
        version: "{{ autodeploy_repository_branch }}"
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
{% if autodeploy_external_asset_storage_enabled %}
    - name: External Asset Storage | Discard Assets from Repository
      file:
        state: absent
        path: "{{ autodeploy_external_asset_storage_destination }}"

    - name: External Asset Storage | Connect to Deployment Path
      file:
        state: link
        src: "{{ autodeploy_external_asset_storage_source }}"
        dest: "{{ autodeploy_external_asset_storage_destination }}"
{% endif %}
{% if autodeploy_insert_enabled %}
{%   for insert in autodeploy_insert %}

    - name: "Delete {{ insert.file }}"
      file:
        state: absent
        path: "{{ insert.file }}"

    - name: "Insert Data into {{ insert.file }}"
      lineinfile:
        state: present
        create: yes
        dest: "{{ insert.file }}"
        regexp: "{{ insert.match | default(insert.contents) }}"
        line: "{{ insert.contents }}"
{%   endfor %}
{% endif %}
{% if autodeploy_for_wordpress %}

    - name: Configure Application | database parameters
      no_log: yes
      lineinfile:
        state: present
        dest: "{{ autodeploy_wordpress_config_path }}"
        regexp: "{{ '{{ item.regexp }}' }}"
        line: "{{ '{{ item.line }}' }}"
      with_items:
        - regexp: "'DB_HOST'"
          line: "define('DB_HOST', 'database.{{ project }}-{{ environment_tier }}.{{ domain }}');"
        - regexp: DB_NAME
          line: "define('DB_NAME', '{{ database_name | default(project) }}');"
        - regexp: DB_USER
          line: "define('DB_USER', '{{ database_username | default(project) }}');"
        - regexp: DB_PASSWORD
          line: "define('DB_PASSWORD', '{{ database_password | mandatory }}');"
{% endif %}
{% if autodeploy_database_bundled and environment_tier not in ['production'] %}
{%   if autodeploy_database_compressed %}

    - name: Database | Unpack
      unarchive:
        src: "{{ autodeploy_docroot }}/{{ autodeploy_database_file_compressed }}"
        dest: "{{ autodeploy_docroot }}"
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
{%   endif %}
{%   if autodeploy_rewrite_enabled %}
{%     for file in autodeploy_rewrite_files %}

    - name: "Rewrite Deployed Code in {{ file }}"
      replace:
        dest: "{{ file }}"
        regexp: "{{ autodeploy_rewrite_match | mandatory }}"
        replace: "{{ autodeploy_rewrite_replace }}"
{%     endfor %}
{%   endif %}
{%   if autodeploy_database_engine == 'postgres' %}

    - name: Database | Drop / Create / Import
      command: "{{ '{{ item }}' }}"
      no_log: yes
      with_items:
        - "/usr/bin/dropdb {{ database_name | default(project) }}"
        - "/usr/bin/createdb {{ database_name | default(project) }}"
        - "/usr/bin/psql -f {{ autodeploy_docroot }}/{{ autodeploy_database_file }}"
      environment:
        PGHOST: "database.{{ project }}-{{ environment_tier }}.{{ domain }}"
        PGUSER: "{{ database_username | default(project) }}"
        PGDATABASE: "{{ database_name | default(project) }}"
        PGPASSWORD: "{{ database_password | mandatory }}"
{%   else %}

    - name: Database | Drop / Create / Import
      mysql_db:
        state: "{{ '{{ item.state }}' }}"
        login_host: "database.{{ project }}-{{ environment_tier }}.{{ domain }}"
        login_password: "{{ <PASSWORD> }}"
        login_user: "{{ database_username | default(project) }}"
        name: "{{ database_name | default(project) }}"
        target: "{{ '{{ item.target | default(omit) }}' }}"
      with_items:
        - { state: absent }
        - { state: present }
        - { state: import, target: "{{ autodeploy_docroot }}/{{ autodeploy_database_file }}" }
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      ignore_errors: True
{%   endif %}
{% endif %}
{% if autodeploy_for_node %}

    - name: Update Dependencies | npm
      npm:
        state: latest
        path: "{{ autodeploy_docroot }}"
      environment:
        HOME: "/var/www"
{% endif %}
{% if autodeploy_for_ruby %}

    - name: Update Dependencies | Bundler
      shell: "cd {{ autodeploy_docroot }} && /usr/local/bin/bundle install"
{% endif %}
{% if autodeploy_composer_enabled %}

    - name: Install Modules | Composer
      shell: "cd {{ autodeploy_composer_root }} && /usr/local/bin/composer install"
{% endif %}
{% if autodeploy_compass_enabled %}

    - name: Compile | Compass / SCSS
      shell: "cd {{ autodeploy_compass_root }} && /usr/local/bin/compass compile -e production --force"
{% endif %}
{% if autodeploy_requirejs_enabled %}

    - name: Compile | RequireJS
      command: "/usr/bin/r.js -o {{ '{{ item }}' }}"
      with_fileglob: "{{ autodeploy_requirejs_fileglob }}"
{% endif %}

{% for post_deployment_command in autodeploy_post_deployment_commands %}

    - name: Post Deployment Command | {{ post_deployment_command }}
      shell: "cd {{ autodeploy_docroot }} && {{ post_deployment_command }}"
{% endfor %}

{% if autodeploy_restart_enabled %}

    - name: Restart Application
      command: "sudo monit restart {{ autodeploy_restart_target | mandatory }}"
{% endif %}

{% if autodeploy_slack_notifications_enabled %}

    - name: Get Instance ID
      shell: ec2metadata | grep instance-id | cut -f 2 -d ' ' | tr -d -
      register: instance_id
      tags:
        - hostname

    - name: Notify via Slack
      slack:
        domain: "{{ slack_domain }}"
        channel: "{{ slack_channel }}"
        token: "{{ slack_token | mandatory }}"
        msg: "Successfully Deployed Branch '{{ autodeploy_repository_branch }}' to {{ system_role }}-{{ instance_id.stdout }}-{{ project }}-{{ environment_tier }}"
{% endif %}
<commit_msg>stupid spacing issue in deploy.yml<commit_after>---
- connection: local
  hosts: localhost
  gather_facts: False
  sudo_user: www-data

  tasks:
{% if autodeploy_external_asset_storage_enabled %}
    - name: External Asset Storage | Disconnect from Deployment Path
      file:
        state: absent
        path: "{{ autodeploy_external_asset_storage_destination }}"

{% endif %}
    - name: Fetch Application Code from git
      git:
        repo: "{{ autodeploy_repository_origin }}"
        accept_hostkey: yes
        dest: "{{ autodeploy_docroot }}"
        key_file: "{{ autodeploy_key }}"
        update: yes
        force: yes
        version: "{{ autodeploy_repository_branch }}"
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
{% if autodeploy_external_asset_storage_enabled %}
    - name: External Asset Storage | Discard Assets from Repository
      file:
        state: absent
        path: "{{ autodeploy_external_asset_storage_destination }}"

    - name: External Asset Storage | Connect to Deployment Path
      file:
        state: link
        src: "{{ autodeploy_external_asset_storage_source }}"
        dest: "{{ autodeploy_external_asset_storage_destination }}"
{% endif %}
{% if autodeploy_insert_enabled %}
{%   for insert in autodeploy_insert %}

    - name: "Delete {{ insert.file }}"
      file:
        state: absent
        path: "{{ insert.file }}"

    - name: "Insert Data into {{ insert.file }}"
      lineinfile:
        state: present
        create: yes
        dest: "{{ insert.file }}"
        regexp: "{{ insert.match | default(insert.contents) }}"
        line: "{{ insert.contents }}"
{%   endfor %}
{% endif %}
{% if autodeploy_for_wordpress %}

    - name: Configure Application | database parameters
      no_log: yes
      lineinfile:
        state: present
        dest: "{{ autodeploy_wordpress_config_path }}"
        regexp: "{{ '{{ item.regexp }}' }}"
        line: "{{ '{{ item.line }}' }}"
      with_items:
        - regexp: "'DB_HOST'"
          line: "define('DB_HOST', 'database.{{ project }}-{{ environment_tier }}.{{ domain }}');"
        - regexp: DB_NAME
          line: "define('DB_NAME', '{{ database_name | default(project) }}');"
        - regexp: DB_USER
          line: "define('DB_USER', '{{ database_username | default(project) }}');"
        - regexp: DB_PASSWORD
          line: "define('DB_PASSWORD', '{{ database_password | mandatory }}');"
{% endif %}
{% if autodeploy_database_bundled and environment_tier not in ['production'] %}
{%   if autodeploy_database_compressed %}

    - name: Database | Unpack
      unarchive:
        src: "{{ autodeploy_docroot }}/{{ autodeploy_database_file_compressed }}"
        dest: "{{ autodeploy_docroot }}"
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
{%   endif %}
{%   if autodeploy_rewrite_enabled %}
{%     for file in autodeploy_rewrite_files %}

    - name: "Rewrite Deployed Code in {{ file }}"
      replace:
        dest: "{{ file }}"
        regexp: "{{ autodeploy_rewrite_match | mandatory }}"
        replace: "{{ autodeploy_rewrite_replace }}"
{%     endfor %}
{%   endif %}
{%   if autodeploy_database_engine == 'postgres' %}

    - name: Database | Drop / Create / Import
      command: "{{ '{{ item }}' }}"
      no_log: yes
      with_items:
        - "/usr/bin/dropdb {{ database_name | default(project) }}"
        - "/usr/bin/createdb {{ database_name | default(project) }}"
        - "/usr/bin/psql -f {{ autodeploy_docroot }}/{{ autodeploy_database_file }}"
      environment:
        PGHOST: "database.{{ project }}-{{ environment_tier }}.{{ domain }}"
        PGUSER: "{{ database_username | default(project) }}"
        PGDATABASE: "{{ database_name | default(project) }}"
        PGPASSWORD: "{{ database_password | mandatory }}"
{%   else %}

    - name: Database | Drop / Create / Import
      mysql_db:
        state: "{{ '{{ item.state }}' }}"
        login_host: "database.{{ project }}-{{ environment_tier }}.{{ domain }}"
        login_password: "{{ <PASSWORD> }}"
        login_user: "{{ database_username | default(project) }}"
        name: "{{ database_name | default(project) }}"
        target: "{{ '{{ item.target | default(omit) }}' }}"
      with_items:
        - { state: absent }
        - { state: present }
        - { state: import, target: "{{ autodeploy_docroot }}/{{ autodeploy_database_file }}" }
      environment:
        PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      ignore_errors: True
{%   endif %}
{% endif %}
{% if autodeploy_for_node %}

    - name: Update Dependencies | npm
      npm:
        state: latest
        path: "{{ autodeploy_docroot }}"
      environment:
        HOME: "/var/www"
{% endif %}
{% if autodeploy_for_ruby %}

    - name: Update Dependencies | Bundler
      shell: "cd {{ autodeploy_docroot }} && /usr/local/bin/bundle install"
{% endif %}
{% if autodeploy_composer_enabled %}

    - name: Install Modules | Composer
      shell: "cd {{ autodeploy_composer_root }} && /usr/local/bin/composer install"
{% endif %}
{% if autodeploy_compass_enabled %}

    - name: Compile | Compass / SCSS
      shell: "cd {{ autodeploy_compass_root }} && /usr/local/bin/compass compile -e production --force"
{% endif %}
{% if autodeploy_requirejs_enabled %}

    - name: Compile | RequireJS
      command: "/usr/bin/r.js -o {{ '{{ item }}' }}"
      with_fileglob: "{{ autodeploy_requirejs_fileglob }}"
{% endif %}

{% for post_deployment_command in autodeploy_post_deployment_commands %}

    - name: Post Deployment Command | {{ post_deployment_command }}
      shell: "cd {{ autodeploy_docroot }} && {{ post_deployment_command }}"
{% endfor %}

{% if autodeploy_restart_enabled %}

    - name: Restart Application
      command: "sudo monit restart {{ autodeploy_restart_target | mandatory }}"
{% endif %}

{% if autodeploy_slack_notifications_enabled %}

    - name: Get Instance ID
      shell: ec2metadata | grep instance-id | cut -f 2 -d ' ' | tr -d -
      register: instance_id
      tags:
        - hostname

    - name: Notify via Slack
      slack:
        domain: "{{ slack_domain }}"
        channel: "{{ slack_channel }}"
        token: "{{ slack_token | mandatory }}"
        msg: "Successfully Deployed Branch '{{ autodeploy_repository_branch }}' to {{ system_role }}-{{ instance_id.stdout }}-{{ project }}-{{ environment_tier }}"
{% endif %}

{'fraction_non_alphanumeric': 0.15061173919776985, 'fraction_numerical': 0.0003097413659594239, 'mean_word_length': 2.7510891664246295, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2539867', 'n_tokens_mistral': 4280, 'n_tokens_neox': 3969, 'n_words': 842}