Skip to content

Commit

Permalink
Changed the PostgreSQL version in integration tests from 14 to 15 for…
Browse files Browse the repository at this point in the history
… Ubuntu 20.04 (#452)

Co-authored-by: aleksvagachev <aleksvagachev@yandex.ru>
  • Loading branch information
aleksvagachev and aleksvagachev authored Apr 20, 2023
1 parent bbb3257 commit 63026e7
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
become_user: "{{ pg_user }}"
postgresql_db:
state: present
name: "{{ suspicious_db_name }}"
name: "{{ db_name_with_dot }}"
owner: "{{ db_user1 }}"
login_user: "{{ pg_user }}"
trust_input: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@
that:
- result is changed

# Grant rights to the public schema, since in PostgreSQL 15
# the rights to this schema are taken away from all users except the owner
- name: GRANT ALL PRIVILEGES ON SCHEMA public TO ansible_db_user1,2,3
community.postgresql.postgresql_privs:
db: "{{ db_name }}"
privs: ALL
type: schema
objs: public
role: "{{ item }}"
loop:
- "{{ db_user2 }}"
- "{{ db_user3 }}"

# Also covers https://github.com/ansible-collections/community.general/issues/884
- name: Set table default privs on the schema with hyphen in the name
postgresql_privs:
Expand Down Expand Up @@ -1719,7 +1732,10 @@
become_user: "{{ pg_user }}"
postgresql_query:
login_db: "{{ db_name }}"
query: "DROP OWNED BY {{ db_user3 }};"
query: "DROP OWNED BY {{ item }};"
loop:
- "{{ db_user2 }}"
- "{{ db_user3 }}"

- name: Remove user given permissions
become: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
maintenance_work_mem: 32mb
effective_cache_size: 1024kB
shared_buffers: 1GB
stats_temp_directory: pg_stat_tmp
wal_level: replica
log_statement: mod
track_functions: none
Expand Down
61 changes: 36 additions & 25 deletions tests/integration/targets/setup_postgresql_db/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,45 @@
loop_var: loop_item

#
# Install PostgreSQL 14 on Ubuntu 20.04
- name: Install wget
package:
name: wget
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '20'

- name: Add a repository
shell: echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '20'

- name: Add a repository
shell: wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '20'
# Install PostgreSQL 15 on Ubuntu 20.04
- name: Install PostgreSQL 15 on Ubuntu 20.04
when:
- ansible_facts.distribution == 'Ubuntu'
- ansible_facts.distribution_major_version == '20'
block:
- name: Run autoremove
become: true
apt:
autoremove: true

- name: Install wget
package:
name: wget

- name: Create the file repository configuration
lineinfile:
create: true
line: "deb http://apt.postgresql.org/pub/repos/apt {{ ansible_facts['distribution_release'] }}-pgdg main"
path: '/etc/apt/sources.list.d/pgdg.list'
state: 'present'

- name: Import the repository signing key
ansible.builtin.apt_key:
state: present
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc

- name: Add a repository
shell: apt -y update
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '20'
- name: Update the package lists
apt:
update_cache: true

- name: Install locale needed
shell: 'locale-gen {{ item }}'
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '20'
loop:
- es_ES
- pt_BR
- name: Install locale needed
shell: 'locale-gen {{ item }}'
loop:
- es_ES
- pt_BR

- name: Update locale
shell: 'update-locale'
when: ansible_facts.distribution == 'Ubuntu' and ansible_facts.distribution_major_version == '20'
- name: Update locale
shell: 'update-locale'
##
#

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
postgresql_packages:
- "apt-utils"
- "postgresql-14"
- "postgresql"
- "postgresql-common"
- "python3-psycopg2"
- "postgresql-client"

pg_hba_location: "/etc/postgresql/14/main/pg_hba.conf"
pg_dir: "/var/lib/postgresql/14/main"
pg_hba_location: "/etc/postgresql/15/main/pg_hba.conf"
pg_dir: "/var/lib/postgresql/15/main"
pg_auto_conf: "{{ pg_dir }}/postgresql.auto.conf"
pg_ver: 14
pg_ver: 15

postgis: postgresql-14-postgis-3
postgis: postgresql-15-postgis-3

0 comments on commit 63026e7

Please sign in to comment.