---
-
  name: "Block to Allow Loading of Variables without running task"
  when: run_tasks
  block:
    -
      name: Add backwards-compatibility shims.
      ansible.builtin.include_tasks: backwards-compatibility.yml
    
    -
      name: Check if Drupal is already set up.
      ansible.builtin.stat:
        path: "{{ drupal_core_path }}/index.php"
      register: drupal_site
      ignore_errors: true
    
    -
      name: Define drush_path if it's not already defined.
      ansible.builtin.set_fact:
        drush_path: drush
      when: drush_path is not defined
    
    -
      name: Define drupal_site_exists.
      ansible.builtin.set_fact:
        drupal_site_exists: "{{ drupal_site.stat.exists | default(false) }}"
    
    # Deploy Drupal if configured.
    
    -
      name: Define drush_path if it's not already defined.
      ansible.builtin.include_tasks: deploy.yml
      when: drupal_deploy
    
    -
      name: Define drupal_deploy_updated
      ansible.builtin.set_fact:
        drupal_deploy_updated: "{{ (drupal_deploy_repo_updated is defined and drupal_deploy_repo_updated.changed) | default(false) }}"
    
    # Run update tasks if Drupal was updated.
    
    -
      name: Define drush_path if it's not already defined.
      ansible.builtin.include_tasks: update.yml
      when: drupal_deploy_updated and drupal_site_exists
    
    # Build makefile if configured.
    
    -
      name: Define drush_path if it's not already defined.
      ansible.builtin.include_tasks: build-makefile.yml
      when: drupal_build_makefile
    
    # Build with composer if configured.
    
    -
      name: Define drush_path if it's not already defined.
      ansible.builtin.include_tasks: build-composer.yml
      when: drupal_build_composer
    
    # Build a composer project if configured.
    
    -
      name: Define drush_path if it's not already defined.
      ansible.builtin.include_tasks: build-composer-project.yml
      when: drupal_build_composer_project
    
    # Set Drush variables.
    -
      name: Check if a project specific Drush binary exists.
      ansible.builtin.stat:
        path: "{{ drupal_composer_install_dir }}/{{ drupal_composer_bin_dir }}/drush"
      register: drush_vendor_bin
      ignore_errors: true
    
    -
      name: Use project specific Drush if available.
      ansible.builtin.set_fact:
        drush_path: "{{ drupal_composer_install_dir }}/{{ drupal_composer_bin_dir }}/drush"
      when: drush_vendor_bin.stat.exists
    
    # Install site if configured.
    -
      name: Install site ife configured
      ansible.builtin.include_tasks: install-site.yml
      when: drupal_install_site
    