The preceding hyphen in front of "become_user" is initiating a new play
segment. Remove that hyphen so that become user becomes a key of the play
that was started by your "- hosts" declaration.

On Sun, Feb 23, 2020 at 11:09 AM Daley Okuwa <daleyok...@gmail.com> 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/6fd69d1c-e027-4bae-9b2e-12e5ba1682d5%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-devel/6fd69d1c-e027-4bae-9b2e-12e5ba1682d5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAMSYDtza_ZORQf21PTSdC76AtZX%3DebKFWxmmxo8dVU1Bs1PVtQ%40mail.gmail.com.

Reply via email to