From cefba149a3b5ccc7b0fc24cd9a4dd82114b2d2d8 Mon Sep 17 00:00:00 2001 From: Ted Cook Date: Sat, 30 Mar 2024 20:51:28 -0600 Subject: [PATCH] Fix version lock tests --- defaults/main/package.yml | 1 + molecule/hold/converge.yml | 2 +- molecule/hold/verify.yml | 14 ++++++++++++++ tasks/install.yml | 16 ++++++++++++++-- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/defaults/main/package.yml b/defaults/main/package.yml index a4ea105..b5d4680 100644 --- a/defaults/main/package.yml +++ b/defaults/main/package.yml @@ -7,6 +7,7 @@ __postgresql_os_search: - "default" __postgresql_package_extra: redhat: + - "python3-dnf-plugin-versionlock" - "pgaudit_{{ postgresql_release }}" - "pg_cron_{{ postgresql_release }}" - "glibc-langpack-{{ postgresql_locale | regex_replace('_.*', '') }}" diff --git a/molecule/hold/converge.yml b/molecule/hold/converge.yml index 8539288..30b71f8 100644 --- a/molecule/hold/converge.yml +++ b/molecule/hold/converge.yml @@ -70,7 +70,7 @@ _arch: "{{ _target[0].split('.')[1] }}" _name: "{{ _target[0].split('.')[0] }}" _version: "{{ _target[1] }}" - _package: "{{ _name }}-{{ _version }}.{{ _arch }}" + _package: "{{ _name }}={{ _version }}.{{ _arch }}" loop_control: label: "{{ item.item }}" loop: "{{ _postgresql_package_query }}" diff --git a/molecule/hold/verify.yml b/molecule/hold/verify.yml index 496c4da..f74ccc4 100644 --- a/molecule/hold/verify.yml +++ b/molecule/hold/verify.yml @@ -106,3 +106,17 @@ _installed: "{{ (packages[_package] | default([{'version': 'None'}]))[0].version }}" loop: "{{ _postgresql_package_name | zip(postgresql_package_list) }}" when: ansible_os_family == "RedHat" + + - name: Verify apt package locks + ansible.builtin.command: + cmd: "apt-mark showhold | grep {{ item }}" + loop: "{{ _postgresql_package_name }}" + when: ansible_os_family == "Debian" + changed_when: false + + - name: Verify yum package locks + ansible.builtin.command: + cmd: "grep {{ item }} /etc/yum/pluginconf.d/versionlock.list" + loop: "{{ _postgresql_package_name }}" + when: ansible_os_family == "RedHat" + changed_when: false diff --git a/tasks/install.yml b/tasks/install.yml index 83096a7..cd28fae 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -38,13 +38,25 @@ - name: Install packages and configure package holds block: - - name: Install PostgreSQL server packages + - name: Install PostgreSQL deb server packages ansible.builtin.package: - name: "{{ _server + _extra }}" + name: "{{ _packages }}" state: "{{ postgresql_package_state }}" vars: _server: "{{ [_postgresql_package_name] | flatten }}" _extra: "{{ [_postgresql_package_extra] | flatten }}" + _packages: "{{ _server + _extra }}" + when: ansible_os_family == 'Debian' + + - name: Install PostgreSQL yum server packages + ansible.builtin.package: + name: "{{ _packages | regex_replace('=', '-') }}" + state: "{{ postgresql_package_state }}" + vars: + _server: "{{ [_postgresql_package_name] | flatten }}" + _extra: "{{ [_postgresql_package_extra] | flatten }}" + _packages: "{{ _server + _extra }}" + when: ansible_os_family == 'RedHat' always: - name: Configure package holds