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:


here’s the jinja2 template:

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

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
    name: httpd
    state: latest

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

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