<commit_before>---
- name: upgrade all packages
  apt: update_cache=yes

- name: install required packages
  apt: pkg={{ item }} state=latest
  with_items:
  - python-psycopg2 
  - postgresql 
  - postgresql-contrib

- name: Make sure postgres is running
  service: name=postgresql state=started enabled=yes

- name: Create postgres database
  postgresql_db: name={{ irods_db_name }} state=present
  sudo: true
  sudo_user: postgres

- name: Create postgres user
  postgresql_user: name={{ irods_db_user }} password={{ <PASSWORD> }} db={{ irods_db_name }} priv=ALL encrypted=no state=present
  sudo: true
  sudo_user: postgres<commit_msg>allow remote connections to postgres database<commit_after>---
- name: upgrade all packages
  apt: update_cache=yes

- name: install required packages
  apt: pkg={{ item }} state=latest
  with_items:
  - python-psycopg2 
  - postgresql 
  - postgresql-contrib

- name: make sure postgres is running
  service: name=postgresql state=started enabled=yes

- name: create postgres database
  postgresql_db: name={{ irods_db_name }} state=present
  sudo: true
  sudo_user: postgres

- name: create postgres user
  postgresql_user: name={{ irods_db_user }} password={{ <PASSWORD> }} db={{ irods_db_name }} priv=ALL encrypted=no state=present
  sudo: true
  sudo_user: postgres

# allow remote user connections

- name: find pg_hba.conf
  command: find / -name pg_hba.conf
  sudo: true
  register: result

- debug: var=result

- name: add line to pg_hba.conf
  lineinfile: 
    dest: "{{ result.stdout_lines[0] }}" 
    line: "host    all    all    192.168.1.0/24    md5"
    state: present

- name: find postgresql.conf
  command: find / -name postgresql.conf
  sudo: true
  register: result

- debug: var=result

- name: add line to postgresql.conf
  lineinfile: 
    dest: "{{ result.stdout_lines[0] }}" 
    line: "listen_addresses = '*'"
    insertbefore: "#listen_addresses = 'localhost'"
    state: present

- name: make sure postgres is restarted
  service: name=postgresql state=restarted
{'fraction_non_alphanumeric': 0.10601577909270217, 'fraction_numerical': 0.0073964497041420114, 'mean_word_length': 3.854066985645933, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '510831', 'n_tokens_mistral': 700, 'n_tokens_neox': 682, 'n_words': 192}