James,

Thanks
That worked but also another error popped up below
I think maybe because it is redhat 7.2 

 ansible-playbook linuxpatch.yml

PLAY [testserver] 
*********************************************************************************************************************************************

TASK [Gathering Facts] 
****************************************************************************************************************************************
ok: [testserver]

TASK [update the system] 
**************************************************************************************************************************************
fatal: [testserver]: FAILED! => {"changed": false, "msg": "There are no 
enabled repos.\n Run \"yum repolist all\" to see the repos you have.\n You 
can enable repos with yum-config-manager --enable <repo>\n", "rc": 1, 
"results": []}

PLAY RECAP 
****************************************************************************************************************************************************
testserver                 : ok=1    changed=0    unreachable=0    
failed=1    skipped=0    rescued=0    ignored=0   




On Sunday, February 23, 2020 at 4:09:12 PM UTC, Daley Okuwa wrote:
>
> I have written a simple script to patch my red hat server and it is 
> comming out with this error message when i run : ansible-playbook 
> linuxpatch.yml
>
> ERROR! the field 'hosts' is required but was not set
>
> in /etc/ansible/hosts i only have an entry of testserver
>
>
>
> ---
>
> - hosts: testserver
> - become_user: root
>
>   tasks:
>
>     - name: update the system
>       yum: 
>         name: "*" 
>         state: latest
>
>     - name: restart system to reboot to newest kernel
>       shell: "sleep 5 && reboot"
>       async: 1
>       poll: 0
>
>     - name: wait for 10 secs
>       pause:
>         seconds: 10
>
>     - name: wait for system to reboot
>       wait_for_connection:
>         connect_timeout: 20
>         sleep: 5
>         delay: 5
>         timeout: 60
>
>     - name: install epel-release
>       yum:
>         name: epel-release
>         state: latest
>          
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/fa9160ed-35e2-4dfb-acd2-0d568908c62f%40googlegroups.com.

Reply via email to