Skip to content

Conversation

@bnerickson
Copy link
Contributor

@bnerickson bnerickson commented Mar 31, 2025

Overview of Changes

This PR adds a separate job_diff_mode variable to the AnsibleRunner class which ultimately sets the --diff flag in the ansible-runner command. This allows Ansible Diff Mode to be set for Jobs when the new ansible_diff_mode checkbox is selected in Ansible Job Templates (see PR theforeman/foreman_ansible#764).

Implementation Consideration

None

Testing Steps

  1. Add the changes in Fixes #38335 - Adding Ansible Diff Mode to Ansible Job Templates foreman_ansible#764 to your test environment.
  2. Add the changes in this PR to your test environment.
  3. Clone the "Ansible Roles - Ansible Default" Job Template.
  4. In the clone's "Ansible" tab, select the "Ansible Diff Mode Enabled" checkbox and save the Job Template.
  5. In the user-defined Ansible Playbook for the test host, add a "copy" task that changes or deploys a text file with dummy content to the test host in the /tmp directory. For examples:
  - name: Deploy test file
    copy:
      src: "/etc/ansible/roles/somefile"
      dest: "/tmp/somefile"
      owner: root
      group: root
      mode: 0644
  1. Schedule a Job for the test host and select the cloned Job Category and Job Template. Execute the job, and verify in the job's "template_invocation" page that the dummy contents of the file are displayed when the file is changed/deployed.

Checklists

  • I am familiar with the contributing guidelines.
  • I have added relevant tests for my changes.
  • I have updated the documentation accordingly.

Additional Notes

This PR is dependent on:

@bnerickson
Copy link
Contributor Author

It looks like the changes here conflict somewhat with the proposed changes in #98. I don't mind waiting for that PR to be approved/merged first and then merging those changes into this PR when the time comes.

@ekohl ekohl mentioned this pull request Jun 21, 2025
@ekohl
Copy link
Member

ekohl commented Jun 21, 2025

I started a review of #98 and I think most comments also apply here.

@bnerickson
Copy link
Contributor Author

bnerickson commented Jun 24, 2025

Rebased after changes merged in #98

I also added a missing statement in test/fixtures/action_input.json for "diff_mode": "false",.

@bnerickson
Copy link
Contributor Author

Hi @nofaralfasi , I see this PR is approved. Is there anything pending before this PR may be merged?

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.

3 participants