Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,52 @@ language: generic
sudo: required

env:
DOCKER_COMPOSE_VERSION: 1.16.1
global:
- DOCKER_CACHE_DIR=$HOME/docker
- DOCKER_COMPOSE_VERSION=1.26.2
- ANSIBLE_VERSION=2.9.9
jobs:
- PLATFORM=centos PLAYBOOK=user.yml
- PLATFORM=debian PLAYBOOK=user.yml
- PLATFORM=ubuntu PLAYBOOK=user.yml
- PLATFORM=centos PLAYBOOK=root.yml
- PLATFORM=debian PLAYBOOK=root.yml
- PLATFORM=ubuntu PLAYBOOK=root.yml

services:
- docker

cache:
pip: true
directories:
- $HOME/docker
- $DOCKER_CACHE_DIR

before_install:
- if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
- set -e # Let's fail fast (as Travis CI doesn't by default, see travis-ci/travis-ci#1066)
- if [[ -d $DOCKER_CACHE_DIR ]]; then ls $DOCKER_CACHE_DIR/tests_$PLATFORM*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

install:
- sudo pip install ansible==2.4.6.0 > /dev/null 2>&1
- sudo pip install ansible==$ANSIBLE_VERSION > /dev/null 2>&1

script:
- cd tests
- docker-compose up -d
- ansible-playbook user.yml -l centos
- ansible-playbook user.yml -l debian
- ansible-playbook user.yml -l ubuntu
- docker-compose config --services | grep $PLATFORM | xargs docker-compose up -d
- ansible-playbook $PLAYBOOK -l $PLATFORM

