Skip to content

Conversation

@rpluem-vf
Copy link
Contributor

Add the possibility to turn on Ansible diff mode by the new input parameter diff_mode.
There will be further PR's following to https://github.com/theforeman/foreman-ansible-modules and https://github.com/theforeman/foreman_ansible to enable this on the Foreman server and make use of it in the configuration reports.

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

At first glance this looks good, waiting for the followup PRs in related repos.

@rpluem-vf
Copy link
Contributor Author

Next PR is theforeman/foreman-ansible-modules#1816

@rpluem-vf
Copy link
Contributor Author

@rpluem-vf
Copy link
Contributor Author

Any update?

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I wonder if it makes sense to expose this as a capability. In https://theforeman.org/2019/04/smart-proxy-capabilities-explained.html I showed how that can be done. Then on the Foreman side you can know if the Smart Proxy supports diff mode and can error out if it was requested, but not supported. Or at least show a warning.

@rex_command = action_input[:remote_execution_command]
@check_mode = action_input[:check_mode]
@job_check_mode = action_input[:job_check_mode]
@diff_mode = action_input[:diff_mode]
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the naming: #100 chose job_diff_mode. For check_mode there's both check_mode and job_check_mode. d67b3d2 added that.

Should we support both too here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but this would require changes to theforeman/foreman_ansible#749 as well similar to theforeman/foreman_ansible@76a53e3 I guess. Let me know what you prefer.

Copy link
Contributor Author

@rpluem-vf rpluem-vf Jun 23, 2025

Choose a reason for hiding this comment

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

We could, but this would require changes to theforeman/foreman_ansible#749 as well similar to theforeman/foreman_ansible@76a53e3 I guess. Let me know what you prefer.

Looking at theforeman/foreman_ansible#764 and #100 I think no changes are needed here and we just need to merge these and mine. There are some text conflicts but these should be easy to fix in a rebase of whatever PR is merged later.

Copy link
Member

Choose a reason for hiding this comment

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

@bnerickson has submitted theforeman/foreman_ansible#764. I wouldn't mind merging this PR together with your foreman_ansible PR. @bnerickson would you be OK to rebase your work on top of this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no problem rebasing my work on top of this PR.

@ekohl
Copy link
Member

ekohl commented Jun 21, 2025

I wonder if it makes sense to expose this as a capability. In https://theforeman.org/2019/04/smart-proxy-capabilities-explained.html I showed how that can be done. Then on the Foreman side you can know if the Smart Proxy supports diff mode and can error out if it was requested, but not supported. Or at least show a warning.

I looked at https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_checkmode.html and I wonder how bad it is if the Smart Proxy doesn't support diff mode. It may be frustrating, but I don't think it would cause harm (unlike if check mode). So perhaps this is all not needed.

@rpluem-vf
Copy link
Contributor Author

I wonder if it makes sense to expose this as a capability. In https://theforeman.org/2019/04/smart-proxy-capabilities-explained.html I showed how that can be done. Then on the Foreman side you can know if the Smart Proxy supports diff mode and can error out if it was requested, but not supported. Or at least show a warning.

I looked at https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_checkmode.html and I wonder how bad it is if the Smart Proxy doesn't support diff mode. It may be frustrating, but I don't think it would cause harm (unlike if check mode). So perhaps this is all not needed.

If you have a Foreman with theforeman/foreman_ansible#749 and a smart proxy without this PR it has no further impact but that the diffs are not displayed for Ansible jobs that have been executed by that smart proxy. As you state, it is just frustrating, but it does not cause harm.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

👍 on the code, but could you rebase this and squash it into a single PR? We also require a Redmine issue. https://projects.theforeman.org/projects/ansible/issues/new can be used to create one.

@rpluem-vf
Copy link
Contributor Author

Add the possibility to turn on Ansible diff mode by the new input parameter
diff_mode.

Signed-off-by: Ruediger Pluem <[email protected]>

Update lib/smart_proxy_ansible/runner/ansible_runner.rb

Co-authored-by: Adam Růžička <[email protected]>
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I approved the CI run. Perhaps @adamruzicka wants to weigh in too, otherwise I'll merge this soon

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

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

This looks reasonable

@ekohl ekohl merged commit 962e2f6 into theforeman:master Jun 24, 2025
11 checks passed
@rpluem-vf rpluem-vf deleted the diff_mode branch June 24, 2025 14:21
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.

4 participants