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

[Bug] agent_job_schedule does not change when set to enabled: true #272

Open
da-access-group opened this issue Oct 31, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@da-access-group
Copy link

da-access-group commented Oct 31, 2024

Describe the bug
I've recently deploy an agent_job_schedule without the enabled property, by default this appears to create a schedule that isn't enabled. I have since updated my Ansible configuration to add "enabled: true" to the agent_job_schedule task but this does not cause the schedule to be changed.

To Reproduce
Create an agent_job and agent_job_schedule

    - name: Create a job 
      lowlydba.sqlserver.agent_job:
        sql_instance: [REDACTED]
        job: MyJob
        force: true

    - name: Create a job schedule
      lowlydba.sqlserver.agent_job_schedule:
        sql_instance: [REDACTED]
        schedule: DailySchedule
        force: true
        start_date: '20200525'
        end_date: '20990525'
        start_time: '010500'
        end_time: '140030'
        state: present
        job: 'MyJob'

Modify the agent_job_schedule to add the enabled property and set this to true

    - name: Create a job schedule
      lowlydba.sqlserver.agent_job_schedule:
        sql_instance: [REDACTED]
        schedule: DailySchedule
        force: true
        enabled: true
        start_date: '20200525'
        end_date: '20990525'
        start_time: '010500'
        end_time: '140030'
        state: present
        job: 'MyJob'

Ansible returns with no changes:

{
  "changed": false,
  "invocation": {
    "module_args": {
      "end_time": "140030",
      "sql_instance": "[REDACTED]",
      "frequency_relative_interval": null,
      "frequency_subday_interval": null,
      "frequency_subday_type": null,
      "start_date": "20200525",
      "frequency_type": null,
      "state": "present",
      "frequency_interval": null,
      "job": "MyJob",
      "start_time": "010500",
      "sql_username": null,
      "sql_password": null,
      "schedule": "DailySchedule",
      "enabled": true,
      "force": true,
      "frequency_recurrence_factor": null,
      "end_date": "20990525"
    }
  },
  "data": {
    "ComputerName": "[REDACTED]",
    "InstanceName": "MSSQLSERVER",
    "SqlInstance": "[REDACTED]",
    "Description": "Occurs on 5/25/2020 at 1:05:00 AMat 1:05:00 AM. Schedule will used between 5/25/2020 and 5/25/2099.",
    "ScheduleName": "DailySchedule",
    "ScheduleUid": "29214802-8617-432f-acca-5064c67cb5a4",
    "ActiveEndDate": "2099-05-25T00:00:00.0000000",
    "ActiveEndTimeOfDay": {
      "Ticks": 504300000000,
      "Days": 0,
      "Hours": 14,
      "Milliseconds": 0,
      "Minutes": 0,
      "Seconds": 30,
      "TotalDays": 0.5836805555555555,
      "TotalHours": 14.008333333333333,
      "TotalMilliseconds": 50430000,
      "TotalMinutes": 840.5,
      "TotalSeconds": 50430
    },
    "ActiveStartDate": "2020-05-25T00:00:00.0000000",
    "ActiveStartTimeOfDay": {
      "Ticks": 39000000000,
      "Days": 0,
      "Hours": 1,
      "Milliseconds": 0,
      "Minutes": 5,
      "Seconds": 0,
      "TotalDays": 0.04513888888888889,
      "TotalHours": 1.0833333333333333,
      "TotalMilliseconds": 3900000,
      "TotalMinutes": 65,
      "TotalSeconds": 3900
    },
    "DateCreated": "2024-10-31T10:15:41.4530000",
    "FrequencyInterval": 0,
    "FrequencyRecurrenceFactor": 0,
    "FrequencyRelativeIntervals": "0",
    "FrequencySubDayInterval": 0,
    "FrequencySubDayTypes": "Unknown",
    "FrequencyTypes": "OneTime",
    "IsEnabled": false,
    "JobCount": 1
  },
  "_ansible_no_log": false
}

Expected behavior
I would expect Ansible to modify the schedule so it is now enabled.

Versions(please complete the following information):

  • OS: Windows Server 2019 Datacenter
  • SQL Server: 2022 Developer
  • PowerShell: 5.1.17763.6414
  • DBATools: Choco 2.1.26 (choco install dbatools --version=2.1.26)
  • lowlydba.sqlserver: 2.3.4
@da-access-group da-access-group added the bug Something isn't working label Oct 31, 2024
@lowlydba
Copy link
Owner

lowlydba commented Nov 2, 2024

Hi! Thanks for the bug report. I don't have a ton of time right now to dedicate to this project, but bug fix PRs are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants