It sounds like you want one NFS role that can do both NFS server and NFS client
tasks. Were I designing such a role I think I would use a variable or tag to
identify which "persona" you want the role to configure, and use that in the
tasks/main.yml to source two different task files. One task file would do the
work for an NFS server persona. One task file would do the work for an NFS
client persona.
roles/nfs/tasks/main.yml
---
- name: configure nfs server
include_tasks: nfs_server.yml
tags: nfs_server
- name: configure nfs client
include_tasks: nfs_client.yml
tags: nfs_client
...
roles/nfs/tasks/nfs_server.yml
---
- name: tasks to configure nfs servers
some_tasks:
...
roles/nfs/tasks/nfs_client.yml
---
- name: tasks to configure nfs clients
some_tasks:
...
This lets you separate the tasks for server and client persona. Executing the
role with tag nfs_server will configure the inventory machines as nfs servers.
Executing the role with tag nfs_client will configure the inventory machines as
nfs clients. Execute the role two times with different inventories and tags as
you showed in your original message.
my_playbook.yml
---
- hosts: cmp
become: true
tags: nfs_server
roles:
- nfs
- hosts:
- hardware:!cmp
- vms
become: true
tags: nfs_client
roles:
- nfs
I am curious to have others also propose ideas to see how others might address
the problem.
Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123
On Nov 23, 2022, at 8:08 AM, Robert Grießner
<[email protected]<mailto:[email protected]>> wrote:
Hi,
i'd like to migrate my playbooks into a ansible role. I started but a basic
question raises.
E.g.
I sould like to implement nfs in network 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.
---
# tasks file for installing nfs
- import_tasks: install_cmp.yml
- import_tasks: install_machines.yml
in the run.yml I tried to call the same role twice where I used tags to call
the plays for the cmp machine from install_cmp.yml and the tags in
install_machines for running the plays for the other machines. however this
doesn't work
- hosts: cmp
become: true
tags:
- create_nfs_cmp
- config_exports_cmp
- exportfs_cmp
- symlink_cmp
- symlink_hostsini_cmp
roles:
- nfs
- hosts:
- hardware:!cmp
- vms
become: true
tags:
- create_nfs_machines
- mnt_nfs_machines
roles:
- nfs
is my concept wrong, do I have to configure to roles one for setting up nfs on
cmp and one for implementing nfs on the machines or is it possible to create
just one role for installing nfs on with vaious tasks on various machines?
Thx
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a9e1aa6f-f5d8-4256-b735-fc693bb133b4n%40googlegroups.com<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fansible-project%2Fa9e1aa6f-f5d8-4256-b735-fc693bb133b4n%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7Cwalter.rowe%40nist.gov%7C63631feb95cf466144e408dacd54229d%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638048058487251915%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=FOpwW7nZfhWhVKzhASHgCri5nwlggPPnue52DU9YQYI%3D&reserved=0>.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/65960A4F-FCE4-45C2-9F6B-DF3F23EE4348%40nist.gov.