Repository navigation
feat: Honour postgresql_version on SUSE and handle transactional updates #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
78a8ba1
ee37112
f710ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,3 +193,13 @@ argument_specs: | |
| description: > | ||
| Whether to suppress logging of sensitive commands such as | ||
| password changes. Set to `false` for troubleshooting. | ||
| postgresql_transactional_update_reboot_ok: | ||
| type: raw | ||
| default: null | ||
| description: > | ||
| Whether to permit reboots required by transactional updates. Set | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add sentence that this variable is related to managed nodes that have OS with transactional updates. |
||
| to `true` to allow reboots, `false` to disallow reboots, or | ||
| leave unset so that the role will fail to ensure the reboot | ||
| requirement is not overlooked. Accepts a boolean value or `null`. | ||
| Only managed nodes whose OS uses transactional updates read it; | ||
| on other systems it is ignored. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,4 +23,6 @@ galaxy_info: | |
| - fedora | ||
| - leap | ||
| - postgresql | ||
| - sles | ||
| - sles16 | ||
| dependencies: [] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,11 +42,15 @@ | |
| fail: | ||
| msg: >- | ||
| Setting version {{ __postgresql_version }} while | ||
| {{ ansible_facts.packages['postgresql'][0].version }} is installed | ||
| {{ __installed_versions | join(', ') }} is installed | ||
| when: | ||
| - "'postgresql' in ansible_facts.packages" | ||
| - ansible_facts.packages["postgresql"][0].version | | ||
| regex_search('([0-9]*).', '\\1') | first != __postgresql_version | string | ||
| - __installed_versions | length > 0 | ||
| - __installed_versions != [__postgresql_version | string] | ||
| vars: | ||
| __installed_versions: "{{ ansible_facts.packages | dict2items | | ||
| selectattr('key', 'match', __postgresql_version_packages) | | ||
| map(attribute='value') | flatten | map(attribute='version') | | ||
| map('regex_search', '^([0-9]+)', '\\1') | map('first') | unique | list }}" | ||
|
Comment on lines
+50
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Read the SUSE major version from the server package name. On the SLE 15 SP7 case described in the PR context, 🤖 Prompt for AI Agents |
||
|
|
||
| # rpm ostree pkg mgr cannot handle @groups/modules | ||
| # so just assume the packages are present | ||
|
|
@@ -62,6 +66,42 @@ | |
| (__postgresql_is_ostree | d(false)) | | ||
| ternary(__postgresql_packages | reject('match', '^@'), | ||
| __postgresql_packages) | list }}" | ||
| register: __postgresql_package_result | ||
|
|
||
| # A staged install reports ok on re-runs, so ask rpm (by provides) if it is live. | ||
| - name: Check whether the packages are live on a transactional update system | ||
| command: # noqa command-instead-of-module | ||
| argv: "{{ ['rpm', '-q', '--whatprovides'] + __postgresql_packages }}" | ||
|
richm marked this conversation as resolved.
Resolved
|
||
| register: __postgresql_packages_live | ||
| changed_when: false | ||
| failed_when: false | ||
| check_mode: false | ||
| when: __postgresql_is_transactional | ||
|
|
||
| - name: Handle reboot for transactional update systems | ||
| when: | ||
| - __postgresql_is_transactional | ||
| - __postgresql_package_result is changed or | ||
| (__postgresql_packages_live.rc | d(0)) != 0 | ||
| block: | ||
| - name: Notify user that reboot is needed to apply changes | ||
| debug: | ||
| msg: > | ||
| Reboot required to apply changes due to transactional updates. | ||
|
Comment on lines
+87
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift Stop role execution when a staged package is not live and reboot is declined. If installation stages a new server package and 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Reboot transactional update systems | ||
| reboot: | ||
| msg: Rebooting the system to apply transactional update changes. | ||
| when: | ||
| - postgresql_transactional_update_reboot_ok is not none | ||
| - postgresql_transactional_update_reboot_ok | bool | ||
|
|
||
| - name: Fail if reboot is needed and not set | ||
| fail: | ||
| msg: > | ||
| Reboot is required but not allowed. Please set 'postgresql_transactional_update_reboot_ok' to proceed. | ||
| when: | ||
| - postgresql_transactional_update_reboot_ok is none | ||
|
|
||
| - name: Init DB on booted systems (with postgresql-setup) | ||
| when: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a usage example for the reboot option.
Show how to set
postgresql_transactional_update_reboot_ok, for example in a short playbook variable block. As per path instructions, README.md must “Include usage examples for new functionality.”🤖 Prompt for AI Agents
Source: Path instructions