Thanks, this is working. On Saturday, September 19, 2020 at 11:17:51 PM UTC+5:30 [email protected] wrote:
> Try > - name: check the url http://{{ inventory_hostname}}:{{ port }}/test > > On Sat, 19 Sep 2020, 20:46 priyanka prabhune, <[email protected]> > wrote: > >> I am writing the Ansible playbook to check the URL status for multiple >> IPs from the hosts file, however, it is not working when I am giving input >> as a group_name, but is working for single IP. >> >> Here is my playbook, >> --- >> - hosts: "{{ hosts }}" >> vars_prompt: >> - name: "hosts" >> prompt: "Please enter the hosts details" >> private: no >> - name: "port" >> prompt: "Please enter the port" >> private: no >> >> serial: 1 >> tasks: >> - name: check the url http://{{ hosts }}:{{ port }}/test >> uri: >> url: "http://{{ hosts }}:{{ port }}/test" >> follow_redirects: none >> method: GET >> register: _result >> until: _result.status == 200 >> >> My application is running on below Ips and I want to check the url status >> for all. >> [webservers] >> 10.10.10.10 >> 10.10.10.20 >> 10.10.10.30 >> 10.10.10.40 >> >> *But it's getting failed with below error.* >> ansible-playbook test.yml -u test --ask-pass SSH password: [WARNING]: >> Invalid characters were found in group names but not replaced, use -vvvv to >> see details Please enter the hosts details: webservers Please enter the >> port: 8080 [WARNING]: Found variable using reserved name: port PLAY >> [webservers] >> ****************************************************************************> >> >> ******************************** TASK [Gathering Facts] >> ********************************************************************************************************** >> >> ok: [10.10.10.10] TASK [http://webservers:8080/test] >> ********************************************************************** >> [WARNING]: The value True (type bool) in a string field was converted to >> u'True' (type string). If this does not look like what you expect, quote >> the entire value to ensure it does not change. fatal: [10.10.10.10]: >> FAILED! => {"changed": false, "content": "", "elapsed": 0, >> "failed_when_result": true, "msg": "Status code was -1 and not [200]: >> Request failed: <urlopen error [Errno -2] Name or service not known>", >> "redirected": false, "status": -1, "url": "*http://webservers:8080/test >> <http://webservers:8080/test>*"} PLAY RECAP >> ********************************************************************************************************************** >> >> 10.10.10.10 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 >> ignored=0 >> >> *Can someone please suggest on this?* >> >> -- >> 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/d77b3789-c21e-4dbe-8780-01bb9aab1c8fn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/d77b3789-c21e-4dbe-8780-01bb9aab1c8fn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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/defb2b73-387e-452f-b25a-78ad43701bfbn%40googlegroups.com.
