Skip to content
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

Make it work with check_mode #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

diraol
Copy link
Contributor

@diraol diraol commented Jun 13, 2022

Ok, even with the small fix I proposed in #38, it was still not working in check_mode (because a bunch of reasons).

So this PR aims to make it work also with in --check (check mode). I had to set a small "hack" to make it work because neither command not shell effectively run in check_mode, so we couldn't get the current version result from them (using dpkg shell command).

Comment on lines 39 to +47
- name: Get installed version
command: dpkg-query -f ${Version;3} --show postgresql
shell: "dpkg-query -f '${Version;3}' --show postgresql"
when: postgresql_version is not defined
register: __postgresql_version_query_result
changed_when: false
check_mode: no
args:
# Using this in order to enforce the task to be executed in check mode
removes: "{{ __temp_file_for_check_mode }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we're shelling out to dpkg-query anyway, could we use something like the package facts module instead that might be natively check-safe? @natefoo ?

Copy link
Contributor Author

@diraol diraol Jun 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is ok even though it has the following requirements?

REQUIREMENTS

The below requirements are needed on the host that executes this module.

For ‘portage’ support it requires the qlist utility, which is part of ‘app-portage/portage-utils’.

For Debian-based systems python-apt package must be installed on targeted hosts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's not ideal.

Copy link
Contributor Author

@diraol diraol Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought so....

So should we move with this PR? Or any other suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants