I actually figured it out, should use the -l

-i ./inventory/hosts -l Windows

Works like a charm!

On Saturday, October 16, 2021 at 10:56:29 AM UTC-7 James Ngo wrote:

> I have changed to "host: all" per your suggestion, it unfortunately did 
> not help...
> It does not like the -i ./inventory/hosts Windows
> But if I just do -i ./inventory/hosts (without the group "Windows"), it 
> will work but it will do all the devices/machines instead of just a 
> specific group (which I want to)
> Thank you
>
>
> On Saturday, October 16, 2021 at 10:37:54 AM UTC-7 [email protected] 
> wrote:
>
>> That "*" is a bit unusual (to me at least).
>> Try:
>>
>> hosts: all
>>
>> And then see if the issue is still there
>>
>>
>> On Sat, 16 Oct 2021 at 19:27, James Ngo <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> Right, it maybe the playbook itself. Anyway, the play1.yml is per below:
>>>
>>> ========================
>>> - hosts: "*"
>>>   become: yes
>>>   tasks:
>>>     - name: apt
>>>       apt:
>>>         update_cache: yes
>>>         upgrade: 'yes'
>>> =========================
>>>
>>> If I run the play1.yml with the following command, without specify any 
>>> group name, it works:
>>> $ ansible-playbook ./playbooks/play1.yml --user admin --ask-pass 
>>> --ask-become-pass -i ./inventory/hosts
>>>
>>>
>>> Then it is OK!!!
>>>
>>>
>>>
>>> On Saturday, October 16, 2021 at 9:59:38 AM UTC-7 [email protected] 
>>> wrote:
>>>
>>>> Then the issue must in the playbook itself. 
>>>> What does that look like?
>>>>
>>>> On Sat, 16 Oct 2021 at 18:26, James Ngo <[email protected]> wrote:
>>>>
>>>>> Hello everyone,
>>>>> I am a pretty new face to Ansible. I can follow instruction pretty 
>>>>> good however, I need your help with the following scenario.
>>>>> I created an .INI style inventory file called "hosts", with basically 
>>>>> categorize our devices/servers in different groups like below
>>>>>
>>>>> +++++++++++++++++++
>>>>> [Ubuntu]
>>>>> 192.168.100.105
>>>>> 192.168.100.106
>>>>>
>>>>> [Windows]
>>>>> 192.168.100.200
>>>>> 192.168.100.201
>>>>>
>>>>> [Mac]
>>>>> 192.168.100.300
>>>>> 192.168.100.301
>>>>>
>>>>> ++++++++++++++++++++++
>>>>> This inventory file is saved in ~/ansible/inventory/hosts
>>>>> Playbook file (called play1.yml) is saved in ~/ansible/plabooks/play1: 
>>>>> check for updates
>>>>>
>>>>> I can ping the devices in [Windows] group using this command:
>>>>> $ ansible -i ./inventory/hosts Windows -m ping --user admin --ask-pass
>>>>>
>>>>> Now, I try to check for updates for just the devices/machines in 
>>>>> [Windows] group, using this command:
>>>>> $ ansible-playbook ./playbooks/play1.yml --user admin --ask-pass 
>>>>> --ask-become-pass -i ./inventory/hosts Windows
>>>>>
>>>>> It returns error that it does not know what devices/machines that I'm 
>>>>> targeting at. In another word, it does not recognize my flag 
>>>>> ./inventory/hosts Windows
>>>>>
>>>>> Could someone guide me how to make the proper reference to a specific 
>>>>> group of the machines?
>>>>>
>>>>> Thank you
>>>>>
>>>>> -- 
>>>>> 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/66ff95de-e6ca-46fb-9718-8ddbe9eb89acn%40googlegroups.com
>>>>>  
>>>>> <https://groups.google.com/d/msgid/ansible-project/66ff95de-e6ca-46fb-9718-8ddbe9eb89acn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>> -- 
>>>> Sent from a mobile device - please excuse the brevity, spelling and 
>>>> punctuation.
>>>>
>>> -- 
>>> 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/7994ff2b-6f66-45bc-87ad-086afe7c6446n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/7994ff2b-6f66-45bc-87ad-086afe7c6446n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> -- 
>> Sent from a mobile device - please excuse the brevity, spelling and 
>> punctuation.
>>
>

-- 
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/cd42e3f8-b0e6-4175-9ce3-21696015a8c7n%40googlegroups.com.

Reply via email to