<commit_before>---
- name: Adding APT repository key
  apt_key: 
    id: "{{ postgresql_apt_key_id }}" 
    url: "https://www.postgresql.org/media/keys/{{ postgresql_apt_key_id}}.asc"

- name: Add PostgreSQL official APT repository
  apt_repository: 
    repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ansible_distribution_release}}-pgdg main"

- name: Install apt packages
  apt: 
    pkg: "{{ item }}"
    state: present
  with_items:
    - "postgresql-{{ postgresql_version }}"
    - python-psycopg2
    - libpq-dev

- name: Add postgis repo
  apt_repository:
    repo: ppa:ubuntugis/ubuntugis-unstable
    state: present

- name: Install postgresql-{{ postgresql_version }}-postgis-{{ postgis_version }}
  apt:
    pkg: postgresql-{{ postgresql_version }}-postgis-{{ postgis_version }}
    state: present

- name: List postgresql extension
  shell: psql -c "SELECT * FROM pg_extension;"
  args:
    executable: /bin/bash
  register: postgresql_plugin_list
  become: yes
  become_user: postgres
  become_method: sudo
  changed_when: False

- name: Enable postgis
  shell: psql -c "CREATE EXTENSION postgis;"
  args:
    executable: /bin/bash
  register: enable_postgis
  become: yes
  become_user: postgres
  become_method: sudo
  failed_when: '"CREATE EXTENSION" not in enable_postgis.stdout'
  changed_when: False
  when:
    - '"postgis" not in postgresql_plugin_list.stdout'
    - postgis_enabled<commit_msg>working on #28<commit_after>---
- name: Adding APT repository key
  apt_key: 
    id: "{{ postgresql_apt_key_id }}" 
    url: "https://www.postgresql.org/media/keys/{{ postgresql_apt_key_id}}.asc"

- name: Add PostgreSQL official APT repository
  apt_repository: 
    repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ansible_distribution_release}}-pgdg main"

- name: Install apt packages
  apt: 
    pkg: "{{ item }}"
    state: present
  with_items:
    - "postgresql-{{ postgresql_version }}"
    - python-psycopg2
    - libpq-dev

- name: Add postgis repo
  apt_repository:
    repo: ppa:ubuntugis/ubuntugis-unstable
    state: present

- name: Install postgresql-{{ postgresql_version }}-postgis-{{ postgis_version }}
  apt:
    pkg: postgresql-{{ postgresql_version }}-postgis-{{ postgis_version }}
    state: present

- name: Create postgis extension
  shell: psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"
  args:
    executable: /bin/bash
  become_user: postgres
  become_method: sudo
{'fraction_non_alphanumeric': 0.11679735864630623, 'fraction_numerical': 0.0016508460586050352, 'mean_word_length': 3.5822306238185253, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2753963', 'n_tokens_mistral': 898, 'n_tokens_neox': 863, 'n_words': 200}