Ansible Blockinfile Module Bug

I’m not understanding why its failing. I did everything that the tasks has asked for and even verified it.

Here is the task:

We already have an inventory file under /home/thor/ansible directory on jump host . Create a playbook.yml under /home/thor/ansible directory on jump host itself.

  1. Using the playbook, install httpd web server on all app servers. Additionally, make sure its service should up and running.

  2. Using blockinfile Ansible module add some content in /var/www/html/index.html file. Below is the content:

Welcome to XfusionCorp!

This is Nautilus sample file, created using Ansible!

Please do not modify this file manually!

  1. The /var/www/html/index.html file’s user and group owner should be apache on all app servers.

  2. The /var/www/html/index.html file’s permissions should be 0777 on all app servers.

Note:

i. Validation will try to run the playbook using command ansible-playbook -i inventory playbook.yml so please make sure the playbook works this way without passing any extra arguments.

ii. Do not use any custom or empty marker for blockinfile module.

And i added screenshots of verification and of my playbook.

Here is my playbook

---
- name: Install Web Server
  hosts: all
  become: yes
  tasks:
    - name: Install httpd
      ansible.builtin.dnf:
        name: httpd
        state: present

    - name: Start and Enable httpd
      ansible.builtin.service:
        name: httpd
        enabled: true
        state: started

    - name: Add index.html content
      ansible.builtin.blockinfile:
        path: /var/www/html/index.html
        owner: apache
        group: apache
        mode: '0777'
        create: yes
        block: |
          Welcome to XfusionCorp!
          This is a Nautilus sample file, created using Ansible!
          Please do not modify this file manually!
    ```

Someone please assist

Hello ,

Pardon me, but i didnt get it ? where is the problem actually ?

The task keeps failing saying that stapp01 doesnt contain the content even though its there when i validated it.

Juste a question , is the machine Debian or RHEL based ?

If its Debian family, it should have www-data for Debian ( user & group) and apache for RHEL ( user & group) , what i can see that the task is Okay , waiting for an Admin to verify this

Greetings.

Thanks for your help i’ll stand by for admin. But it is RHEL based

Problem was resolved