# How to specify multiple groups in ansible playbook.

**URL:** <https://forum.ansible.com/t/how-to-specify-multiple-groups-in-ansible-playbook/29121>\
**Category:** Ansible Project\
**Tags:** azure, windows\
**Created:** [November 27, 2018, 6:37am UTC](https://forum.ansible.com/t/how-to-specify-multiple-groups-in-ansible-playbook/29121 "2018-11-27T06:37:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameya\_Agashe](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Ameya\_Agashe](https://forum.ansible.com/u/Ameya_Agashe)\
**Post date:** [November 27, 2018, 6:37am UTC](https://forum.ansible.com/t/how-to-specify-multiple-groups-in-ansible-playbook/29121/1 "2018-11-27T06:37:58Z")

</div>

Hello,

I’m wondering how to specify multiple groups in a Ansible playbook??

I followed the correct syntax but it reports error “skipping: no hosts matched”

Playbook code is as below:

- name: Install IIS on the newly provisioned Azure Windows Web Servers  
hosts: webserver  
gather\_facts: yes  
tasks:

- name: Install IIS (Web-Server and Web-Common-Http)  
win\_feature:  
name:

- Web-Server

- Web-Common-Http  
state: present

- name: Install IIS Web-Server with sub features and management tools  
win\_feature:  
name: Web-Server  
state: present  
include\_sub\_features: True  
include\_management\_tools: True  
register: feature\_install

- name: Print variable  
debug:  
var: feature\_install

- name: reboot if installing Web-Server feature requires it  
win\_reboot:  
when: feature\_install.reboot\_required

- name: Install .Net Framework 3.5 on AOS and Web Servers  
hosts: webserver:&aosserver  
gather\_facts: yes  
tasks:

- name: Install .Net Framework 3.5  
win\_feature:  
name: NET-Framework-Features  
include\_sub\_features: True  
state: present  
register: dotnet35\_install

- name: Print variable  
debug:  
var: dontnet35\_install

- name: reboot if installing Web-Server feature requires it  
win\_reboot:  
when: dotnet35\_install.reboot\_required

- name: Install .Net Framework 4.5 on AOS and Web Servers  
hosts: webserver:&aosserver  
gather\_facts: yes  
tasks:

- name: Install .Net Framework 4.5  
win\_feature:  
name: NET-Framework-45-Features  
include\_sub\_features: True  
state: present  
register: dotnet45\_install

- name: Print variable  
debug:  
var: dontnet45\_install

- name: reboot if installing Web-Server feature requires it  
win\_reboot:  
when: dotnet45\_install.reboot\_required

When I run, the first part of webserver works well, but for aosserver I get the below error

TASK [reboot if installing Web-Server feature requires it] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /media/sf\_C\_DRIVE/OnlyOnMyPC/ansible/playbooks.V4/apply-iis.yml:24  
skipping: [10.100.3.11] =\> {  
“changed”: false,  
“skip\_reason”: “Conditional result was False”  
}  
skipping: [10.100.3.12] =\> {  
“changed”: false,  
“skip\_reason”: “Conditional result was False”  
}  
META: ran handlers  
META: ran handlers

PLAY [Install .Net Framework 3.5 on AOS and Web Servers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched

PLAY [Install .Net Framework 4.5 on AOS and Web Servers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
10.100.3.11 : ok=4 changed=0 unreachable=0 failed=0  
10.100.3.12 : ok=4 changed=0 unreachable=0 failed=0

My inventory file is like below

cat inventory/hosts  
[aosserver]  
10.100.3.4  
10.100.3.6

[webserver]  
10.100.3.11  
10.100.3.12

Wondering what I am doing wrong here?

Kindly assist

Thank you very much.

Kind Regards,  
Ameya Agashe

---

<div class="post-metadata">

**Author:** ![Bharath\_Kumar2](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@Bharath\_Kumar2](https://forum.ansible.com/u/Bharath_Kumar2)\
**Post date:** [November 28, 2018, 4:17am UTC](https://forum.ansible.com/t/how-to-specify-multiple-groups-in-ansible-playbook/29121/2 "2018-11-28T04:17:52Z")

</div>

One way to achieve the result is modifying your hosts file as below, could help.

`  
[aosserver]  
10.100.3.4  
10.100.3.6

[webserver]  
10.100.3.11  
10.100.3.12

[webaos:children]  
aosserver  
webserver

`

and, use webaos in the target group/hosts.

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [November 28, 2018, 4:49am UTC](https://forum.ansible.com/t/how-to-specify-multiple-groups-in-ansible-playbook/29121/3 "2018-11-28T04:49:54Z")

</div>

You can also just comma-separate a list of groups like:

hosts: aosserver,webserver

---

<div class="post-metadata">

**Author:** ![Ameya\_Agashe](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@Ameya\_Agashe](https://forum.ansible.com/u/Ameya_Agashe)\
**Post date:** [November 28, 2018, 5:08am UTC](https://forum.ansible.com/t/how-to-specify-multiple-groups-in-ansible-playbook/29121/4 "2018-11-28T05:08:48Z")

</div>

Many thanks to you both! Much appreciated. It’s working now.

Kind Regards,  
Ameya Agashe
