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
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.
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 \n”, “rc”: 1, “results”: }
PLAY RECAP ****************************************************************************************************************************************************
testserver : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
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 \n”, “rc”: 1, “results”: }
Looks like it is related to repo. Do you mind to check if the repo is available on your system