# Make it possible to set tasks\_from to None in include\_role

**URL:** <https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119>\
**Category:** Ansible Developer\
**Created:** [March 31, 2017, 11:24pm UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119 "2017-03-31T23:24:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oyvind\_Saltvik](https://avatars.discourse-cdn.com/v4/letter/o/8491ac/32.png) [@Oyvind\_Saltvik](https://forum.ansible.com/u/Oyvind_Saltvik)\
**Post date:** [March 31, 2017, 11:24pm UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/1 "2017-03-31T23:24:21Z")

</div>

If you want to just include defaults, vars and handlers it would be nice to be able to not run any of the roles tasks.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 3, 2017, 1:59pm UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/2 "2017-04-03T13:59:18Z")

</div>

I would not do this in include\_role, this makes more sense in roles:  
declaration (as a resource).

---

<div class="post-metadata">

**Author:** ![Oyvind\_Saltvik](https://avatars.discourse-cdn.com/v4/letter/o/8491ac/32.png) [@Oyvind\_Saltvik](https://forum.ansible.com/u/Oyvind_Saltvik)\
**Post date:** [April 3, 2017, 3:44pm UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/3 "2017-04-03T15:44:16Z")

</div>

I dont quite get what you mean by as a resource.

I was thinking like this:

hosts: ahost  
become: true  
tasks:

- name: get defaults  
include\_role:  
name: geerlingguy.certbot  
tasks\_from: none # no tasks just defaults and handlers
- debug:  
msg: “This task requires {{ a\_default\_var\_from\_certbot }}”

How would you suggest how it should be done?

---

<div class="post-metadata">

**Author:** ![Oyvind\_Saltvik](https://avatars.discourse-cdn.com/v4/letter/o/8491ac/32.png) [@Oyvind\_Saltvik](https://forum.ansible.com/u/Oyvind_Saltvik)\
**Post date:** [April 3, 2017, 4:04pm UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/4 "2017-04-03T16:04:56Z")

</div>

Or something like a lookup:

- name: include\_defaults from role  
include\_vars:  
dir: “{{ lookup(‘role\_dir’, ‘geerlingguy.certbot dir=defaults’ ) }}”

---

<div class="post-metadata">

**Author:** ![Scott\_Mcdermott](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@Scott\_Mcdermott](https://forum.ansible.com/u/Scott_Mcdermott)\
**Post date:** [April 4, 2017, 2:32am UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/5 "2017-04-04T02:32:32Z")

</div>

> \> I would not do this in include\_role, this makes more sense in  
> \> roles: declaration (as a resource).
> 
> I dont quite get what you mean by as a resource.

perhaps meaning, roles as a kind of resource container, to bring  
in variables and things, rather than something executed. there's  
a discussion of what to call it here:  
[https://github.com/ansible/proposals/pull/4](https://github.com/ansible/proposals/pull/4)

I didn't realize there was a difference between declaring something  
in "roles:" and as an "include\_role:" besides just when it was run.  
Based on these comments, it seems that "include\_role" is intended  
more for "executing" roles i.e. running tasks/main.yml whereas  
appearance in "roles" is intended for importing "resources" ?

> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: get defaults  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include\_role:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: geerlingguy.certbot  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tasks\_from: none # no tasks just defaults and handlers  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "This task requires {{ a\_default\_var\_from\_certbot }}"

your "tasks\_from" appears to be the exact intention of "exec\_main"  
from the linked feature proposal.

---

<div class="post-metadata">

**Author:** ![Oyvind\_Saltvik](https://avatars.discourse-cdn.com/v4/letter/o/8491ac/32.png) [@Oyvind\_Saltvik](https://forum.ansible.com/u/Oyvind_Saltvik)\
**Post date:** [April 4, 2017, 10:52am UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/6 "2017-04-04T10:52:08Z")

</div>

Ah, did not know there was a proposal.

This proposal seems like a good solution.

---

<div class="post-metadata">

**Author:** ![Oyvind\_Saltvik](https://avatars.discourse-cdn.com/v4/letter/o/8491ac/32.png) [@Oyvind\_Saltvik](https://forum.ansible.com/u/Oyvind_Saltvik)\
**Post date:** [April 5, 2017, 11:51pm UTC](https://forum.ansible.com/t/make-it-possible-to-set-tasks-from-to-none-in-include-role/24119/7 "2017-04-05T23:51:52Z")

</div>

A temporary (hopefully) solution to this issue for me.

In ansible.cfg

[defaults]  
roles\_path=required\_roles/

# ansible-galaxy install --roles-path required\_roles geerlingguy.certbot

# touch required\_roles/geerlingguy.certbot/tasks/none.yml

- name: certbot vars and defaults  
include\_role:  
name: geerlingguy.certbot  
tasks\_from: none
