How do I assign different variable values for different group system

Hello,

I’m trying to create an Ansible role, networking, to automate /etc/resolv.conf file. I created this role like below:

production

networking.yml

group_vars/
agroup
bgroup

roles/
networking/
tasks/main.yml
templates/resolv.conf.j2

In my resolv.conf.j2 file, I put variables in this file:

{% for item in nameserver %}
nameserver {{ item }}
{% endfor %}

The name servers will be different for different group systems.

In group_vars/agroup:

Why don't you just run the code and check for yourself?
Anyway, the answer to your question is yes.