From 63026e7c59f8f4b97736ec488aea73d6e6adb047 Mon Sep 17 00:00:00 2001 From: Aleks Vagachev <43969425+aleksvagachev@users.noreply.github.com> Date: Thu, 20 Apr 2023 15:35:42 +0300 Subject: [PATCH] Changed the PostgreSQL version in integration tests from 14 to 15 for Ubuntu 20.04 (#452) Co-authored-by: aleksvagachev --- .../tasks/state_dump_restore.yml | 2 +- .../tasks/postgresql_privs_general.yml | 18 +++++- .../postgresql_set/tasks/options_coverage.yml | 1 - .../setup_postgresql_db/tasks/main.yml | 61 +++++++++++-------- .../setup_postgresql_db/vars/Ubuntu-12.yml | 9 --- .../setup_postgresql_db/vars/Ubuntu-14.yml | 9 --- .../vars/Ubuntu-16-py3.yml | 9 --- .../setup_postgresql_db/vars/Ubuntu-16.yml | 9 --- .../vars/Ubuntu-18-py3.yml | 9 --- .../vars/Ubuntu-20-py3.yml | 11 ++-- 10 files changed, 60 insertions(+), 78 deletions(-) delete mode 100644 tests/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml delete mode 100644 tests/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml delete mode 100644 tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml delete mode 100644 tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml delete mode 100644 tests/integration/targets/setup_postgresql_db/vars/Ubuntu-18-py3.yml diff --git a/tests/integration/targets/postgresql_db/tasks/state_dump_restore.yml b/tests/integration/targets/postgresql_db/tasks/state_dump_restore.yml index 0292ca310..dbb3bf7a1 100644 --- a/tests/integration/targets/postgresql_db/tasks/state_dump_restore.yml +++ b/tests/integration/targets/postgresql_db/tasks/state_dump_restore.yml @@ -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 diff --git a/tests/integration/targets/postgresql_privs/tasks/postgresql_privs_general.yml b/tests/integration/targets/postgresql_privs/tasks/postgresql_privs_general.yml index 815fa75a7..834275c11 100644 --- a/tests/integration/targets/postgresql_privs/tasks/postgresql_privs_general.yml +++ b/tests/integration/targets/postgresql_privs/tasks/postgresql_privs_general.yml @@ -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: @@ -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 diff --git a/tests/integration/targets/postgresql_set/tasks/options_coverage.yml b/tests/integration/targets/postgresql_set/tasks/options_coverage.yml index 172ff6aaa..c4598d2a9 100644 --- a/tests/integration/targets/postgresql_set/tasks/options_coverage.yml +++ b/tests/integration/targets/postgresql_set/tasks/options_coverage.yml @@ -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 diff --git a/tests/integration/targets/setup_postgresql_db/tasks/main.yml b/tests/integration/targets/setup_postgresql_db/tasks/main.yml index c0bc07566..80bb3c4d4 100644 --- a/tests/integration/targets/setup_postgresql_db/tasks/main.yml +++ b/tests/integration/targets/setup_postgresql_db/tasks/main.yml @@ -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' ## # diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml deleted file mode 100644 index e6dd6434c..000000000 --- a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-12.yml +++ /dev/null @@ -1,9 +0,0 @@ -postgresql_packages: - - "postgresql" - - "postgresql-common" - - "python-psycopg2" - -pg_hba_location: "/etc/postgresql/9.1/main/pg_hba.conf" -pg_dir: "/var/lib/postgresql/9.1/main" -pg_auto_conf: "{{ pg_dir }}/postgresql.auto.conf" -pg_ver: 9.1 diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml deleted file mode 100644 index e946f15ee..000000000 --- a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-14.yml +++ /dev/null @@ -1,9 +0,0 @@ -postgresql_packages: - - "postgresql" - - "postgresql-common" - - "python-psycopg2" - -pg_hba_location: "/etc/postgresql/9.3/main/pg_hba.conf" -pg_auto_conf: "/etc/postgresql/9.3/main/postgresql.auto.conf" -pg_dir: "/var/lib/postgresql/9.3/main" -pg_ver: 9.3 diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml deleted file mode 100644 index 85b0accbf..000000000 --- a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16-py3.yml +++ /dev/null @@ -1,9 +0,0 @@ -postgresql_packages: - - "postgresql" - - "postgresql-common" - - "python3-psycopg2" - -pg_hba_location: "/etc/postgresql/9.5/main/pg_hba.conf" -pg_auto_conf: "/etc/postgresql/9.5/main/postgresql.auto.conf" -pg_dir: "/var/lib/postgresql/9.5/main" -pg_ver: 9.5 diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml deleted file mode 100644 index 0176f4cf7..000000000 --- a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-16.yml +++ /dev/null @@ -1,9 +0,0 @@ -postgresql_packages: - - "postgresql" - - "postgresql-common" - - "python-psycopg2" - -pg_hba_location: "/etc/postgresql/9.5/main/pg_hba.conf" -pg_dir: "/var/lib/postgresql/9.5/main" -pg_auto_conf: "{{ pg_dir }}/postgresql.auto.conf" -pg_ver: 9.5 diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-18-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-18-py3.yml deleted file mode 100644 index 1dbc57e6c..000000000 --- a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-18-py3.yml +++ /dev/null @@ -1,9 +0,0 @@ -postgresql_packages: - - "postgresql" - - "postgresql-common" - - "python3-psycopg2" - -pg_hba_location: "/etc/postgresql/10/main/pg_hba.conf" -pg_dir: "/var/lib/postgresql/10/main" -pg_auto_conf: "{{ pg_dir }}/postgresql.auto.conf" -pg_ver: 10 diff --git a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-20-py3.yml b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-20-py3.yml index c1a3269ad..ff543a385 100644 --- a/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-20-py3.yml +++ b/tests/integration/targets/setup_postgresql_db/vars/Ubuntu-20-py3.yml @@ -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