Ansible jinja2 task failed

hey team,

I got Ansible jinja2 task failed here,
the msg is telling me that I didn’t add copy from src to dest task which is absolutely incorrect.

here’s the playbook:

image

here’s the jinja2 template:
image

here’s the tasks YAML file:

and the result is working just fine:

message from task after finishing it:

can you please look into this ?
thanks in advance

@kodekloud-support3
could you please take a look ?

Your task file is wrong, you should use template instead of copy:

[email protected]_host ~/ansible$ cat role/httpd/tasks/main.yml

tasks file for role/test

  • name: install the latest version of HTTPD
    yum:
    name: httpd
    state: latest

  • name: Start service httpd
    service:
    name: httpd
    state: started

  • name: Copy file
    template:
    src: /home/thor/ansible/role/httpd/templates/index.html.j2
    dest: /var/www/html/index.html
    mode: 0755
    owner: “{{ ansible_user }}”
    group: “{{ ansible_user }}”