Skip to content

Commit

Permalink
Merge branch 'pote-postgres_extensions'
Browse files Browse the repository at this point in the history
* pote-postgres_extensions:
  Install extra postgres extensions
  • Loading branch information
pjan committed Jan 28, 2015
2 parents cb82d0a + 8b8c94d commit f0ad7e4
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions tasks/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
- name: PostgreSQL | Add hstore to the databases with the requirement
sudo: yes
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS hstore;'"
with_items: postgresql_databases
when: item.hstore is defined and item.hstore

- name: PostgreSQL | Add uuid-ossp to the database with the requirement
sudo: yes
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
with_items: postgresql_databases
register: uuid_ext_result
failed_when: uuid_ext_result.rc != 0 and ("already exists, skipping" not in uuid_ext_result.stderr)
Expand All @@ -40,7 +40,28 @@

- name: PostgreSQL | Add postgis to the databases with the requirement
sudo: yes
sudo_user: "{{postgresql_admin_user}}"
shell: "psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'"
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS postgis;'&&psql {{item.name}} -c 'CREATE EXTENSION IF NOT EXISTS postgis_topology;'"
with_items: postgresql_databases
when: item.gis is defined and item.gis

- name: postgresql | add cube to the database with the requirement
sudo: yes
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists cube;'"
with_items: postgresql_databases
when: item.cube is defined and item.cube

- name: PostgreSQL | Add plpgsql to the database with the requirement
sudo: yes
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'CREATE EXTENSION IF NOT EXISTS plpgsql;'"
with_items: postgresql_databases
when: item.plpgsql is defined and item.plpgsql

- name: postgresql | add earthdistance to the database with the requirement
sudo: yes
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} --username {{ postgresql_admin_user }} -c 'create extension if not exists earthdistance;'"
with_items: postgresql_databases
when: item.earthdistance is defined and item.earthdistance

0 comments on commit f0ad7e4

Please sign in to comment.