3

Help with advice please!

There is a program located in the path:

C:\Program Files(x86)\Common Files\Autodesk Shared\AdskLicensing\Current\helper\AdskLicensingInstHelper.exe

And it must be run with the parameters:

register -pk 829L1 -pv 2020.0.0.F -cf "\\ srv\deploy$\RVT20\Img\x64\RVT\RevitConfig.pit" -el EN

I decided to do it through the task scheduler, but did not find in the documentation how to start the task immediately after it was added.

- 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

The task is being added, but how to start it immediately after adding it?

It may of course be easier to run .exe via win_command or raw but it doesn't work for me ...

seshadri_c
  • 6,906
  • 2
  • 10
  • 24
Michail S
  • 81
  • 1
  • 5

1 Answers1

5

solved it myself .. it works. task is added, immediately executed, and removed

 - 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 
Michail S
  • 81
  • 1
  • 5
  • Thanks for this! I just wanted to say that the code as presented needs a slight tweak to work: in the `win_scheduled_task_stat:` section, only `name:` should be indented. `register:`, `until:`, `retries:` and `delay:` should be dedented (to be at the same level as `win_scheduled_task_stat:` and `tags:`), otherwise Ansible will complain. – wickedchicken Feb 18 '22 at 15:07