Managing Jinja2 Templates Using Ansible

Hi @Inderpreet @andrzej @KodeKloud

I got the desired output , but task failed .Kindly check.


Hi @Inderpreet @KodeKloud @kodekloud-bot @kodekloud-support3

Kindly update the status of the above query


Hv u checked content of index.html file after failure ?

Hi @andrzej,

yes , I already shared the output of the index.html from APP2 .please find the below output.


Hi @Inderpreet @KodeKloud @kodekloud-bot @andrzej,

Kindly update the status.

Apologies for delayed response, this task has been marked Success for you.

Hi @Inderpreet


@Inderpreet @mmumshad @KodeKloud @kodekloud-support3

This task was assigned for me today. I think I made what the task asked to do, but it’s still marked as failed. The template path in text was httpd/templates/index.html.j2, but on validation is shown only ‘template’. Can you kindly check?

@francilio thanks for reporting this. Thanks is just a typo in error message but validation is checking the correct location, could you share your KKE username we can re-check your answer.

1 Like

My KKE email is

Hi @Inderpreet

I am getting the same error kindly check on this

My KKE emai Id is

1 Like

@francilio @Prabhu this is marked Success for you guys.


@Inderpreet Thank you!!

hello @Inderpreet
i have the same issue here !

@redops this is marked Success for you.

thank you for your usual efforts @Inderpreet


Go to /home/thor/ansible and update inventory file

Comment which is not required

Update hosts as all in playbook.yml


Update var file as below

Update index.html.j2 under /home/thor/ansible/role/httpd/templates/

Update tasks main.yml as below

How to update hostname in templates/index.html.js ? Is there other thing I have to change?

I used ansible_facts but not working
[root@stapp03 html]# cat index.html
This file was created using Ansible on {{ansible_facts[‘hostname’]}}

Also it is mentioned to use inventory_hostname?
Also please make sure not to hard code the server name inside the template. Instead, use inventory_hostname variable to fetch the correct value.

@player001 @andrzej please help

Looks fine what error you are getting?
{{ inventory_hostname }}


I tried using template module instead of copy module.