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

awx.awx.schedule: Do not fail if state is absent and unified_job_template does not exist #15220

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

Conversation

jedla01
Copy link

@jedla01 jedla01 commented May 23, 2024

SUMMARY

Module managing schedules does is not idempotent in case unified_job_template is provided and such unified_job_template does not exist and so schedule does not exist anymore. Module should still provide OK.

This is affecting mainly configuration as code, when switching object with state to absent. It is then not consistent to have one playbook managing creation and removal at same time.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Collection - awx.awx.schedule
AWX VERSION
24.4.0
ADDITIONAL INFORMATION

Using following example for configuration as code using dispatch within infra.controller_configuration is gonna deploy it.

controller_templates:
  - name: foobar_jobtemplate
     playbook: dummy_playbook
     organization: org
     state: present
controller_schedules:
  - name: foobar_schedule
    rrule: "{{ query('awx.awx.schedule_rrule',
      'day',
      start_date='2023-01-01 03:33:00',
      timezone='America/New_York')
      }}"
    unified_job_template: foobar_jobtemplate
    organization: org
    enabled: true
    state: present

Simple changing state to absent, keeping the rest of the values intact will make it fail on schedules as job templates are removed first and schedule still refer to non-existing unified_job_template.

Error:

plugins/modules/schedule.py\", line 279, in main", "TypeError: argument of type 'NoneType' is not iterable

With proposed update it manages both states successfully (present and absent).

@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX community labels May 23, 2024
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.

None yet

1 participant