# Ansible Roles - Concept

**URL:** <https://forum.ansible.com/t/ansible-roles-concept/37380>\
**Category:** Ansible Project\
**Created:** [November 23, 2022, 1:19pm UTC](https://forum.ansible.com/t/ansible-roles-concept/37380 "2022-11-23T13:19:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RG1](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@RG1](https://forum.ansible.com/u/RG1)\
**Post date:** [November 23, 2022, 1:19pm UTC](https://forum.ansible.com/t/ansible-roles-concept/37380/1 "2022-11-23T13:19:57Z")

</div>

i’d like to migrate my playbooks into ansible roles. I started but a basic question raises.

E.g.  
I’d like to implement nfs in a bunch of of linux machines. on one machine i’ve to configure the nfs-sharing and on the other machines I’ve to implemt the link to the nfs-sourcing host.

systemA - configure a share for other hosts  
systemB,C,D - use the nfs-sharing from system A

I tried to create a role called nfs where i have to configure a few tasks on systemA and the other tasks on systemB,C,D  
I’ve splitted the tasks into 2 vaious task files one for systemA and one for systemB and both will be imported into main.yml in tasks.

---

<div class="post-metadata">

**Author:** ![sdarwin](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sdarwin/32/2450_2.png) [@sdarwin](https://forum.ansible.com/u/sdarwin)\
**Post date:** [November 28, 2022, 4:57pm UTC](https://forum.ansible.com/t/ansible-roles-concept/37380/2 "2022-11-28T16:57:32Z")

</div>

Hi RG,

Here is a solution for that problem which I have used for a long time, maybe before ansible tags were available.

tasks/main.yml:

- name: include client  
import\_tasks: client.yml  
when: run\_nfs\_client is defined

- name: include server  
import\_tasks: server.yml  
when: run\_nfs\_server is defined

playbook.yml:

---

<div class="post-metadata">

**Author:** ![Robert\_Griessner](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@Robert\_Griessner](https://forum.ansible.com/u/Robert_Griessner)\
**Post date:** [December 1, 2022, 1:39pm UTC](https://forum.ansible.com/t/ansible-roles-concept/37380/3 "2022-12-01T13:39:38Z")

</div>

thx samuel, looks good. if there’s some time i’ll have a try. br, robert