before_cache:
# Put docker images used during this run into travis cache (if not already cached).
# Tarballs are named after the pattern <docker-repository>-<docker-image-id>.tar.gz,
# to allow "filtering" by platform type (e.g. only import debian images from cache).
- >
mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
| xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz'
mkdir -p $DOCKER_CACHE_DIR && docker images -a --filter='dangling=false' --format '{{.Repository}} {{.ID}}' "tests_$PLATFORM*"
| xargs -n 2 -t sh -c 'test -e $DOCKER_CACHE_DIR/$0-$1.tar.gz || docker save $0 | gzip -2 > $DOCKER_CACHE_DIR/$0-$1.tar.gz'
# Show cache usage details (useful to know if a cache cleanup is needed)
- du -hs $DOCKER_CACHE_DIR/*
Comment thread
thbar marked this conversation as resolved.
- du -hs $DOCKER_CACHE_DIR

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
24 changes: 20 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,31 @@

### NEXT

* Fixes bare variables in conditionals (deprecation warnings with Ansible 2.8+) (#204)
#### New features

* Report when Ruby is removed and don't ignore when version listing fails (#212)

#### Bug fixes

* Fix bare variables in conditionals (deprecation warnings with Ansible 2.8+) (#204)
* Fix boolean values when checking array (#207)
* Fixes regression forbidding installation of rubies (#209, fixed via #207)
* Fix regression forbidding installation of rubies (#209, fixed via #207)
* Fix conditional logic for detecting and removing versions of Ruby (#212)
* Report when Ruby is removed and don't ignore when version listing fails (#212)

#### Changes

* Extend test matrix with: (#215)
* CentOS 8, Debian 10, Ubuntu 18.04 and 20.04
* Ruby 2.6.6 and 2.7.1
* Modify some test assertions to better abstract RVM behaviour from its internal implementation ("blackbox" testing) (#205)
* Fix and enhance Travis CI setup (#205)
* Install more recent versions of Ruby, to be compatible with latest Bundler version
* Validate system-wide setup (root.yml)
* Parallelize the tests to speed up the builds
Comment thread
gildegoma marked this conversation as resolved.

### 2.1.2
2018-12-28 &middot; [Changes](https://github.com/rvm/rvm1-ansible/compare/v2.1.1...v2.1.2)
)

* Fallback to alternative GPG key servers (#192)
* Remove keys.gnupg.net in favour of pool.sks-keyservers.net (#192)

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ Just add `--extra-vars 'rvm1_delete_ruby=ruby-2.1.0'` to the end of your play bo

## Requirements

- Tested on CentOS 6 and 7
- Tested on Debian 8 and 9
- Tested on Ubuntu 14.04 and 16.04
Potentially, any Linux/Unix system supported by Ansible and satisfying the [RVM prerequisites](https://rvm.io/rvm/prerequisites) should work.

Compatibility with Linux distributions based on Debian, Ubuntu or Redhat families is actively tested.

The continuous integration setup of this project currently covers following platforms:
- CentOS 6, 7 and 8
- Debian 8, 9 and 10
- Ubuntu 14.04, 16.04, 18.04 and 20.04

## Ansible galaxy

Expand Down
51 changes: 34 additions & 17 deletions tests/assertions.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
---
- name: Check that ruby exists
shell: . $HOME/.bash_profile && ruby -v | cut -c1-4
args:
executable: /bin/bash
register: check_ruby
- name: Check default ruby version
shell:
cmd: bash -lc 'ruby -v | cut -c1-10'
register: check_ruby_default
changed_when: false
- assert:
that:
- check_ruby.stdout == 'ruby'
- check_ruby.rc == 0
msg: No ruby installed
- check_ruby_default.stdout == 'ruby {{ rvm_tests_mri_version_default }}'
- check_ruby_default.rc == 0
msg: Default ruby version is wrong

- name: Check default ruby
shell: ~/.rvm/wrappers/default/ruby -v | cut -c1-10
register: check_ruby_default
- name: Check that rvm is in use
shell:
cmd: bash -lc 'which ruby'
register: check_rvm_loaded
changed_when: false
- assert:
that:
- check_ruby_default.stdout == 'ruby 2.3.1'
msg: No default ruby installed
- check_rvm_loaded.stdout == '{{ rvm1_install_path }}/rubies/ruby-{{ rvm_tests_mri_version_default }}/bin/ruby'
- check_rvm_loaded.rc == 0
msg: Default ruby is in the wrong path

- name: Check multiple rubies
command: ls ~/.rvm/rubies
command:
cmd: bash -lc 'rvm list strings'
register: check_ruby_multiple
changed_when: false
- assert:
that:
- "'ruby-2.2.5' in check_ruby_multiple.stdout"
- "'ruby-2.3.1' in check_ruby_multiple.stdout"
- "'ruby-{{ rvm_tests_mri_version_other }}' in check_ruby_multiple.stdout"
- "'ruby-{{ rvm_tests_mri_version_default }}' in check_ruby_multiple.stdout"
- check_ruby_multiple.rc == 0
msg: No multiple rubies installed

- name: Check ruby switch
command:
cmd: bash -lc 'rvm use {{ rvm_tests_mri_version_other }} && ruby -v | cut -c1-10'
register: check_ruby_switch
changed_when: false
- assert:
that:
- "'Using {{ rvm1_install_path }}/gems/ruby-{{ rvm_tests_mri_version_other }}' in check_ruby_switch.stdout"
- "'ruby {{ rvm_tests_mri_version_other }}' in check_ruby_switch.stdout"
- check_ruby_switch.rc == 0
msg: Failed to switch the ruby version

- name: Check bundler symlinked on system path
shell: ls ~/.rvm/wrappers/default/ |grep 'bundler'
shell:
cmd: ls wrappers/default/ | grep 'bundler'
chdir: "{{ rvm1_install_path }}"
register: check_ruby_bundler
changed_when: false
- assert:
Expand Down
33 changes: 21 additions & 12 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
version: "3"
services:

centos6:
build: ./dockerfiles/centos6
cap_add:
- ALL
cap_add: [ALL]
centos7:
build: ./dockerfiles/centos7
cap_add:
- ALL
cap_add: [ALL]
centos8:
build: ./dockerfiles/centos8
cap_add: [ALL]

debian8:
build: ./dockerfiles/debian8
cap_add:
- ALL
cap_add: [ALL]
debian9:
build: ./dockerfiles/debian9
cap_add:
- ALL
cap_add: [ALL]
debian10:
build: ./dockerfiles/debian10
cap_add: [ALL]

ubuntu14:
build: ./dockerfiles/ubuntu14
cap_add:
- ALL
cap_add: [ALL]
ubuntu16:
build: ./dockerfiles/ubuntu16
cap_add:
- ALL
cap_add: [ALL]
ubuntu18:
build: ./dockerfiles/ubuntu18
cap_add: [ALL]
ubuntu20:
build: ./dockerfiles/ubuntu20
cap_add: [ALL]
12 changes: 12 additions & 0 deletions tests/dockerfiles/centos8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM centos:8

RUN yum update -y \
&& yum install -y \
sudo \
which \
&& yum clean all

RUN useradd -ms /bin/bash user && \
echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

CMD ["/usr/sbin/init"]
17 changes: 17 additions & 0 deletions tests/dockerfiles/debian10/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM debian:10

RUN apt-get update \
&& apt-get install -y \
curl \
gpg \
procps \
python \
sudo \
systemd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN useradd -ms /bin/bash user && \
echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

CMD ["/lib/systemd/systemd"]
16 changes: 16 additions & 0 deletions tests/dockerfiles/ubuntu18/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:18.04

RUN apt-get update \
&& apt-get install -y \
curl \
gpg \
python \
sudo \
systemd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN useradd -ms /bin/bash user && \
echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

CMD ["/lib/systemd/systemd"]
16 changes: 16 additions & 0 deletions tests/dockerfiles/ubuntu20/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM ubuntu:20.04

RUN apt-get update \
&& apt-get install -y \
curl \
gpg \
python \
sudo \
systemd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN useradd -ms /bin/bash user && \
echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

CMD ["/lib/systemd/systemd"]
7 changes: 7 additions & 0 deletions tests/group_vars/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
rvm_tests_mri_version_default: 2.7.1
rvm_tests_mri_version_other: 2.6.6

# Upcoming
# rvm_tests_jruby_version_x: 9.2.12.0
# ...
6 changes: 6 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[centos]
tests_centos6_1 ansible_connection=docker
tests_centos7_1 ansible_connection=docker
tests_centos8_1 ansible_connection=docker

[debian]
tests_debian8_1 ansible_connection=docker
tests_debian9_1 ansible_connection=docker
tests_debian10_1 ansible_connection=docker

[ubuntu]
tests_ubuntu14_1 ansible_connection=docker
tests_ubuntu16_1 ansible_connection=docker
tests_ubuntu18_1 ansible_connection=docker
tests_ubuntu20_1 ansible_connection=docker
22 changes: 13 additions & 9 deletions tests/root.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
---
- hosts: all
- name: RVM System Wide Setup
hosts: all
gather_facts: false
vars:
rvm1_user: root
rvm1_install_flags: '--auto-dotfiles'
rvm1_install_path: '/home/{{ rvm1_user }}/.rvm'
rvm1_install_path: '/opt/rvm'
rvm1_rubies:
- 'ruby-2.2.5'
- 'ruby-2.3.1'
- 'ruby-{{ rvm_tests_mri_version_other }}'
- 'ruby-{{ rvm_tests_mri_version_default }}'
roles:
- role: rvm1-ansible
- rvm1-ansible
tags: setup

# Asserts tasks
- hosts: all
- name: RVM Setup Validation
hosts: all
gather_facts: false
vars:
rvm1_install_path: '/opt/rvm'
tasks:
- name: Assert tasks
import_tasks: assertions.yml
- import_tasks: assertions.yml
tags: validate
18 changes: 11 additions & 7 deletions tests/user.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
---
- hosts: all
- name: RVM Single User Setup
hosts: all
gather_facts: false
remote_user: user
vars:
rvm1_user: user
rvm1_install_path: '/home/{{ rvm1_user }}/.rvm'
rvm1_rubies:
- 'ruby-2.2.5'
- 'ruby-2.3.1'
- 'ruby-{{ rvm_tests_mri_version_other }}'
- 'ruby-{{ rvm_tests_mri_version_default }}'
roles:
- role: rvm1-ansible
become: yes
tags: setup

# Asserts tasks
- hosts: all
- name: RVM Setup Validation
hosts: all
gather_facts: false
remote_user: user
vars:
rvm1_install_path: '/home/user/.rvm'
tasks:
- name: Assert tasks
import_tasks: assertions.yml
- import_tasks: assertions.yml
tags: validate