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

community.windows.win_scheduled_task - run_on_last_week_of_month isn't working #414

Closed
derSchweiger opened this issue Jul 8, 2022 · 3 comments · Fixed by #422
Closed

Comments

@derSchweiger
Copy link

SUMMARY

The module "community.windows.win_scheduled_task" isn't behaving correctly if the parameter "run_on_last_week_of_month" has been set to true. This parameter won't get set within the created task of the Windows Task Scheduler.

ISSUE TYPE
  • Bug Report
COMPONENTS
Ansible-4.0.0, Python 3.8
STEPS TO REPRODUCE

Using the following task to create a task inside the Windows Task Scheduler:

  tasks:
    - name: CONFIGURE Windows Update enable Task
      community.windows.win_scheduled_task:
        name: TEST
        version: 1.0
        enabled: yes        
        username: SYSTEM
        logon_type: service_account
        run_level: highest
        state: present
        compatibility: 3
        multiple_instances: 2
        actions:
        - path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
          arguments: .\RunSomeScript.ps1
        triggers:
        - type: monthlydow
          enabled: true
          days_of_week: "Monday"
          weeks_of_month: "2"
          months_of_year: "June"
          run_on_last_week_of_month: true
          start_boundary: '2020-01-01T00:00:00'

The task will get created, but the "last" trigger isn't set to true, regardless which value the "run_on_last_week_of_month" parameter has.
image

The actual result should be: Task runs every second AND last Monday in June.

@derSchweiger
Copy link
Author

@jborean93 do you have any idea why this isn't working?

@jborean93
Copy link
Collaborator

The code is setting weeks_of_month after run_on_last_week_of_month based on the order in

[TASK_TRIGGER_TYPE2]::TASK_TRIGGER_MONTHLYDOW = @{
mandatory = @('start_boundary')
optional = @('days_of_week', 'enabled', 'end_boundary', 'execution_time_limit', 'months_of_year', 'random_delay', 'run_on_last_week_of_month',
'weeks_of_month', 'repetition')
}

If I change the order to have weeks_of_month come before run_on_last_week_of_month then I can see both week 2 and the last week get set in the task trigger.

@jborean93
Copy link
Collaborator

The PR #422 includes the changes I mentioned.

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 a pull request may close this issue.

2 participants