8000 AAP-101726: Tolerate missing unified_job_template on schedule state=absent by arvind-sme · Pull Request #16819 · ansible/awx · GitHub
[go: up one dir, main page]

Skip to content

AAP-101726: Tolerate missing unified_job_template on schedule state=absent - #16819

Open
arvind-sme wants to merge 1 commit into
ansible:develfrom
arvind-sme:AAP-101726-schedule-absent-missing-ujt
Open

arvind-sme wants to merge 1 commit into
ansible:develfrom
arvind-sme:AAP-101726-schedule-absent-missing-ujt

Conversation

@arvind-sme
@arvind-sme arvind-sme commented Nov 26, 2026 •
Copy link
Copy Markdown
SUMMARY

Fix awx.awx.schedule (downstream ansible.controller.schedule) so state: absent is idempotent when the targeted unified_job_template no longer exists.

Previously the module always resolved the UJT via get_one(...)['id'] before handling state: absent. When the template was already gone (common in CasC cleanup after JT deletion), get_one returned None and the module crashed with 'NoneType' object is not subscriptable.

This matches the AAP-80457 / credential_input_source pattern: use allow_none=(state == 'absent'), and if the UJT is missing on absent, exit_json(changed=False). state: present still fails when the UJT is missing (allow_none=False).

Related: AAP-101726

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Collection
STEPS TO REPRODUCE AND EXTRA INFO
  • Ensure no job template named Nonexistent Example JT exists.
  • Run:
---
- name: Test schedule absent on missing unified job template
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - name: Remove schedule when job template is already gone
      awx.awx.schedule:
        name: Example Nightly Schedule
        unified_job_template: Nonexistent Example JT
        state: absent
        controller_host: "{{ controller_host }}"
        controller_oauthtoken: "{{ controller_oauthtoken }}"
        validate_certs: false

Before:

fatal: [localhost]: FAILED! =>
    changed: false
    msg: 'Task failed: Module failed: ''NoneType'' object is not subscriptable'

After:

ok: [localhost] =>
    changed: false

PLAY RECAP
localhost                  : ok=1    changed=0    failed=0

Unit tests added: test_schedule_delete_missing_unified_job_template, test_schedule_create_missing_unified_job_template.

Summary by CodeRabbit

  • Bug Fixes
    • Schedule removal requests now succeed without changes when the referenced job template is missing. Requests to create a schedule still fail if the template does not exist.

…bsent

Match credential_input_source (AAP-80457): when state is absent and the
unified job template no longer exists, exit changed=false instead of
failing on None['id']. Keep present-state lookups strict.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the component:awx_collection issues related to the collection for controlling AWX label Nov 26, 2026
@coderabbitai
coderabbitai Bot commented Nov 26, 2026 •
Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Walkthrough

The schedule module now allows a missing unified job template when state is absent. It returns changed: False in that case. Tests verify that state=present still fails when the template is missing.

Changes: Missing unified job template handling

Layer / File(s) Summary
State-dependent lookup and validation
awx_collection/plugins/modules/schedule.py, awx_collection/test/awx/test_schedule.py
The module allows the template lookup to return no result when state=absent and exits unchanged. Tests verify this behavior and confirm that state=present fails without creating schedules.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: sean-m-sullivan

Merge Risk: Minimal · up to 7adda

Deleting a schedule whose job template has already been removed now succeeds without changes instead of failing. Creating a schedule with a missing template still fails. The change is small, tested, and low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the schedule module now tolerates a missing unified_job_template when state is absent. The raw summary confirms the lookup change in schedule.py and the added absent/p…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the schedule module now tolerates a missing unified_job_template when state is absent. The raw summary confirms the lookup change in schedule.py and the added absent/present tests. The title is specific and matches the changeset. The AAP-101726 ticket prefix is a tracker reference and does not reduce clarity.

Warning

Some tools did not complete. Review the errors below.

Ruff (0.17.4)

awx_collection/plugins/modules/schedule.py

ruff failed
Cause: Required version ~=0.16.0 does not match the running version 0.17.4

awx_collection/test/awx/test_schedule.py

ruff failed
Cause: Required version ~=0.16.0 does not match the running version 0.17.4

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0fd6a09d-49a0-4b0b-8a76-6c68f4fff271
Commits

Reviewing files that changed from the base of the PR and between 0717600 and 7addad0.

Files selected for processing: 2

  • awx_collection/plugins/modules/schedule.py
  • awx_collection/test/awx/test_schedule.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community component:awx_collection issues related to the collection for controlling AWX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0