diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..95cb42b --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bd161d7 --- /dev/null +++ b/.travis.yml @@ -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= diff --git a/README.md b/README.md new file mode 100644 index 0000000..42ef518 --- /dev/null +++ b/README.md @@ -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)! diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..19b766b --- /dev/null +++ b/Vagrantfile @@ -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 diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..6b6cfdf --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +# defaults file for r +--- +r_cran_mirror: http://cran.rstudio.com/ +r_install_dev: false +r_install: [] diff --git a/files/empty b/files/empty new file mode 100644 index 0000000..e69de29 diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..35c0ab3 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +# handlers file for r +--- diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..114e434 --- /dev/null +++ b/meta/main.yml @@ -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: [] diff --git a/tasks/install.yml b/tasks/install.yml new file mode 100644 index 0000000..0dd7502 --- /dev/null +++ b/tasks/install.yml @@ -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] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..d051cc9 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,4 @@ +# tasks file for r +--- +- include: repository.yml +- include: install.yml diff --git a/tasks/repository.yml b/tasks/repository.yml new file mode 100644 index 0000000..43c1815 --- /dev/null +++ b/tasks/repository.yml @@ -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] diff --git a/templates/empty b/templates/empty new file mode 100644 index 0000000..e69de29 diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..68f8b6b --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,9 @@ +# test file for r +--- +- hosts: localhost + remote_user: root + roles: + - ansible-r + vars: + r_install: + - littler diff --git a/tests/vagrant.yml b/tests/vagrant.yml new file mode 100644 index 0000000..1f43d46 --- /dev/null +++ b/tests/vagrant.yml @@ -0,0 +1,7 @@ +# test file for r +--- +- hosts: all + remote_user: vagrant + sudo: true + roles: + - r diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..17c6309 --- /dev/null +++ b/vars/main.yml @@ -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 '' }}"