<commit_before>---

- name: Clear /home/pss/pss symlink
  # It will be recreated below.
  file: path=/home/pss/pss state=absent

- name: Make sure that PSS build directories are clear
  when: clean_pss | default(false)
  file:
    path: "/home/pss/{{ item }}"
    state: absent
  with_items:
    - pss-git
    - pss-local

- name: Check out primary-source-sets app from its repository
  git: >-
      repo=https://github.com/dpla/primary-source-sets.git
      dest=/home/pss/pss-git
      version={{ pss_branch_or_tag }}
      force=true
  become_user: pss
  when: not pss_use_local_source

## Symlink to the build directory, to allow local and git builds to coexist
# neatly ...

# 1. For a git deployment ...
- file: src=/home/pss/pss-git dest=/home/pss/pss state=link
  when: not pss_use_local_source

- name: Check out primary source sets app from mounted directory
  script: copy_local_app.sh
  when: pss_use_local_source

# 2. For a local deployment ...
- file: src=/home/pss/pss-local dest=/home/pss/pss state=link
  when: pss_use_local_source

- name: Update primary-source-sets app configuration files
  template: >-
    src="{{ item }}.j2" dest="/home/pss/pss/config/{{ item }}"
    owner=pss group=pss mode=0640
  with_items:
    - database.yml
    - secrets.yml
  when: not pss_use_local_source

- name: Update primary-source-sets app settings
  template: >-
      src=settings.local.yml.j2
      dest=/home/pss/pss/config/settings.local.yml
      owner=pss group=webapp mode=0640
  when: not pss_use_local_source

- name: Update primary-source-sets unicorn.rb
  template: >-
      src=unicorn.rb.j2 dest=/home/pss/pss/config/unicorn.rb
      owner=pss group=pss mode=0644

- name: Add dpla_frontend_assets to Gemfile if branding is turned on
  lineinfile: >
    dest=/home/pss/pss/Gemfile
    state=present
    regexp=dpla_frontend_assets
    line="gem 'dpla_frontend_assets', git: '<EMAIL>:dpla/frontend-assets.git'"
  when: pss_include_branding

# To use "Clean rbenv", define the variable `clean_rbenv', which is not defined
# anywhere by default.
- name: Clean rbenv
  file:
    path: /home/pss/.rbenv
    state: absent
  when: clean_rbenv | default(false)

- name: Make sure that rbenv and bundler are current
  script: >-
      ../../../files/install_ruby_tools.sh {{ pss_rbenv_version }}
  become_user: pss

- name: Ensure the existence and permissions of necessary directories<commit_msg>Improve PSS deployment with local source (#250)<commit_after>---

- name: Clear /home/pss/pss symlink
  # It will be recreated below.
  file: path=/home/pss/pss state=absent

- name: Make sure that PSS build directories are clear
  when: clean_pss | default(false)
  file:
    path: "/home/pss/{{ item }}"
    state: absent
  with_items:
    - pss-git
    - pss-local

- name: Check out primary-source-sets app from its repository
  git: >-
      repo=https://github.com/dpla/primary-source-sets.git
      dest=/home/pss/pss-git
      version={{ pss_branch_or_tag }}
      force=true
  become_user: pss
  when: not pss_use_local_source

## Symlink to the build directory, to allow local and git builds to coexist
# neatly ...

# 1. For a git deployment ...
- file: src=/home/pss/pss-git dest=/home/pss/pss state=link
  when: not pss_use_local_source

- name: Check out primary source sets app from mounted directory
  script: copy_local_app.sh
  when: pss_use_local_source

# 2. For a local deployment ...
- file: src=/home/pss/pss-local dest=/home/pss/pss state=link
  when: pss_use_local_source

- name: Update primary-source-sets app database configuration file
  template:
    src: database.yml.j2
    dest: /home/pss/pss/config/database.yml
    owner: pss
    group: pss
    mode: 0640

- name: Update primary-source-sets app secrets configuration file
  template:
    src: secrets.yml.j2
    dest: /home/pss/pss/config/secrets.yml
    owner: pss
    group: pss
    mode: 0640

- name: Update primary-source-sets app settings
  template: >-
      src=settings.local.yml.j2
      dest=/home/pss/pss/config/settings.local.yml
      owner=pss group=webapp mode=0640

- name: Update primary-source-sets unicorn.rb
  template: >-
      src=unicorn.rb.j2 dest=/home/pss/pss/config/unicorn.rb
      owner=pss group=pss mode=0644

- name: Add dpla_frontend_assets to Gemfile if branding is turned on
  lineinfile: >
    dest=/home/pss/pss/Gemfile
    state=present
    regexp=dpla_frontend_assets
    line="gem 'dpla_frontend_assets', git: '<EMAIL>:dpla/frontend-assets.git'"
  when: pss_include_branding

# To use "Clean rbenv", define the variable `clean_rbenv', which is not defined
# anywhere by default.
- name: Clean rbenv
  file:
    path: /home/pss/.rbenv
    state: absent
  when: clean_rbenv | default(false)

- name: Make sure that rbenv and bundler are current
  script: >-
      ../../../files/install_ruby_tools.sh {{ pss_rbenv_version }}
  become_user: pss

- name: Ensure the existence and permissions of necessary directories
{'fraction_non_alphanumeric': 0.11034761519805983, 'fraction_numerical': 0.008488278092158448, 'mean_word_length': 3.1905165114309906, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '6867947', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1750, 'n_words': 453}