For each of our servers (webs and perls), we have different mount points for each type of servers. So for web servers, I want to use the entries for “web_mounts” and perls would be “perl_mounts.”
If I hard code “web_mounts” into the “with_items,” it works fine. Otherwise, it tells me “nfs_group” is undefined.
But I suggest you to change a way.
Divide you hosts on groups: Web_Hosts, Perl_Hosts and specify the same variable name in group_vars directory on inventory file but with different value based on you needs for specific group.
Then you can use one variable name for any number of groups.