Skip to content

Commit cf2819d

Browse files
committed
Issue #308: Update Drupal example in chapter 4 to 9.0.x.
1 parent 802f4b3 commit cf2819d

File tree

4 files changed

+45
-53
lines changed

4 files changed

+45
-53
lines changed

drupal/Vagrantfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
1010
config.ssh.insert_key = false
1111

1212
config.vm.provider :virtualbox do |v|
13-
v.memory = 1024
13+
v.memory = 2048
1414
end
1515

1616
# Ansible provisioning.

drupal/provisioning/playbook.yml

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
apt:
1919
state: present
2020
name:
21-
- python-apt
22-
- python-pycurl
21+
- python3-apt
22+
- python3-pycurl
2323

2424
- name: Add ondrej repository for later versions of PHP.
2525
apt_repository: repo='ppa:ondrej/php' update_cache=yes
@@ -64,7 +64,7 @@
6464
apache2_module: name=rewrite state=present
6565
notify: restart apache
6666

67-
- name: Add Apache virtualhost for Drupal 8.
67+
- name: Add Apache virtualhost for Drupal.
6868
template:
6969
src: "templates/drupal.test.conf.j2"
7070
dest: "/etc/apache2/sites-available/{{ domain }}.test.conf"
@@ -73,17 +73,16 @@
7373
mode: 0644
7474
notify: restart apache
7575

76-
- name: Symlink Drupal virtualhost to sites-enabled.
77-
file:
78-
src: "/etc/apache2/sites-available/{{ domain }}.test.conf"
79-
dest: "/etc/apache2/sites-enabled/{{ domain }}.test.conf"
80-
state: link
76+
- name: Enable the Drupal site.
77+
command: >
78+
a2ensite {{ domain }}.test
79+
creates=/etc/apache2/sites-enabled/{{ domain }}.test.conf
8180
notify: restart apache
8281

83-
- name: Remove default virtualhost file.
84-
file:
85-
path: "/etc/apache2/sites-enabled/000-default.conf"
86-
state: absent
82+
- name: Disable the default site.
83+
command: >
84+
a2dissite 000-default
85+
removes=/etc/apache2/sites-enabled/000-default.conf
8786
notify: restart apache
8887

8988
- name: Adjust OpCache memory setting.
@@ -131,53 +130,43 @@
131130
mv /tmp/composer.phar /usr/local/bin/composer
132131
creates=/usr/local/bin/composer
133132
134-
- name: Check out drush 8.x branch.
135-
git:
136-
repo: https://github.com/drush-ops/drush.git
137-
version: 8.x
138-
dest: /opt/drush
139-
140-
- name: Install Drush dependencies with Composer.
141-
command: >
142-
/usr/local/bin/composer install
143-
chdir=/opt/drush
144-
creates=/opt/drush/vendor/autoload.php
145-
146-
- name: Create drush bin symlink.
147-
file:
148-
src: /opt/drush/drush
149-
dest: /usr/local/bin/drush
150-
state: link
151-
152-
- name: Check out Drupal Core to the Apache docroot.
153-
git:
154-
repo: https://git.drupal.org/project/drupal.git
155-
version: "{{ drupal_core_version }}"
156-
dest: "{{ drupal_core_path }}"
157-
register: git_checkout
158-
159-
- name: Ensure Drupal codebase is owned by www-data.
133+
- name: Ensure Drupal docroot exists.
160134
file:
161135
path: "{{ drupal_core_path }}"
136+
state: directory
162137
owner: www-data
163138
group: www-data
164-
recurse: true
165-
when: git_checkout.changed | bool
166139

167-
- name: Install Drupal dependencies with Composer.
168-
command: >
169-
/usr/local/bin/composer install
170-
chdir={{ drupal_core_path }}
171-
creates={{ drupal_core_path }}/vendor/autoload.php
140+
- name: Check if Drupal project already exists.
141+
stat:
142+
path: "{{ drupal_core_path }}/composer.json"
143+
register: drupal_composer_json
144+
145+
- name: Create Drupal project.
146+
composer:
147+
command: create-project
148+
arguments: drupal/recommended-project "{{ drupal_core_path }}"
149+
working_dir: "{{ drupal_core_path }}"
150+
no_dev: true
172151
become_user: www-data
152+
when: not drupal_composer_json.stat.exists
153+
154+
- name: Add drush to the Drupal site with Composer.
155+
composer:
156+
command: require
157+
arguments: drush/drush:10.*
158+
working_dir: "{{ drupal_core_path }}"
159+
become_user: www-data
160+
when: not drupal_composer_json.stat.exists
173161

174162
- name: Install Drupal.
175163
command: >
176-
drush si -y --site-name="{{ drupal_site_name }}"
164+
vendor/bin/drush si -y --site-name="{{ drupal_site_name }}"
177165
--account-name=admin
178166
--account-pass=admin
179167
--db-url=mysql://{{ domain }}:1234@localhost/{{ domain }}
180-
--root={{ drupal_core_path }}
181-
creates={{ drupal_core_path }}/sites/default/settings.php
168+
--root={{ drupal_core_path }}/web
169+
chdir={{ drupal_core_path }}
170+
creates={{ drupal_core_path }}/web/sites/default/settings.php
182171
notify: restart apache
183172
become_user: www-data

drupal/provisioning/templates/drupal.test.conf.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
ServerAdmin webmaster@localhost
33
ServerName {{ domain }}.test
44
ServerAlias www.{{ domain }}.test
5-
DocumentRoot {{ drupal_core_path }}
6-
<Directory "{{ drupal_core_path }}">
5+
DocumentRoot {{ drupal_core_path }}/web
6+
<Directory "{{ drupal_core_path }}/web">
77
Options FollowSymLinks Indexes
88
AllowOverride All
99
</Directory>

drupal/provisioning/vars.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
---
22
# The core version you want to use.
3-
drupal_core_version: "8.9.x"
3+
drupal_core_version: "9.0.x"
44

55
# The path where Drupal will be downloaded and installed.
6-
drupal_core_path: "/var/www/drupal-{{ drupal_core_version }}-dev"
6+
drupal_core_path: "/var/www/drupal"
77

88
# The resulting domain will be [domain].test (with .test appended).
99
domain: "drupal"
1010

1111
# Your Drupal site name.
1212
drupal_site_name: "Drupal Test"
13+
14+
# The Drush branch version to install.
15+
drush_version: "10.x"

0 commit comments

Comments
 (0)