--- # ------------------ VALIDATION TASKS ------------------ - name: "Validate that project root '{{ project.project_root }}' exists" ansible.builtin.stat: path: "{{ project.project_root }}" register: project_root_stat - name: "Fail if project root directory does not exist" ansible.builtin.fail: msg: | VALIDATION FAILED for site '{{ project.domain }}': The project_root directory '{{ project.project_root }}' does not exist. This path is required for Composer. Please create it or correct the path in Lenverge.yaml. when: not project_root_stat.stat.exists or not project_root_stat.stat.isdir - name: "Validate that document root '{{ project.document_root }}' exists" ansible.builtin.stat: path: "{{ project.document_root }}" register: document_root_stat - name: "Fail if document root directory does not exist" ansible.builtin.fail: msg: | VALIDATION FAILED for site '{{ project.domain }}': The document_root directory '{{ project.document_root }}' does not exist. This path is required for Nginx. Please create it or correct the path in Lenverge.yaml. when: not document_root_stat.stat.exists or not document_root_stat.stat.isdir - name: "Check for an index file (index.php or index.html) in the document root" ansible.builtin.find: paths: "{{ project.document_root }}" patterns: "index.php,index.html" file_type: file register: index_file_find - name: "Fail if no index file is found" ansible.builtin.fail: msg: | VALIDATION FAILED for site '{{ project.domain }}': No 'index.php' or 'index.html' was found in the document_root '{{ project.document_root }}'. Nginx requires an entry point file to serve the site. when: index_file_find.matched == 0 # ------------------ PERMISSION FIX FOR LARAVEL ------------------ - name: "Check if 'storage' directory exists in project root" ansible.builtin.stat: path: "{{ project.project_root }}/storage" register: storage_dir_stat - name: "Set full permissions (777) on 'storage' if it exists" ansible.builtin.file: path: "{{ project.project_root }}/storage" mode: '0777' recurse: yes when: storage_dir_stat.stat.exists and storage_dir_stat.stat.isdir # ------------------ CONFIGURATION TASKS ------------------ - name: "Create Nginx config for {{ project.domain }} in conf.d" ansible.builtin.template: src: nginx-site.conf.j2 dest: "/etc/nginx/conf.d/{{ project.domain }}.conf" owner: root group: root mode: '0644' notify: - Reload Nginx - Reload PHP-FPM Services - name: "Create project-specific database '{{ project.database }}'" community.mysql.mysql_db: name: "{{ project.database }}" state: present login_unix_socket: /var/run/mysqld/mysqld.sock when: project.database is defined and (db_engine == 'mariadb' or db_engine == 'mysql') - name: "Create project-specific PostgreSQL database '{{ project.database }}'" community.postgresql.postgresql_db: name: "{{ project.database }}" owner: "{{ db_credentials.user }}" state: present become: yes become_user: postgres when: project.database is defined and db_engine == 'postgres'