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

hosts: aosserver,webserver


On Tue, Nov 27, 2018 at 8:17 PM Bharath Kumar <[email protected]> wrote:

> 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.
>
>
>
>
> On Tuesday, November 27, 2018 at 1:38:24 AM UTC-5, ameya agashe wrote:
>
>> 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
>>
>> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5c57c9d6-5029-49aa-8daa-2cf217b0a908%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/5c57c9d6-5029-49aa-8daa-2cf217b0a908%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAH4rTPtrgzOR8pp-yYsgv%2Bgn2M%2BeWAXyz%2BQstuwR-W4oqAjUUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to