Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Ansibles/postgresql
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/Ansibles/postgresql:
  Corrected user tasks when custom ports are defined
  Corrected database tasks when custom ports are defined
  added install of postgresql-contrib (uuid-ossp ext needs it). added fix so ansible wont incorrectly report the uuid-ossp install as "changed" on each run, despite already being successfully installed
  add postgis scripts package
  postgis extension databases
  • Loading branch information
pjan committed Jan 28, 2015
2 parents 1e8f6fe + c15be7d commit e004386
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tasks/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
encoding: "{{postgresql_encoding}}"
lc_collate: "{{postgresql_locale}}"
lc_ctype: "{{postgresql_locale}}"
port: "{{postgresql_port}}"
template: "template0"
state: present
login_user: "{{postgresql_admin_user}}"
Expand All @@ -32,4 +33,14 @@
sudo_user: "{{ postgresql_service_user }}"
shell: "psql {{item.name}} -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)
changed_when: uuid_ext_result.rc == 0 and ("already exists, skipping" not in uuid_ext_result.stderr)
when: item.uuid_ossp is defined and item.uuid_ossp

- 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;'"
with_items: postgresql_databases
when: item.gis is defined and item.gis
1 change: 1 addition & 0 deletions tasks/extensions/postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
with_items:
- libgeos-c1
- "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}"
- "postgresql-{{postgresql_version}}-postgis-{{postgresql_ext_postgis_version}}-scripts"
notify:
- restart postgresql
1 change: 1 addition & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
with_items:
- "postgresql-{{postgresql_version}}"
- "postgresql-client-{{postgresql_version}}"
- "postgresql-contrib"
2 changes: 2 additions & 0 deletions tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
postgresql_user:
name: "{{item.name}}"
password: "{{item.pass | default('pass')}}"
port: "{{postgresql_port}}"
state: present
login_user: "{{postgresql_admin_user}}"
sudo: yes
Expand All @@ -20,6 +21,7 @@
postgresql_user:
name: "{{item.name}}"
db: "{{item.db}}"
port: "{{postgresql_port}}"
priv: "{{item.priv | default('ALL')}}"
state: present
login_user: "{{postgresql_admin_user}}"
Expand Down

0 comments on commit e004386

Please sign in to comment.