geerlingguy / geerlingguy/ansible-for-devops

Install Druplal on ubuntu 22.04 - [Errno 2] No such file or directory: b'vendor/bin/drush'

Open
#583 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
9.9k
Forks
3.8k
PR merge metrics
No merged PRs in 30d

Description

I'm attempting to follow the book and perform the installation of Drupal on an Ubuntu VM.

I created a new ubuntu 20.04 VM and performed updates on the host (sudo apt update && sudo apt upgrade -y).

I then ran the following playbook against the host (ubu-1.home)

```
---
- hosts: ubu1
become: yes

vars_files:
- vars.yml

pre_tasks:
- name: Update apt cache if needed.
apt: update_cache=yes cache_valid_time=3600

handlers:
- name: restart apache
service: name=apache2 state=restarted

tasks:
- name: Get software for apt repository management.
apt:
state: present
name:
- python3-apt
- python3-pycurl

- name: Add ondrej repository for later versions of PHP.
apt_repository: repo='ppa:ondrej/php' update_cache=yes

- name: "Install Apache, MySQL, PHP, and other dependencies."
apt:
state: present
name:
- acl
- git
- curl
- unzip
- sendmail
- apache2
- php8.2-common
- php8.2-cli
- php8.2-dev
- php8.2-gd
- php8.2-curl
- php8.2-opcache
- php8.2-xml
- php8.2-mbstring
- php8.2-pdo
- php8.2-mysql
- php8.2-apcu
- libpcre3-dev
- libapache2-mod-php8.2
- python3-mysqldb
- mysql-server

- name: Disable the firewall (since this is for local dev only).
service: name=ufw state=stopped

- name: "Start Apache, MySQL, and PHP."
service: "name={{ item }} state=started enabled=yes"
with_items:
- apache2
- mysql

- name: Enable Apache rewrite module (required for Drupal).
apache2_module: name=rewrite state=present
notify: restart apache

- name: Add Apache virtualhost for Drupal.
template:
src: "templates/drupal.test.conf.j2"
dest: "/etc/apache2/sites-available/{{ domain }}.test.conf"
owner: root
group: root
mode: 0644
notify: restart apache

- name: Enable the Drupal site.
command: >
a2ensite {{ domain }}.test
creates=/etc/apache2/sites-enabled/{{ domain }}.test.conf
notify: restart apache

- name: Disable the default site.
command: >
a2dissite 000-default
removes=/etc/apache2/sites-enabled/000-default.conf
notify: restart apache

- name: Adjust OpCache memory setting.
lineinfile:
dest: "/etc/php/8.2/apache2/conf.d/10-opcache.ini"
regexp: "^opcache.memory_consumption"
line: "opcache.memory_consumption = 96"
state: present
notify: restart apache

- name: Create a MySQL database for Drupal.
mysql_db: "db={{ domain }} state=present"

- name: Create a MySQL user for Drupal.
mysql_user:
name: "{{ domain }}"
password: "1234"
priv: "{{ domain }}.*:ALL"
host: localhost
state: present

- name: Download Composer installer.
get_url:
url: https://getcomposer.org/installer
dest: /tmp/composer-installer.php
mode: 0755

- name: Run Composer installer.
command: >
php composer-installer.php
chdir=/tmp
creates=/usr/local/bin/composer

- name: Move Composer into globally-accessible location.
command: >
mv /tmp/composer.phar /usr/local/bin/composer
creates=/usr/local/bin/composer

- name: Ensure Drupal directory exists.
file:
path: "{{ drupal_core_path }}"
state: directory
owner: www-data
group: www-data

- name: Check if Drupal project already exists.
stat:
path: "{{ drupal_core_path }}/composer.json"
register: drupal_composer_json

- name: Create Drupal project.
composer:
command: create-project
arguments: drupal/recommended-project "{{ drupal_core_path }}"
working_dir: "{{ drupal_core_path }}"
no_dev: true
become_user: www-data
when: not drupal_composer_json.stat.exists

- name: Add drush to the Drupal site with Composer.
composer:
command: require
arguments: drush/drush:11.*
working_dir: "{{ drupal_core_path }}"
become_user: www-data
when: not drupal_composer_json.stat.exists

- name: Install Drupal.
command: >
vendor/bin/drush si -y --site-name="{{ drupal_site_name }}"
--account-name=admin
--account-pass=admin
--db-url=mysql://{{ domain }}:1234@localhost/{{ domain }}
--root={{ drupal_core_path }}/web
chdir={{ drupal_core_path }}
creates={{ drupal_core_path }}/web/sites/default/settings.php
notify: restart apache
become_user: www-data
```

