Ansible win_scheduled_task 如何立即启动任务

Mic*_*l S 3 windows autodesk ansible

请帮忙指教!

路径中有一个程序:

C:\Program Files(x86)\Common Files\Autodesk Shared\AdskLicensing\Current\helper\AdskLicensingInstHelper.exe
Run Code Online (Sandbox Code Playgroud)

并且必须使用以下参数运行:

register -pk 829L1 -pv 2020.0.0.F -cf "\\ srv\deploy$\RVT20\Img\x64\RVT\RevitConfig.pit" -el EN
Run Code Online (Sandbox Code Playgroud)

我决定通过任务调度程序来完成,但是在文档中没有找到如何在添加任务后立即启动任务。

- name: recover ADSKLic Service
      win_scheduled_task:
        name: ADSK
        description: RecADSK
        actions:
        - path: 'C:\Program Files(x86)\Common Files\Autodesk Shared\AdskLicensing\Current\helper\AdskLicensingInstHelper.exe'
          arguments: register -pk 829L1 -pv 2020.0.0.F -cf "\\srv\deploy$\RVT20\Img\x64\RVT\RevitConfig.pit" -el EN
        triggers:
        - type: registration
        frequency: once
        state: present
        enabled: yes
        username: SYSTEM
      tags: rev, adsk, task
Run Code Online (Sandbox Code Playgroud)

任务正在添加中,但是添加后如何立即启动呢?

win_command通过or运行 .exe 当然可能更容易,raw 但它对我不起作用......

Mic*_*l S 5

我自己解决了..它有效。任务被添加、立即执行和删除

 - name: recover ADSKLic Service Trough task scheduler
      win_scheduled_task:
        name: ADSK
        username: SYSTEM
        actions:
        - path: 'C:\Program Files (x86)\Common Files\Autodesk Shared\AdskLicensing\Current\helper\AdskLicensingInstHelper.exe'
          arguments: register -pk 829L1 -pv 2020.0.0.F -cf "\\srv\deploy$\RVT20\Img\x64\RVT\RevitConfig.pit" -el EN
       # Remove this action if the task shouldn't be deleted on completion
        - path: cmd.exe
          arguments: /c schtasks.exe /Delete /TN "ADSK" /F
        triggers:
        - type: registration
      tags: task
    - name: Wait for the scheduled task to complete
      win_scheduled_task_stat:
        name: ADSK
        register: task_stat
        until: (task_stat.state is defined and task_stat.state.status != "TASK_STATE_RUNNING") or (task_stat.task_exists == False)
        retries: 7
        delay: 5
      tags: task 
Run Code Online (Sandbox Code Playgroud)