# Is it possible to defer action resolution to run time?

**URL:** <https://forum.ansible.com/t/is-it-possible-to-defer-action-resolution-to-run-time/8469>\
**Category:** Get Help\
**Tags:** windows, role\
**Created:** [September 12, 2024, 3:55pm UTC](https://forum.ansible.com/t/is-it-possible-to-defer-action-resolution-to-run-time/8469 "2024-09-12T15:55:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![opoplawski](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/opoplawski/32/2112_2.png) [@opoplawski](https://forum.ansible.com/u/opoplawski)\
**Post date:** [September 12, 2024, 3:55pm UTC](https://forum.ansible.com/t/is-it-possible-to-defer-action-resolution-to-run-time/8469/1 "2024-09-12T15:55:36Z")

</div>

I have a role that can be run against both WIndows and Linux hosts. It has a handler for restarting a service on windows using `win_service`. This is breaking ansible-pull for us:

```auto
ansible-pull[7939]: ERROR! couldn't resolve module/action 'win_service'. This often indicates a misspelling, missing collection, or incorrect module path.
ansible-pull[7939]: The error appears to be in 'roles/ups/handlers/main.yml': line 11, column 3, but may
Sep 12 09:16:51 ansible-pull[7939]: be elsewhere in the file depending on the exact syntax problem.
Sep 12 09:16:51 ansible-pull[7939]: The offending line appears to be:
Sep 12 09:16:51 ansible-pull[7939]: become: yes
Sep 12 09:16:51 ansible-pull[7939]: - name: "windows restart nut service"
Sep 12 09:16:51 ansible-pull[7939]: ^ here

```

because we do not install the ansible windows collection on the Linux hosts, and I would prefer not to. Is there any way I can avoid the need to resolve the win\_service action on the Linux hosts?

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [September 12, 2024, 4:29pm UTC](https://forum.ansible.com/t/is-it-possible-to-defer-action-resolution-to-run-time/8469/2 "2024-09-12T16:29:15Z")

</div>

Yes. I don’t feel like reformatting it for the forum since I just answered this in IRC, but the two approaches that immediately come to mind are to use the old `action:` syntax, or make the handler an `include_tasks:` task.

[0\_test.yml · GitHub](https://gist.github.com/flowerysong/872773006d452246f2f800d4290d9f9c) and  
[handler\_include.md · GitHub](https://gist.github.com/flowerysong/3ecb2ffd9681bf0bdd6d2144bec13b30)

---

<div class="post-metadata">

**Author:** ![opoplawski](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/opoplawski/32/2112_2.png) [@opoplawski](https://forum.ansible.com/u/opoplawski)\
**Post date:** [September 12, 2024, 5:12pm UTC](https://forum.ansible.com/t/is-it-possible-to-defer-action-resolution-to-run-time/8469/3 "2024-09-12T17:12:40Z")

</div>

I went with `action:` and that worked nicely. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 12, 2024, 5:12pm UTC](https://forum.ansible.com/t/is-it-possible-to-defer-action-resolution-to-run-time/8469/4 "2024-10-12T17:12:55Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
