Skip to content

Commit

Permalink
Merge pull request ANXS#307 from sebalix/use_postgresql_ext_for_exten…
Browse files Browse the repository at this point in the history
…sions

Use postgresql ext for extensions
  • Loading branch information
UnderGreen authored Mar 19, 2018
2 parents 7346fdb + a3f45f9 commit 73c77b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tasks/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
when: postgresql_databases|length > 0

- name: PostgreSQL | Add extensions to the databases
shell: "psql {{item.0.db}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS {{ item.1 }};'"
become: yes
become_user: "{{postgresql_service_user}}"
postgresql_ext:
db: "{{ item.0.db }}"
login_user: "{{ postgresql_service_user }}"
port: "{{ postgresql_port }}"
name: "{{ item.1 }}"
with_subelements:
- "{{postgresql_database_extensions}}"
- "{{ postgresql_database_extensions }}"
- extensions
register: result
changed_when: "'NOTICE' not in result.stderr"

- name: PostgreSQL | Add hstore to the databases with the requirement
become: yes
Expand Down
7 changes: 7 additions & 0 deletions tests/docker/group_vars/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ postgresql_ext_install_contrib: true
postgresql_ssl: false
postgresql_pgtune: false
postgresql_ext_install_postgis: false

postgresql_database_extensions:
- db: foobar
extensions:
- adminpack
- pgcrypto
- unaccent

0 comments on commit 73c77b4

Please sign in to comment.