My vars file

```
---
# The path where Drupal will be downloaded and installed
drupal_core_path: "/var/www/drupal"

# the resulting domain will be [domain].test (with .test appended)
domain: "drupal"

# Drupal site name
drupal_site_name: "Drupal Test"
```

My ansible.cfg is as follows

```
[defaults]
inventory = hosts.ini
remote_tmp = /var/tmp/${USER}/ansible

[ssh_connection]
pipelining=True
```

And relevant hosts.ini portion

```
# Ubuntu vm on proxmox-1
[ubu1]
ubu-1.home
```

I am using WSL2 on Windows 11 to run the playbook against the host.

I receive the following output which does not complete at TASK [Install Drupal]

```
BECOME password:

PLAY [ubu1] ********************************************************************************************************************

TASK [Gathering Facts] *********************************************************************************************************
ok: [ubu-1.home]

TASK [Update apt cache if needed.] *********************************************************************************************
ok: [ubu-1.home]

TASK [Get software for apt repository management.] *****************************************************************************
ok: [ubu-1.home]

TASK [Add ondrej repository for later versions of PHP.] ************************************************************************
ok: [ubu-1.home]

TASK [Install Apache, MySQL, PHP, and other dependencies.] *********************************************************************
ok: [ubu-1.home]

TASK [Disable the firewall (since this is for local dev only).] ****************************************************************
ok: [ubu-1.home]

TASK [Start Apache, MySQL, and PHP.] *******************************************************************************************
ok: [ubu-1.home] => (item=apache2)
ok: [ubu-1.home] => (item=mysql)

TASK [Enable Apache rewrite module (required for Drupal).] *********************************************************************
ok: [ubu-1.home]

TASK [Add Apache virtualhost for Drupal.] **************************************************************************************
ok: [ubu-1.home]

TASK [Enable the Drupal site.] *************************************************************************************************
ok: [ubu-1.home]

TASK [Disable the default site.] ***********************************************************************************************
ok: [ubu-1.home]

TASK [Adjust OpCache memory setting.] ******************************************************************************************
ok: [ubu-1.home]

TASK [Create a MySQL database for Drupal.] *************************************************************************************
ok: [ubu-1.home]

TASK [Create a MySQL user for Drupal.] *****************************************************************************************
[WARNING]: Option column_case_sensitive is not provided. The default is now false, so the column's name will be uppercased. The
default will be changed to true in community.mysql 4.0.0.
ok: [ubu-1.home]

TASK [Download Composer installer.] ********************************************************************************************
ok: [ubu-1.home]

TASK [Run Composer installer.] *************************************************************************************************
ok: [ubu-1.home]

TASK [Move Composer into globally-accessible location.] ************************************************************************
ok: [ubu-1.home]

TASK [Ensure Drupal directory exists.] *****************************************************************************************
ok: [ubu-1.home]

TASK [Check if Drupal project already exists.] *********************************************************************************
ok: [ubu-1.home]

TASK [Create Drupal project.] **************************************************************************************************
skipping: [ubu-1.home]

TASK [Add drush to the Drupal site with Composer.] *****************************************************************************
skipping: [ubu-1.home]

TASK [Install Drupal.] *********************************************************************************************************
fatal: [ubu-1.home]: FAILED! => {"changed": false, "cmd": "vendor/bin/drush si -y '--site-name=Drupal Test' --account-name=admin --account-pass=admin '--db-url=mysql://drupal:********@localhost/drupal' --root=/var/www/drupal/web", "msg": "[Errno 2] No such file or directory: b'vendor/bin/drush'", "rc": 2, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

PLAY RECAP *********************************************************************************************************************
ubu-1.home : ok=19 changed=0 unreachable=0 failed=1 skipped=2 rescued=0 ignored=0
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.