This is more like a question about what is going on under the hood, so the first one just does the task wrongly, and ended in not parsing right the jinja2 { inventory_hostname } field to steve and just write { inventory_hostname } in the html file. I’m kinda curious about why you must use this different syntax while working with roles in ansible.
Hi @Alistair_KodeKloud , no I was wondering why the first block of code doesn’t work for the task. In this task you need to just modify one server. So you can put in the hosts variable the webapp hostname to just modify that. What I don’t understand is why in this case in which you are force to use Roles in ansible, the task can’t be done correctly with the first block of code but you can with the second.
The first block ends with this result when you curl the webapp server:
This is the message from server { inventory_hostname }
But the second one makes you have:
This is the message from server webapp01
Which it does change the variable declared in the jinja2 template to the value of inventory_hostname