# include\_tasks and noop

**URL:** <https://forum.ansible.com/t/include-tasks-and-noop/36096>\
**Category:** Ansible Project\
**Created:** [December 9, 2021, 11:05pm UTC](https://forum.ansible.com/t/include-tasks-and-noop/36096 "2021-12-09T23:05:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omar](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@Omar](https://forum.ansible.com/u/Omar)\
**Post date:** [December 9, 2021, 11:05pm UTC](https://forum.ansible.com/t/include-tasks-and-noop/36096/1 "2021-12-09T23:05:10Z")

</div>

This is potential feature idea.

I’m developing a small collection and as an extension points I expose various variable that refer to ‘task files’. For example, I have a role named prepare with a task file named `_yum.yml` and I have a variable `repositories_tasks` with a default value `_yum.yml`.

Users can override the variable `repositories_tasks` and provide their own tasks file. Or they could disable it entirely by providing an empty tasks file(maybe with a debug task).  
`repositories_tasks: noop.yml`

Another case is for ‘hooks’ to run tasks at various phases in a role’s execution. For example a `pre_upgrade_hook` or a `pre_restart hook` and have them undefined or set to `None` or an empty string. Sample code:

```auto

- include_tasks: "{{ pre_kubelet_upgrade_hook }}"
when: pre_kubelet_upgrade_hook is defined and (not pre_kubelet_upgrade_hook is none) and (pre_kubelet_upgrade_hook | trim != '')

```

After seeing this pattern I thought that this could br a lot simpler(from a user perspective). Suppose we have a special value that when it appears as a value in `include_tasks` nothing happens. I will use `ansible_noop` as the special value. the following:

- include\_tasks: ansible\_noop  
simply does nothing.

When I user wants to disable a set tasks exposed through a variable, they can assign it to `ansible_noop`, and as a default value for all hook variables you can assign them to `ansible_noop`.

Sample code for role author:  
`defaults/main.yml`

pre\_kubelet\_upgrade\_hook: ansible\_noop

update\_kube\_tasks: \_update\_kube.yml  
copy\_config\_tasks: \_copy\_config.yml

Sample code for role clients:  
include\_role:  
name: upgrade  
vars:  
pre\_kubelet\_upgrade\_hook: cri\_upgrade.yml # File supplied by user  
update\_kube\_tasks: update\_kube.yml

copy\_config\_tasks: ansible\_noop

What do you think?

---

<div class="post-metadata">

**Author:** ![flowerysong1](https://avatars.discourse-cdn.com/v4/letter/f/ecae2f/32.png) [@flowerysong1](https://forum.ansible.com/u/flowerysong1)\
**Post date:** [December 10, 2021, 1:06am UTC](https://forum.ansible.com/t/include-tasks-and-noop/36096/2 "2021-12-10T01:06:22Z")

</div>

I don’t see any benefit to the proposed feature. If you want to skip an include based on a flag value, you can do that without adding complexity to the engine.

- include\_tasks: “{{ task\_file }}.yml”  
when: task\_file | default(‘noop’) != ‘noop’
