Skip to content

Commit

Permalink
Merge pull request #1 from Oefenweb/initial-working-version
Browse files Browse the repository at this point in the history
Initial working version
  • Loading branch information
tersmitten committed May 18, 2015
2 parents d0faaf0 + c4cfe45 commit d298671
Show file tree
Hide file tree
Showing 16 changed files with 249 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# IDE files #
#################
/.settings
/.buildpath
/.project
/nbproject
*.komodoproject
*.kpf
/.idea

# Vagrant files #
.vagrant/
vagrant_ansible_inventory_*
ansible.cfg

# Other files #
###############
!empty
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
language: python
python: "2.7"

env:
- ANSIBLE_VERSION=1.6
- ANSIBLE_VERSION=1.7
- ANSIBLE_VERSION=1.8

before_install:
- sudo apt-get update -qq

# Remove r-base
- sudo apt-get remove --purge r-base

install:
# Install Ansible.
- pip install ansible==$ANSIBLE_VERSION

# Add ansible.cfg to pick up roles path.
- printf "[defaults]\nroles_path = ../" > ansible.cfg

script:
# Check the role/playbook's syntax.
- ansible-playbook -i tests/inventory tests/test.yml --syntax-check

# Run the role/playbook with ansible-playbook.
- ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo -vvvv

# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Test r installation
- >
echo 'print(gsub("I","O","PING"))'
| r
| grep -q 'PONG'
&& (echo 'Availability test: pass' && exit 0)
|| (echo 'Availability test: fail' && exit 1)
notifications:
email: false
hipchat:
rooms:
secure: Bi7CmVmZYOvpZM1YRWLoG2bNf9+nbz5czkEZP/ttUaPPP+pJ6aoprvh3XQWO/s35h44IGCCs18n64p6Bch6E4piAjz3p+ihBFNd+gcUl77KEW706MoF6zHBL2jl5NVLnID8OL3Phw6dCVcv1b3mpsmNwVVQkUlplqPTVQAXcwfeWeKSYM05IoVUf2YNiDoBkfeUdlijgjfjdD+XG2nlj8SeBVxX7UzIcSCZ/dgpHbyRpwQqlUldgYqWj09UQFoiDspBmqtOwX1EqmvFfQmtMw1stBChnuCr7Lb7QrXsIMHAPFKS0URCPygwn58OkyS7PALpoB7Q/QkbwPTr5+ZQlv8HQ3qUOD7qw+znYJZp+a6tpqtbJZsqG4bwpH646vsDgrvLNn5OmQ4iHvgLGXQeZyuVkzSsFVBx9KuntPJdiMjpMkjFhx+h5a6LfTbfvYJYQJARjPIgOnoNbSqxjoOGKjQXvug3kaXflMOGXbDNw/loi07BS2Uxko4LybFS9XWifChFXSpSBGKCCuWnkRs/aXJWQ+GyLGoF1Uz0zFnUgtfSJzMZiaCVQHGXAm3jd7qmwyTc7t0MjxgrEk+GfVZksLzG/wpGTY2Gywft5YYPI20sAhJqQRwvF8cLyMKxDlq/+N9RP8+bixx0ARCzo2DFchBq2ck7h+ob6fV7wq2RkIZQ=
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## r

[![Build Status](https://travis-ci.org/Oefenweb/ansible-r.svg?branch=master)](https://travis-ci.org/Oefenweb/ansible-r) [![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-r-blue.svg)](https://galaxy.ansible.com/list#/roles/3831)

Set up the latest version of R in Ubuntu systems.

#### Requirements

None

#### Variables

* `r_cran mirror`: [default: `http://cran.rstudio.com/`]: Your favorite [CRAN mirror](http://cran.r-project.org/mirrors.html)
* `r_install_dev`: [default: `false`]: Whether or not install the `r-base-dev` package
* `r_install`: [default: `[]`]: Additional packages to install (e.g. `r-recommended`, `littler`)

## Dependencies

None

#### Example

```yaml
---
- hosts: all
roles:
- r
```
#### License
MIT
#### Author Information
Mischa ter Smitten
#### Feedback, bug-reports, requests, ...
Are [welcome](https://github.com/Oefenweb/ansible-r/issues)!
47 changes: 47 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- mode: ruby -*-
# vi: set ft=ruby ts=2 sw=2 tw=0 et :

role = File.basename(File.expand_path(File.dirname(__FILE__)))

File.open(File.dirname(__FILE__) + '/ansible.cfg', 'w') { |f| f.write("[defaults]\nroles_path = ../") }

boxes = [
{
:name => "ubuntu-1204",
:box => "opscode-ubuntu-12.04",
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box",
:ip => '10.0.0.11',
:cpu => "50",
:ram => "256"
},
{
:name => "ubuntu-1404",
:box => "opscode-ubuntu-14.04",
:url => "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box",
:ip => '10.0.0.12',
:cpu => "50",
:ram => "256"
},
]

Vagrant.configure("2") do |config|
boxes.each do |box|
config.vm.define box[:name] do |vms|
vms.vm.box = box[:box]
vms.vm.box_url = box[:url]
vms.vm.hostname = "ansible-#{role}-#{box[:name]}"

vms.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]]
v.customize ["modifyvm", :id, "--memory", box[:ram]]
end

vms.vm.network :private_network, ip: box[:ip]

vms.vm.provision :ansible do |ansible|
ansible.playbook = "tests/vagrant.yml"
ansible.verbose = "vv"
end
end
end
end
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# defaults file for r
---
r_cran_mirror: http://cran.rstudio.com/
r_install_dev: false
r_install: []
Empty file added files/empty
Empty file.
2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# handlers file for r
---
16 changes: 16 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# meta file for r
---
galaxy_info:
author: Mischa ter Smitten
company: Oefenweb.nl B.V.
description: Set up the latest version of R in Ubuntu systems
license: MIT
min_ansible_version: 1.6
platforms:
- name: Ubuntu
versions:
- precise
- trusty
categories:
- system
dependencies: []
16 changes: 16 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# tasks file for r
---
- name: install dependencies
apt:
name: "{{ item }}"
state: latest
with_items: r_dependencies
when: "item | trim != ''"
tags: [configuration, r, r-dependencies]

- name: install
apt:
name: "{{ item }}"
state: latest
with_items: r_install
tags: [configuration, r, r-install]
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# tasks file for r
---
- include: repository.yml
- include: install.yml
16 changes: 16 additions & 0 deletions tasks/repository.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# tasks file for r
---
- name: add public key
apt_key:
id: E084DAB9
keyserver: keyserver.ubuntu.com
state: present
tags: [configuration, r, r-public-key]

- name: add cran-r repository
apt_repository:
repo: "{{ item.type }} {{ item.url }}"
state: present
update_cache: yes
with_items: r_repository
tags: [configuration, r, r-repository]
Empty file added templates/empty
Empty file.
1 change: 1 addition & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
9 changes: 9 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# test file for r
---
- hosts: localhost
remote_user: root
roles:
- ansible-r
vars:
r_install:
- littler
7 changes: 7 additions & 0 deletions tests/vagrant.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# test file for r
---
- hosts: all
remote_user: vagrant
sudo: true
roles:
- r
8 changes: 8 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# vars file for r
---
r_repository:
- type: deb
url: "{{ r_cran_mirror }}/bin/linux/ubuntu {{ ansible_distribution_release }}/"
r_dependencies:
- r-base
- "{{ 'r-base-dev' if r_install_dev else '' }}"

0 comments on commit d298671

Please sign in to comment.