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

Commit 0cf2b0e

Browse files
committed
Update Ruby role to latest version.
1 parent 29c0647 commit 0cf2b0e

File tree

11 files changed

+86
-54
lines changed

11 files changed

+86
-54
lines changed

provisioning/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
- src: geerlingguy.repo-remi
7373
version: 1.2.0
7474
- src: geerlingguy.ruby
75-
version: 2.4.2
75+
version: 2.4.3
7676
- src: geerlingguy.security
7777
version: 1.5.0
7878
- src: geerlingguy.solr
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.ruby/.travis.yml

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,88 +4,64 @@ services: docker
44
env:
55
# Package install on all OSes.
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
ruby_version: 2.0.0
119
ruby_path_prefix: /usr
1210
- distro: ubuntu1604
13-
init: /lib/systemd/systemd
14-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1511
playbook: test.yml
1612
ruby_version: 2.3.1
1713
ruby_path_prefix: /usr
1814
- distro: ubuntu1404
19-
init: /sbin/init
20-
run_opts: ""
2115
playbook: test.yml
2216
ruby_version: 1.9.3
2317
ruby_path_prefix: /usr
2418
- distro: debian8
25-
init: /lib/systemd/systemd
26-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
2719
playbook: test.yml
2820
ruby_version: 2.1.5
2921
ruby_path_prefix: /usr
3022

3123
# Source install on latest OSes.
3224
- distro: centos7
33-
init: /usr/lib/systemd/systemd
34-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
3525
playbook: test-source.yml
3626
ruby_version: 2.3.0
3727
ruby_path_prefix: /usr/local
3828
- distro: ubuntu1604
39-
init: /lib/systemd/systemd
40-
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
4129
playbook: test-source.yml
4230
ruby_version: 2.3.0
4331
ruby_path_prefix: /usr/local
4432

45-
before_install:
46-
# Pull container.
47-
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
48-
4933
script:
50-
- container_id=$(mktemp)
51-
# Run container in detached state.
52-
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
53-
54-
# Install dependencies.
55-
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
56-
57-
# Ansible syntax check.
58-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/${playbook} --syntax-check'
34+
# Configure test script so we can run extra tests after playbook is run.
35+
- export container_id=$(date +%s)
36+
- export cleanup=false
5937

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

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

7245
# Make sure ruby is installed and at the correct version.
73-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which ruby'
74-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm test -x ${ruby_path_prefix}/bin/ruby'
46+
- 'docker exec --tty ${container_id} env TERM=xterm which ruby'
47+
- 'docker exec --tty ${container_id} env TERM=xterm test -x ${ruby_path_prefix}/bin/ruby'
7548

76-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ruby --version'
77-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ${ruby_path_prefix}/bin/ruby --version | grep -qF ${ruby_version}'
49+
- 'docker exec --tty ${container_id} env TERM=xterm ruby --version'
50+
- 'docker exec --tty ${container_id} env TERM=xterm ${ruby_path_prefix}/bin/ruby --version | grep -qF ${ruby_version}'
7851

7952
# Make sure bundler is installed.
80-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ls -lah /usr/local/bin'
81-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which bundle'
53+
- 'docker exec --tty ${container_id} env TERM=xterm ls -lah /usr/local/bin'
54+
- 'docker exec --tty ${container_id} env TERM=xterm which bundle'
8255

8356
# Make sure user installed gems are available.
84-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm bash --login -c "which sass"'
57+
- |
58+
if [ "${distro}" != "ubuntu1404" ]; then
59+
docker exec --tty ${container_id} env TERM=xterm bash --login -c "which sass"
60+
fi
8561
8662
after_failure:
87-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm which ruby'
88-
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ruby --version'
63+
- 'docker exec --tty ${container_id} env TERM=xterm which ruby'
64+
- 'docker exec --tty ${container_id} env TERM=xterm ruby --version'
8965

9066
notifications:
9167
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.ruby/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ MIT / BSD
6060

6161
## Author Information
6262

63-
This role was created in 2014 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
63+
This role was created in 2014 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ ruby_install_gems_user: "{{ ansible_user }}"
1313
# If set to TRUE, ruby will be installed from source, using the version set with
1414
# the 'ruby_version' variable instead of using a package.
1515
ruby_install_from_source: false
16-
ruby_download_url: http://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz
17-
ruby_version: 2.3.0
16+
ruby_download_url: http://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz
17+
ruby_version: 2.4.1
1818

1919
# Default should usually work, but this will be overridden on Ubuntu 14.04.
2020
ruby_rubygems_package_name: rubygems

provisioning/roles/geerlingguy.ruby/tasks/main.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
22
# Include OS-specific installation tasks.
33
- include: setup-RedHat.yml
4-
when: (ruby_install_from_source == false) and (ansible_os_family == 'RedHat')
4+
when:
5+
- ruby_install_from_source == False
6+
- ansible_os_family == 'RedHat'
57

68
- include: setup-Debian.yml
7-
when: (ruby_install_from_source == false) and (ansible_os_family == 'Debian')
9+
when:
10+
- ruby_install_from_source == False
11+
- ansible_os_family == 'Debian'
812

913
# Install ruby from source when ruby_install_from_source is true.
1014
- include: install-from-source.yml
11-
when: ruby_install_from_source == true
15+
when: ruby_install_from_source == True
1216

1317
- name: Add user installed RubyGems bin directory to global $PATH.
1418
copy:
@@ -22,7 +26,9 @@
2226
when: ruby_install_bundler
2327

2428
- name: Install configured gems.
25-
gem: "name={{ item }} state=present"
29+
gem:
30+
name: "{{ item }}"
31+
state: present
2632
become: yes
2733
become_user: "{{ ruby_install_gems_user }}"
2834
with_items: "{{ ruby_install_gems }}"

provisioning/roles/geerlingguy.ruby/tasks/setup-Debian.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
ruby_rubygems_package_name: rubygems-integration
88
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'trusty'
99

10-
- name: Install ruby and rubygems.
10+
- name: Install ruby, rubygems, and build-essential.
1111
apt: "name={{ item }} state=present"
1212
with_items:
1313
- ruby-full
14+
- ruby-dev
1415
- "{{ ruby_rubygems_package_name }}"
16+
- build-essential
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2-
- name: Install ruby and rubygems.
2+
- name: Install ruby, rubygems, and development tools.
33
yum: "name={{ item }} state=present"
44
with_items:
55
- ruby
6+
- ruby-devel
67
- "{{ ruby_rubygems_package_name }}"
8+
- '@development'
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)`

0 commit comments

Comments
 (0)