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

Commit

Permalink
Fixes #1539: Update drush role so it works correctly on Debian 8 and 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Jan 26, 2018
1 parent 1a51bed commit d763594
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 33 deletions.
2 changes: 1 addition & 1 deletion default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ extra_packages:
- sqlite

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

extra_security_enabled: false

Expand Down
2 changes: 1 addition & 1 deletion provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- src: geerlingguy.drupal-console
version: 1.1.0
- src: geerlingguy.drush
version: 2.0.1
version: 2.0.2
- src: geerlingguy.elasticsearch
version: 2.1.3
- src: geerlingguy.firewall
Expand Down
2 changes: 2 additions & 0 deletions provisioning/roles/geerlingguy.drush/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.retry
tests/test.sh
43 changes: 13 additions & 30 deletions provisioning/roles/geerlingguy.drush/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,31 @@ services: docker
env:
# Normal installation.
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test.yml
- distro: debian8
playbook: test.yml
- distro: debian9
playbook: test.yml
# Install from source.
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
playbook: test-source-install.yml

before_install:
# Pull container.
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'

script:
- container_id=$(mktemp)
# Run container in detached state.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'

# Install dependencies.
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'

# Ansible syntax check.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
# Configure test script so we can run extra tests after playbook is run.
- export container_id=$(date +%s)
- export cleanup=false

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

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

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

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
20 changes: 20 additions & 0 deletions provisioning/roles/geerlingguy.drush/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2017 Jeff Geerling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions provisioning/roles/geerlingguy.drush/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ The path where drush will be installed and available to your system. Should be i

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

drush_install_from_source: no

Whether to use Git and Composer to install Drush from source.

drush_version: 8.1.10

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.

### Variables used for source install (Git).

drush_install_path: /usr/local/share/drush
Expand Down
2 changes: 1 addition & 1 deletion provisioning/roles/geerlingguy.drush/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Install from phar (faster, but less flexible).
drush_version: "8.1.10"
drush_version: "8.1.15"
drush_phar_url: https://github.com/drush-ops/drush/releases/download/{{ drush_version }}/drush.phar
drush_path: /usr/local/bin/drush

Expand Down
6 changes: 6 additions & 0 deletions provisioning/roles/geerlingguy.drush/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
state: absent
when: drush_path_state.stat.islnk is defined and drush_path_state.stat.islnk

- name: Ensure Drush path directory exists.
file:
path: "{{ drush_path | dirname }}"
state: directory
mode: 0755

- name: Install Drush.
get_url:
url: "{{ drush_phar_url }}"
Expand Down
11 changes: 11 additions & 0 deletions provisioning/roles/geerlingguy.drush/tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Ansible Role tests

To run the test playbook(s) in this directory:

1. Install and start Docker.
1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
- `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
1. Make the test shim executable: `chmod +x tests/test.sh`.
1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`

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)`
26 changes: 26 additions & 0 deletions provisioning/roles/geerlingguy.drush/tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'

# Debian-specific tasks.
- name: Add dependencies for PHP versions (Debian).
apt:
name: "{{ item }}"
with_items:
- apt-transport-https
- ca-certificates
when: ansible_distribution == "Debian"

- name: Add Ondrej Sury's apt key (Debian).
apt_key:
url: https://packages.sury.org/php/apt.gpg
state: present
when: ansible_distribution == "Debian"

- name: Add Ondrej Sury's repo (Debian).
apt_repository:
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
state: present
register: php_ondrej_debian_repo
when: ansible_distribution == "Debian"

- name: Update apt caches after repo is added (Debian).
apt: update_cache=yes
when: php_ondrej_debian_repo.changed and (ansible_distribution == "Debian")

roles:
- role: geerlingguy.repo-remi
when: ansible_os_family == 'RedHat'
Expand Down

0 comments on commit d763594

Please sign in to comment.