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.

Reply via email to