<commit_before>---
- hosts: all
  sudo: yes
  gather_facts: no
  tasks:
  - name: Install base packages
    apt: pkg={{ item }} state=present update-cache=yes cache_valid_time=86400
    with_items:
    - python-pip
    - python-dev
    - python-imaging
    - virtualenvwrapper
    - postgresql
    - gettext
    - python-numpy
    - git
    - opensp
    - tidy
    - libmalaga7
    - python-psycopg2
    - language-pack-fi

  - name: Node.js | Package prerequisites for node.js
    action: apt pkg=python-software-properties state=installed
    tags: nodejs
  - name: Node.js | Add the node.js PPA
    action: command add-apt-repository -y ppa:chris-lea/node.js creates=/etc/apt/sources.list.d/chris-lea-node_js-precise.list
    register: node_ppa_result
    tags: nodejs
  - name: Node.js | Update the apt cache for the new repository
    action: apt update-cache=yes
    tags: nodejs
    when: node_ppa_result.changed

  - name: Node.js | Install nodejs and npm
    action: apt pkg=$item state=installed
    tags: nodejs
    with_items:
    - nodejs

  - name: NPM | Install dependencies
    action: npm name={{ item }} global=yes
    with_items:
    - coffee-script
    - less

- hosts: all
  gather_facts: no
  sudo: yes
  sudo_user: postgres
  tasks:
  - name: PostgreSQL | Create database
    action: postgresql_db name=kamu encoding=utf8 lc_collate=fi_FI.UTF8 template=template0
    tags: postgres
  - name: PostgreSQL | Create user
    action: postgresql_user name={{ app_user }} encrypted=no password=kamu
  - name: PostgreSQL | Grant privileges
    action: postgresql_privs db=kamu role={{ app_user }} privs=ALL type=database

- hosts: all
  gather_facts: no
  vars:
      venv: /home/{{ app_user }}/.virtualenvs/kamu
      download_url: http://www.kansanmuisti.fi/storage
  tasks:
  - name: Python | Install kamu requirements
    action: pip virtualenv={{ venv }} virtualenv_site_packages=yes requirements=/vagrant/requirements.txt
  - name: Kamu | Generate settings_local.py
    template: src=settings_local.py.j2 dest=/vagrant/settings_local.py
  - name: Kamu | Add virtualenv execute script
    template: src=venv_exec.j2 dest={{ venv }}/exec mode=0755

  - name: Kamu | Check if database exists
    shell: '[ ! -z "$({{ venv }}/exec /vagrant/manage.py sqlclear parliament)" ]'
    register: kamu_db_result
    ignore_errors: yes
  - name: Kamu | Download database dump
    get_url: src={{ download_url }}/kamu.sql.bz2 dest=/home/{{ app_user }} mode=0644
    when: kamu_db_result.rc != 0
  - name: Kamu | Apply database dump
    shell: bunzip2 -c /home/{{ app_user }}/kamu.sql.bz2 | psql kamu
    when: kamu_db_result.rc != 0

  - name: Kamu | Download image files
    get_url: src={{ download_url }}/kamu-img.tar.bz2 dest=/home/{{ app_user }} mode=0644
  - name: Kamu | Untar image file
    command: tar -C /vagrant -xjf /home/{{ app_user }}/kamu-img.tar.bz2 creates=/vagrant/media/images/parties

  - name: Kamu | Generate translations
    action: command {{ venv }}/exec /vagrant/manage.py compilemessages creates=/vagrant/locale/fi/LC_MESSAGES/django.mo
<commit_msg>Fix bugs in Ansible playbook<commit_after>---
- hosts: all
  sudo: yes
  gather_facts: no
  tasks:
  - name: Install base packages
    apt: pkg={{ item }} state=present update-cache=yes cache_valid_time=86400
    with_items:
    - python-pip
    - python-dev
    - python-imaging
    - virtualenvwrapper
    - postgresql
    - gettext
    - python-numpy
    - git
    - opensp
    - tidy
    - libmalaga7
    - python-psycopg2
    - language-pack-fi

  - name: Node.js | Package prerequisites for node.js
    action: apt pkg=python-software-properties state=installed
    tags: nodejs
  - name: Node.js | Add the node.js PPA
    action: command add-apt-repository -y ppa:chris-lea/node.js creates=/etc/apt/sources.list.d/chris-lea-node_js-precise.list
    register: node_ppa_result
    tags: nodejs
  - name: Node.js | Update the apt cache for the new repository
    action: apt update-cache=yes
    tags: nodejs
    when: node_ppa_result.changed

  - name: Node.js | Install nodejs and npm
    action: apt pkg={{ item }} state=installed
    tags: nodejs
    with_items:
    - nodejs

  - name: NPM | Install dependencies
    action: npm name={{ item }} global=yes
    with_items:
    - coffee-script
    - less

- hosts: all
  gather_facts: no
  sudo: yes
  sudo_user: postgres
  tasks:
  - name: PostgreSQL | Create database
    action: postgresql_db name=kamu encoding=utf8 lc_collate=fi_FI.UTF8 template=template0
    tags: postgres
  - name: PostgreSQL | Create user
    action: postgresql_user name={{ app_user }} encrypted=no password=<PASSWORD>
  - name: PostgreSQL | Grant privileges
    action: postgresql_privs db=kamu role={{ app_user }} privs=ALL type=database

- hosts: all
  gather_facts: no
  vars:
      venv: /home/{{ app_user }}/.virtualenvs/kamu
      download_url: http://www.kansanmuisti.fi/storage
  tasks:
  - name: Python | Install kamu requirements
    action: pip virtualenv={{ venv }} virtualenv_site_packages=yes requirements=/vagrant/requirements.txt
  - name: Kamu | Generate settings_local.py
    template: src=settings_local.py.j2 dest=/vagrant/settings_local.py
  - name: Kamu | Add virtualenv execute script
    template: src=venv_exec.j2 dest={{ venv }}/exec mode=0755

  - name: Kamu | Check if database exists
    shell: '[ ! -z "$({{ venv }}/exec /vagrant/manage.py sqlclear parliament)" ]'
    register: kamu_db_result
    ignore_errors: yes
  - name: Kamu | Download database dump
    get_url: url={{ download_url }}/kamu.sql.bz2 dest=/home/{{ app_user }} mode=0644
    when: kamu_db_result.rc != 0
  - name: Kamu | Apply database dump
    shell: bunzip2 -c /home/{{ app_user }}/kamu.sql.bz2 | psql kamu
    when: kamu_db_result.rc != 0

  - name: Kamu | Download image files
    get_url: url={{ download_url }}/kamu-img.tar.bz2 dest=/home/{{ app_user }} mode=0644
  - name: Kamu | Untar image file
    command: tar -C /vagrant -xjf /home/{{ app_user }}/kamu-img.tar.bz2 creates=/vagrant/media/images/parties

  - name: Kamu | Generate translations
    action: command {{ venv }}/exec /vagrant/manage.py compilemessages creates=/vagrant/locale/fi/LC_MESSAGES/django.mo

{'fraction_non_alphanumeric': 0.11252825314820794, 'fraction_numerical': 0.010009686793671296, 'mean_word_length': 3.0945142101784535, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3796500', 'n_tokens_mistral': 2224, 'n_tokens_neox': 2137, 'n_words': 549}