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

Commit d763594

Browse files
committed
Fixes #1539: Update drush role so it works correctly on Debian 8 and 9.
1 parent 1a51bed commit d763594

File tree

10 files changed

+89
-33
lines changed

10 files changed

+89
-33
lines changed

default.config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ extra_packages:
234234
- sqlite
235235

236236
# You can configure almost anything else on the server in the rest of this file.
237-
drush_version: "8.1.14"
237+
drush_version: "8.1.15"
238238

239239
extra_security_enabled: false
240240

provisioning/requirements.yml

Lines changed: 1 addition & 1 deletion
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.1
25+
version: 2.0.2
2626
- src: geerlingguy.elasticsearch
2727
version: 2.1.3
2828
- src: geerlingguy.firewall
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.retry
2+
tests/test.sh

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

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,31 @@ services: docker
44
env:
55
# Normal installation.
66
- distro: centos7
7-
init: /usr/lib/systemd/systemd
8-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
97
playbook: test.yml
108
- distro: ubuntu1604
11-
init: /lib/systemd/systemd
12-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
9+
playbook: test.yml
10+
- distro: debian8
11+
playbook: test.yml
12+
- distro: debian9
1313
playbook: test.yml
1414
# Install from source.
1515
- distro: centos7
16-
init: /usr/lib/systemd/systemd
17-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1816
playbook: test-source-install.yml
1917

20-
before_install:
21-
# Pull container.
22-
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
23-
2418
script:
25-
- container_id=$(mktemp)
26-
# Run container in detached state.
27-
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
28-
29-
# Install dependencies.
30-
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
31-
32-
# Ansible syntax check.
33-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
19+
# Configure test script so we can run extra tests after playbook is run.
20+
- export container_id=$(date +%s)
21+
- export cleanup=false
3422

35-
# Test role.
36-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook}'
23+
# Download test shim.
24+
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
25+
- chmod +x ${PWD}/tests/test.sh
3726

38-
# Test role idempotence.
39-
- idempotence=$(mktemp)
40-
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} | tee -a ${idempotence}
41-
- >
42-
tail ${idempotence}
43-
| grep -q 'changed=0.*failed=0'
44-
&& (echo 'Idempotence test: pass' && exit 0)
45-
|| (echo 'Idempotence test: fail' && exit 1)
27+
# Run tests.
28+
- ${PWD}/tests/test.sh
4629

4730
# Test Drush.
48-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm drush --version || true'
31+
- 'docker exec --tty ${container_id} env TERM=xterm drush --version || true'
4932

5033
notifications:
5134
webhooks: https://galaxy.ansible.com/api/v1/notifications/
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Jeff Geerling
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

provisioning/roles/geerlingguy.drush/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ The path where drush will be installed and available to your system. Should be i
2626

2727
Path to the directory where Drush will store its generated config.
2828

29+
drush_install_from_source: no
30+
31+
Whether to use Git and Composer to install Drush from source.
32+
33+
drush_version: 8.1.10
34+
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.
36+
2937
### Variables used for source install (Git).
3038

3139
drush_install_path: /usr/local/share/drush

provisioning/roles/geerlingguy.drush/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# Install from phar (faster, but less flexible).
3-
drush_version: "8.1.10"
3+
drush_version: "8.1.15"
44
drush_phar_url: https://github.com/drush-ops/drush/releases/download/{{ drush_version }}/drush.phar
55
drush_path: /usr/local/bin/drush
66

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
state: absent
1111
when: drush_path_state.stat.islnk is defined and drush_path_state.stat.islnk
1212

13+
- name: Ensure Drush path directory exists.
14+
file:
15+
path: "{{ drush_path | dirname }}"
16+
state: directory
17+
mode: 0755
18+
1319
- name: Install Drush.
1420
get_url:
1521
url: "{{ drush_phar_url }}"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Ansible Role tests
2+
3+
To run the test playbook(s) in this directory:
4+
5+
1. Install and start Docker.
6+
1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
7+
- `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
8+
1. Make the test shim executable: `chmod +x tests/test.sh`.
9+
1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`
10+
11+
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,32 @@
1414
apt: update_cache=yes cache_valid_time=600
1515
when: ansible_os_family == 'Debian'
1616

17+
# Debian-specific tasks.
18+
- name: Add dependencies for PHP versions (Debian).
19+
apt:
20+
name: "{{ item }}"
21+
with_items:
22+
- apt-transport-https
23+
- ca-certificates
24+
when: ansible_distribution == "Debian"
25+
26+
- name: Add Ondrej Sury's apt key (Debian).
27+
apt_key:
28+
url: https://packages.sury.org/php/apt.gpg
29+
state: present
30+
when: ansible_distribution == "Debian"
31+
32+
- name: Add Ondrej Sury's repo (Debian).
33+
apt_repository:
34+
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
35+
state: present
36+
register: php_ondrej_debian_repo
37+
when: ansible_distribution == "Debian"
38+
39+
- name: Update apt caches after repo is added (Debian).
40+
apt: update_cache=yes
41+
when: php_ondrej_debian_repo.changed and (ansible_distribution == "Debian")
42+
1743
roles:
1844
- role: geerlingguy.repo-remi
1945
when: ansible_os_family == 'RedHat'

0 commit comments

Comments
 (0)