Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 4765d81

Browse files
committed
#1672: Update geerlingguy.drush role to 3.0.0.
1 parent 0863eda commit 4765d81

11 files changed

+169
-39
lines changed

provisioning/requirements.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
- src: geerlingguy.drupal-console
2323
version: 1.1.0
2424
- src: geerlingguy.drush
25-
version: 2.0.2
25+
version: 3.0.0
2626
- src: geerlingguy.elasticsearch
2727
version: 2.1.3
2828
- src: geerlingguy.firewall

provisioning/roles/geerlingguy.drush/.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
services: docker
33

44
env:
5-
# Normal installation.
5+
# Default installation.
66
- distro: centos7
77
playbook: test.yml
88
- distro: ubuntu1604
@@ -11,6 +11,9 @@ env:
1111
playbook: test.yml
1212
- distro: debian9
1313
playbook: test.yml
14+
# Install from composer.
15+
- distro: centos7
16+
playbook: test-composer-install.yml
1417
# Install from source.
1518
- distro: centos7
1619
playbook: test-source-install.yml

provisioning/roles/geerlingguy.drush/README.md

+46-13
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,80 @@
22

33
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-drush.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-drush)
44

5-
Installs [Drush](http://www.drush.org/en/master/), a command line shell and scripting interface for Drupal, on any Linux or UNIX system.
5+
Installs [Drush](http://www.drush.org), a command line shell and scripting interface for Drupal, on any Linux or UNIX system.
66

77
## Requirements
88

99
PHP must be installed on the system prior to running this role (suggested role: `geerlingguy.php`).
1010

11+
Global composer installation requires Composer to also be installed on the system (suggested role: `geerlingguy.composer`).
12+
1113
Source installation additionally requires Git and Composer to also be installed on the system (suggested roles: `geerlingguy.git` and `geerlingguy.composer`).
1214

1315
## Role Variables
1416

1517
Available variables are listed below, along with default values (see `defaults/main.yml`):
1618

17-
drush_phar_url: https://github.com/drush-ops/drush/releases/download/8.1.10/drush.phar
19+
### Drush Launcher
20+
21+
[Drush Launcher](https://github.com/drush-ops/drush-launcher) is a small wrapper around Drush for your global `$PATH`.
22+
23+
It is the recommended way to use `drush`, but there are some situations where you might wish to install and run Drush globally without using Drush Launcher. The following variables control Drush Launcher's installation:
24+
25+
drush_launcher_install: yes
26+
27+
Set to `no` if you don't want the launcher installed.
1828

19-
The URL from which the Drush phar file will be downloaded.
29+
drush_launcher_version: "0.5.1"
2030

21-
drush_path: /usr/local/bin/drush
31+
The version of the Drush Launcher to install. This should exactly match an available [Drush Launcher release](https://github.com/drush-ops/drush-launcher/releases).
32+
33+
drush_launcher_phar_url: https://github.com/drush-ops/drush-launcher/releases/download/{{ drush_launcher_version }}/drush.phar
34+
35+
The URL from which the Drush Launcher phar file will be downloaded.
36+
37+
drush_launcher_path: /usr/local/bin/drush
2238

2339
The path where drush will be installed and available to your system. Should be in your user's `$PATH` so you can run commands simply with `drush` instead of the full path.
2440

25-
drush_config: ~/.drush
41+
### Drush global install via Composer
2642

27-
Path to the directory where Drush will store its generated config.
43+
Some people need to have the full power of `drush` available globally, and this role allows the global install of Drush via Composer. If using this option, make sure you have Composer installed!
2844

29-
drush_install_from_source: no
45+
drush_composer_global_install: no
3046

31-
Whether to use Git and Composer to install Drush from source.
47+
Set to `yes` (and set `drush_launcher_install` to `no`) if you want to install `drush` globally using Composer.
3248

33-
drush_version: 8.1.10
49+
drush_composer_version: "~9.0"
3450

35-
The version of Drush to download (examples: `8.1.10`, `8.1.9`). This should exactly match an available [Drush release](https://github.com/drush-ops/drush/releases). Note that setting `drush_install_from_source` to `yes` changes the possible values for `drush_version`--see below for more information.
51+
The version constraint for the global Drush installation.
52+
53+
drush_composer_update: no
54+
55+
Whether to run `composer update drush/drush` to ensure the version of Drush installed globally is the latest version.
56+
57+
drush_composer_path: /usr/local/bin/drush
58+
59+
The path in which a symlink to the Drush binary installed via Composer should be placed.
60+
61+
> NOTE: Composer 'global' installation is global _to the user under which Drush is installed_—e.g. if you install globally using the root user, `drush` will only work properly as `root` or when using `sudo`.
3662
3763
### Variables used for source install (Git).
3864

39-
drush_install_path: /usr/local/share/drush
65+
You can also install Drush from source if you need a bleeding-edge release, or if you need a specific version which can't be installed via Composer.
66+
67+
drush_install_from_source: no
68+
69+
Set to `yes` (and set `drush_launcher_install` to `no`) if you want to install `drush` globally using the Drush source code.
70+
71+
drush_source_install_bin_path: /usr/local/bin/drush
72+
drush_source_install_path: /usr/local/share/drush
4073

4174
The location of the entire drush installation (includes all the supporting files, as well as the `drush` executable file.
4275

43-
drush_version: "master"
76+
drush_source_install_version: "8.x"
4477

45-
The version of Drush to install (examples: `"master"` for the bleeding edge, `"7.x"`, `"6.x"`, `"6.2.0"`). This should be a string as it refers to a git branch, tag, or commit hash.
78+
The version of Drush to install (examples: `"master"` for the bleeding edge, `"8.x"`, `"7.x"`, `"6.2.0"`). This should be a string as it refers to a git branch, tag, or commit hash.
4679

4780
drush_keep_updated: no
4881
drush_force_update: no
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
---
2-
# Install from phar (faster, but less flexible).
3-
drush_version: "8.1.15"
4-
drush_phar_url: https://github.com/drush-ops/drush/releases/download/{{ drush_version }}/drush.phar
5-
drush_path: /usr/local/bin/drush
2+
# Install Drush Launcher.
3+
drush_launcher_install: yes
4+
drush_launcher_version: "0.5.1"
5+
drush_launcher_phar_url: https://github.com/drush-ops/drush-launcher/releases/download/{{ drush_launcher_version }}/drush.phar
6+
drush_launcher_path: /usr/local/bin/drush
7+
8+
# Install Drush via Composer globally.
9+
drush_composer_global_install: no
10+
drush_composer_version: "~9.0"
11+
drush_composer_update: no
12+
drush_composer_path: /usr/local/bin/drush
613

714
# Install from source (git clone + composer-based install).
815
drush_install_from_source: no
9-
drush_install_path: /usr/local/share/drush
10-
# drush_version: "master"
16+
drush_source_install_bin_path: /usr/local/bin/drush
17+
drush_source_install_path: /usr/local/share/drush
18+
drush_source_install_version: "8.x"
1119
drush_keep_updated: no
1220
drush_force_update: no
1321
drush_force_composer_install: no
14-
1522
drush_composer_cli_options: "--prefer-dist --no-interaction"
1623
drush_clone_depth: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
- name: Ensure Drush is installed globally via Composer.
3+
composer:
4+
command: require
5+
global_command: yes
6+
arguments: "drush/drush:{{ drush_composer_version }}"
7+
register: drush_composer_require
8+
9+
- name: Update global Drush install if configured.
10+
composer:
11+
command: update
12+
global_command: yes
13+
arguments: "drush/drush --with-dependencies"
14+
when:
15+
- drush_composer_update
16+
- not drush_composer_require.changed
17+
18+
- name: Ensure globally-installed Drush is symlinked into bin dir.
19+
file:
20+
src: "~/.composer/vendor/bin/drush"
21+
dest: "{{ drush_composer_path }}"
22+
state: link
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
---
22
- name: Check current state.
33
stat:
4-
path: "{{ drush_path }}"
4+
path: "{{ drush_launcher_path }}"
55
register: drush_path_state
66

77
- name: Perform cleanup of old symlink.
88
file:
9-
path: "{{ drush_path }}"
9+
path: "{{ drush_launcher_path }}"
1010
state: absent
1111
when: drush_path_state.stat.islnk is defined and drush_path_state.stat.islnk
1212

1313
- name: Ensure Drush path directory exists.
1414
file:
15-
path: "{{ drush_path | dirname }}"
15+
path: "{{ drush_launcher_path | dirname }}"
1616
state: directory
1717
mode: 0755
1818

1919
- name: Install Drush.
2020
get_url:
21-
url: "{{ drush_phar_url }}"
22-
dest: "{{ drush_path }}"
21+
url: "{{ drush_launcher_phar_url }}"
22+
dest: "{{ drush_launcher_path }}"
2323

2424
- name: Ensure Drush is executable.
2525
file:
26-
path: "{{ drush_path }}"
26+
path: "{{ drush_launcher_path }}"
2727
mode: 0755

provisioning/roles/geerlingguy.drush/tasks/source-install.yml provisioning/roles/geerlingguy.drush/tasks/install-source.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22
- name: Clone Drush from GitHub.
33
git:
44
repo: https://github.com/drush-ops/drush.git
5-
dest: "{{ drush_install_path }}"
6-
version: "{{ drush_version }}"
5+
dest: "{{ drush_source_install_path }}"
6+
version: "{{ drush_source_install_version }}"
77
update: "{{ drush_keep_updated }}"
88
force: "{{ drush_force_update }}"
99
depth: "{{ drush_clone_depth }}"
1010
register: drush_clone
1111

1212
- name: Check for composer.json
13-
stat: path={{ drush_install_path }}/composer.json
13+
stat: path={{ drush_source_install_path }}/composer.json
1414
register: drush_composer
1515

1616
# See: https://github.com/geerlingguy/ansible-role-drush/issues/6
1717
- name: Ensure Drush can be installed on Debian Wheezy.
1818
shell: >
1919
{{ composer_path }} update {{ drush_composer_cli_options }}
20-
chdir={{ drush_install_path }}
20+
chdir={{ drush_source_install_path }}
2121
when: drush_clone.changed and ansible_distribution == "Debian" and ansible_distribution_release == "wheezy" and drush_composer.stat.exists
2222

2323
- name: Install Drush dependencies with Composer.
2424
shell: >
2525
{{ composer_path }} install {{ drush_composer_cli_options }}
26-
chdir={{ drush_install_path }}
26+
chdir={{ drush_source_install_path }}
2727
when: (drush_clone.changed and drush_composer.stat.exists) or drush_force_composer_install
2828

2929
- name: Create drush symlink.
3030
file:
31-
src: "{{ drush_install_path }}/drush"
32-
dest: "{{ drush_path }}"
31+
src: "{{ drush_source_install_path }}/drush"
32+
dest: "{{ drush_source_install_bin_path }}"
3333
state: link
3434
force: yes
3535

3636
- name: Run drush to finish setting it up.
37-
command: "{{ drush_path }}"
37+
command: "{{ drush_source_install_bin_path }}"
3838
register: drush_result
3939
changed_when: "'Execute a drush command' not in drush_result.stdout"
4040
become: no
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
2-
- include: install.yml
3-
when: not drush_install_from_source
2+
- include: install-drush-launcher.yml
3+
when: drush_launcher_install
44

5-
- include: source-install.yml
5+
- include: install-drush-composer.yml
6+
when: drush_composer_global_install
7+
8+
- include: install-source.yml
69
when: drush_install_from_source
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
- hosts: all
3+
4+
vars:
5+
php_enable_webserver: false
6+
php_opcache_enable: "0"
7+
8+
# Use Composer global install.
9+
drush_launcher_install: no
10+
drush_composer_global_install: yes
11+
drush_composer_update: yes
12+
13+
pre_tasks:
14+
- name: Enable remi repo for PHP 7.0 (RedHat).
15+
set_fact: php_enablerepo="remi,remi-php70"
16+
when: ansible_os_family == 'RedHat'
17+
18+
- name: Update apt cache.
19+
apt: update_cache=yes cache_valid_time=600
20+
when: ansible_os_family == 'Debian'
21+
22+
- name: Ensure unzip is installed.
23+
package: name=unzip state=present
24+
25+
# Debian-specific tasks.
26+
- name: Add dependencies for PHP versions (Debian).
27+
apt:
28+
name: "{{ item }}"
29+
with_items:
30+
- apt-transport-https
31+
- ca-certificates
32+
when: ansible_distribution == "Debian"
33+
34+
- name: Add Ondrej Sury's apt key (Debian).
35+
apt_key:
36+
url: https://packages.sury.org/php/apt.gpg
37+
state: present
38+
when: ansible_distribution == "Debian"
39+
40+
- name: Add Ondrej Sury's repo (Debian).
41+
apt_repository:
42+
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
43+
state: present
44+
register: php_ondrej_debian_repo
45+
when: ansible_distribution == "Debian"
46+
47+
- name: Update apt caches after repo is added (Debian).
48+
apt: update_cache=yes
49+
when: php_ondrej_debian_repo.changed and (ansible_distribution == "Debian")
50+
51+
roles:
52+
- role: geerlingguy.repo-remi
53+
when: ansible_os_family == 'RedHat'
54+
- geerlingguy.php
55+
- geerlingguy.composer
56+
- role_under_test

provisioning/roles/geerlingguy.drush/tests/test-source-install.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
vars:
55
php_enable_webserver: false
66
php_opcache_enable: "0"
7+
drush_launcher_install: no
8+
drush_composer_global_install: no
79
drush_install_from_source: yes
810

911
pre_tasks:

provisioning/roles/geerlingguy.drush/tests/test.yml

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
apt: update_cache=yes cache_valid_time=600
1515
when: ansible_os_family == 'Debian'
1616

17+
- name: Ensure unzip is installed.
18+
package: name=unzip state=present
19+
1720
# Debian-specific tasks.
1821
- name: Add dependencies for PHP versions (Debian).
1922
apt:
@@ -44,4 +47,5 @@
4447
- role: geerlingguy.repo-remi
4548
when: ansible_os_family == 'RedHat'
4649
- geerlingguy.php
50+
- geerlingguy.composer
4751
- role_under_test

0 commit comments

Comments
 (0)