Ansible Setup Httpd and PHP Failed

Hi @Inderpreet @rahul456

The task got failed and i couldnt find any issue and my play book as below


  • hosts: stapp02
    become: true
    become_user: root
    tasks:
    • name: instll packages
      yum:
      name: [“httpd”,“php”]
      state: present
    • name: create document root
      file:
      name: /var/www/html/myroot
      state: directory
    • name: modify document root
      lineinfile:
      path: /etc/httpd/conf/httpd.conf
      regexp: “^DocumentRoot”
      line: “DocumentRoot /var/www/html/myroot”
    • name: php config
      template:
      src: templates/phpinfo.php.j2
      dest: /var/www/html/myroot/phpinfo.php
      owner: apache
      group: apache
    • name: service start
      service:
      name: httpd
      state: started
      enabled: yes

All tasks are successfully completed and post verification also done
Can someone guide me trouble shoot the same?

@Tej-Singh-Rana @rahul456
Kindly check on my task.
Task: Ansible Setup Httpd and PHP

Error:
Apache document root seems incorrect on App Server 2

Task expired. @Inderpreet @rahul456, Can you please check what went wrong on this playbook.

it seems you need to mention “path” in “file” module.

  • name: create document root
    file:
    path: /var/www/html/myroot
    state: directory