From a4a75ea60c17ec4da140d438a5fd44129177ae9e Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:00:23 +0200 Subject: [PATCH 1/7] Initial working version --- .gitignore | 29 +++++++++++++++++++++++++++ .travis.yml | 40 +++++++++++++++++++++++++++++++++++++ README.md | 40 +++++++++++++++++++++++++++++++++++++ Vagrantfile | 47 ++++++++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 7 +++++++ files/empty | 0 handlers/main.yml | 2 ++ meta/main.yml | 16 +++++++++++++++ tasks/install.yml | 16 +++++++++++++++ tasks/main.yml | 4 ++++ tasks/repository.yml | 16 +++++++++++++++ templates/empty | 0 tests/inventory | 1 + tests/test.yml | 6 ++++++ tests/vagrant.yml | 7 +++++++ vars/main.yml | 9 +++++++++ 16 files changed, 240 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 README.md create mode 100644 Vagrantfile create mode 100644 defaults/main.yml create mode 100644 files/empty create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/install.yml create mode 100644 tasks/main.yml create mode 100644 tasks/repository.yml create mode 100644 templates/empty create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 tests/vagrant.yml create mode 100644 vars/main.yml 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..18bef90 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +--- +language: python +python: "2.7" + +env: + - ANSIBLE_VERSION=1.4 + - ANSIBLE_VERSION=1.5 + - 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) + +notifications: + email: false 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..3a2ba0f --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,7 @@ +# 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..5ea8108 --- /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.4 + 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..25f4f2a --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,6 @@ +# test file for r +--- +- hosts: localhost + remote_user: root + roles: + - ansible-r 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..9e9f3f5 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,9 @@ +# vars file for r +--- +r_repository: + - type: deb + url: "{{ r_cran_mirror }}/bin/linux/ubuntu {{ ansible_lsb.codename }}/" + +r_dependencies: + - r-base + - "{{ 'r-base-dev' if r_install_dev else '' }}" From 20da28faf7e33784aa7eb800ea0aa44235331a08 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:02:59 +0200 Subject: [PATCH 2/7] Make use of ansible_distribution_release Debian 6010 is not supported anyway --- vars/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vars/main.yml b/vars/main.yml index 9e9f3f5..3d74358 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -2,7 +2,7 @@ --- r_repository: - type: deb - url: "{{ r_cran_mirror }}/bin/linux/ubuntu {{ ansible_lsb.codename }}/" + url: "{{ r_cran_mirror }}/bin/linux/ubuntu {{ ansible_distribution_release }}/" r_dependencies: - r-base From c2ca266f863f88447a7a7046ac03ce26fbf37d3d Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:09:36 +0200 Subject: [PATCH 3/7] Fix for failing build Ansible version 1.4 and 1.5 do not support the keyserver option --- .travis.yml | 2 -- meta/main.yml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18bef90..a1ad3c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,6 @@ language: python python: "2.7" env: - - ANSIBLE_VERSION=1.4 - - ANSIBLE_VERSION=1.5 - ANSIBLE_VERSION=1.6 - ANSIBLE_VERSION=1.7 - ANSIBLE_VERSION=1.8 diff --git a/meta/main.yml b/meta/main.yml index 5ea8108..114e434 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -5,7 +5,7 @@ galaxy_info: company: Oefenweb.nl B.V. description: Set up the latest version of R in Ubuntu systems license: MIT - min_ansible_version: 1.4 + min_ansible_version: 1.6 platforms: - name: Ubuntu versions: From 4b8b192e6ca3f2af1bb14d9de042a1e42a35db73 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:24:48 +0200 Subject: [PATCH 4/7] Improved tests --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index a1ad3c4..f66f7f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,9 @@ before_install: # Remove r-base - sudo apt-get remove --purge r-base + # Install littler + - sudo apt-get install littler + install: # Install Ansible. - pip install ansible==$ANSIBLE_VERSION @@ -34,5 +37,13 @@ script: && (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 From ba648e3df8d00122f2039daf9a633b85032c4fc9 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:26:18 +0200 Subject: [PATCH 5/7] Added hipchat notifications --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index f66f7f6..2bfec75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,3 +47,6 @@ script: 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= From 9a3a664e216fc86fa0ebc4b0dee7a8915d57272a Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:39:42 +0200 Subject: [PATCH 6/7] Improved formatting --- defaults/main.yml | 2 -- vars/main.yml | 1 - 2 files changed, 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3a2ba0f..6b6cfdf 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,7 +1,5 @@ # defaults file for r --- r_cran_mirror: http://cran.rstudio.com/ - r_install_dev: false - r_install: [] diff --git a/vars/main.yml b/vars/main.yml index 3d74358..17c6309 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -3,7 +3,6 @@ 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 '' }}" From c4cfe45d06d832b5500aa11e94b6f5adfa8d13ae Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 18 May 2015 23:46:44 +0200 Subject: [PATCH 7/7] Install littler using r_install --- .travis.yml | 3 --- tests/test.yml | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2bfec75..bd161d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,6 @@ before_install: # Remove r-base - sudo apt-get remove --purge r-base - # Install littler - - sudo apt-get install littler - install: # Install Ansible. - pip install ansible==$ANSIBLE_VERSION diff --git a/tests/test.yml b/tests/test.yml index 25f4f2a..68f8b6b 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -4,3 +4,6 @@ remote_user: root roles: - ansible-r + vars: + r_install: + - littler