Ansible Roles - Concept

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.

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:

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