Replace host name in yml file

hi I have a question this is my main.yml file content:

  • name: Start Tomcat

service: name=tomcat7 state=restarted enabled=yes

command: wget “http://admin:admin@10.1.33.155:8080/manager/text/stop?path=/externaluserwebapi” -O - -q

become: True

become_method: sudo

run_once: true

changed_when: False

Now as you can see there is server name in the command itself (bolded) and it is basically stopping a given application running in tomcat server vs the whole server.

Now my problem is that how can i run this for the given hosts file. Is there a way I can replace the hardcoded server name here by hosts from the hosts file?

Please advise.

Thanks.

That command is going to run on the tomcat server, so you probably can
just use 127.0.0.1

omg never thought of that :slight_smile: thanks !!