├── .gitignore ├── README.md ├── Vagrantfile ├── puppet ├── manifests │ └── rstudio-server.pp └── modules │ └── wget │ ├── Gemfile │ ├── Gemfile.lock │ ├── Modulefile │ ├── README.md │ ├── Rakefile │ ├── manifests │ ├── authfetch.pp │ ├── fetch.pp │ └── init.pp │ ├── metadata.json │ └── spec │ ├── classes │ └── init_spec.rb │ ├── fixtures │ └── manifests │ │ └── site.pp │ └── spec_helper.rb ├── r-packages.R └── test ├── test.R └── test.Rmd /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | apps 3 | etc 4 | srv 5 | /startshiny.cmd 6 | /puppet_core_types_cheatsheet.pdf 7 | shiny-server 8 | 9 | /precise/*.box 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This provides a self-contained virtual environment running R and RStudio, intended for students in [Literary Data: Some Approaches](http://rci.rutgers.edu/~ag978/litdata) (Rutgers English graduate program, Spring 2015). If you have difficulties installing R, TeX, or RStudio on your home machine, you should be able to use this setup instead. Also, if your program runs correctly in this environment, it will run correctly when I test it as well (since I have the very same environment). 2 | 3 | # Installation 4 | 5 | Requirements: this is meant to run on almost any system. However, you will need a substantial amount of RAM (4 GB) and disk space (5 GB). 6 | 7 | 1. Install [Vagrant](https://www.vagrantup.com/downloads). 8 | 2. Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads). 9 | 3. Download [this repository as a zip archive](https://github.com/agoldst/litdata-vagrant/archive/master.zip) and unzip it. Note the folder you unzip it into. 10 | 4. Open a terminal (Windows calls this a "Command Window") and change to the folder from the last step. (Use the `cd` command.) You're in the right place if, when you enter `ls` and press Return, you see `Vagrantfile` among those listed. 11 | 5. Enter the command: `vagrant box add ubuntu/trusty64` and press Return. 12 | 6. Enter the command: `vagrant up` and press Return. Now begins a long process of downloading and installing software. This will require a large amount of disk space and time to complete (on my machine, it took about 5GB and about an hour of downloading and installing). You will know it is finished when you get a new command prompt (and hopefully no error messages). 13 | 14 | 15 | # Testing 16 | 17 | 1. Open your web browser and visit `http://localhost:8787`. You should see an RStudio login screen. Enter username `vagrant` and password `vagrant` and log in. You should now see a three-paned RStudio window. 18 | 1. Type the following command into the left-side pane (the R console): `source("/vagrant/test/test.R")` and press Return. You should see a few messages, and then a final message reading `Looks okay.` 19 | 1. In RStudio's File menu, choose "Open." Enter the following path: `/vagrant/test/test.pdf`. A PDF file should open up in your web browser. It should look like [this file](http://www.rci.rutgers.edu/~ag978/litdata/test-vagrant.pdf). 20 | 1. Close the window. Click "Sign Out" on the upper right of the RStudio window. 21 | 1. Enter `vagrant halt` and press Return. 22 | 1. Check in the folder where you unzipped all these for a file called `test.pdf`. Open this file in Preview or Adobe Reader (it should be the same as before). 23 | 24 | # Starting and stopping the virtual machine 25 | 26 | Before you can use RStudio in your web browser, you have to start the virtual machine. That is what `vagrant up` does. (It's much faster after the first time, because there's no new software to install.) Once you are done working, you will want to reclaim the (large) amount of RAM required to run all this software locally. That is the purpose of the command `vagrant halt`. 27 | 28 | # Saving your work 29 | 30 | When you are working in RStudio Server, your files live on the virtual machine's virtual hard drive. How do you get those files off the virtual machine and back to your regular hard drive so you can print them, e-mail them, back them up, etc.? The answer is that a special folder is *shared* between the virtual machine and your real hard drive. This is `/vagrant`. Any file you save there on the virtual machine will appear in the folder where you saved the `Vagrantfile`. The same process works in reverse. 31 | 32 | Because `/vagrant` itself is cluttered with the files for running the vritual machine (`Vagrantfile`, etc.), you'll find it convenient to create a subfolder of this directory and use *that* as your usual working directory. 33 | 34 | This configuration is based on a repository by [Dieter Menne](https://bitbucket.org/dmenne/rstudio-shiny-server-on-ubuntu). I have also made use of work by [Lincoln Mullen](https://github.com/lmullen/vagrant-r-dev/). 35 | 36 | # What's installed and how to modify it 37 | 38 | In case anyone wants to fork this repository for their own courses or other purposes, here's a little more detail about what's installed: 39 | 40 | ## The virtual machine 41 | 42 | The machine is the `ubuntu/trusty64` box [on Atlas](https://atlas.hashicorp.com/ubuntu/boxes/trusty64), i.e. Ubuntu 14.04 (Trusty Tahr) for AMD64 architectures under the Virtualbox provider. I borrowed this choice from the repositories cited above. 43 | 44 | The machine is configured with 2GB of RAM, which is fine for most pedagogical purposes. Some students will need to reduce this allocation before the VM can fit in their machine's physical RAM. Conversely, the matrices and arrays required for topic-modeling with MALLET consume a lot of RAM and may require a larger allocation. Edit the line in [Vagrantfile](Vagrantfile#L11) reading 45 | 46 | ```` 47 | v.memory = 2048 48 | ```` 49 | 50 | to change the allocation. The number is in megabytes. Use `vagrant reload` for the configuration to take effect. 51 | 52 | ## User accounts 53 | 54 | The machine configuration is governed by a Puppet manifest, [rstudio-server.pp](puppet/manifests/rstudio-server.pp). What I know about Puppet could fit on a postage stamp, so I am sure this isn't elegantly done, but it seems to do the job. 55 | 56 | The puppet script creates a single user, `vagrant`, which is also the RStudio Server user. I couldn't get things working when the two were different. I don't see obvious security concerns if this machine is running locally on your own machine, but don't deploy this image to the cloud (or to unsecured lab machines) without some better security configuration, since the username and password are here in the clear. 57 | 58 | ## Software 59 | 60 | It installs (not exactly in this order): 61 | 62 | 1. The latest available R 63 | 64 | 2. The latest available TeX Live (big) 65 | 66 | 3. RStudio Server. The version is hardcoded, but you can change it by editing the [line in the manifest](puppet/manifests/rstudio-server.pp#L3) that sets `$rstudioserver` (or change the full download URL by also changing `$urlrstudio`). 67 | 68 | 4. Various supporting libraries, languages, and tools: Java, python, libxml2, Make, Vim, and so on. 69 | 70 | 71 | ## R packages 72 | 73 | Finally, the Puppet manifest causes a set of R packages to be installed. This process is governed by an R script, [r-packages.R](r-packages.R). There's nothing sophisticated here, just a list of packages to be installed from CRAN (in the variable `packages`). In principle, `vagrant provision` will cause these to be upgraded if more recent versions are available than those that are installed. You can of course install packages from within R in the usual way too once the VM is up, but pedagogically speaking, the less time students spend installing tools after the first week, the better. (N.B. Vagrant's provisioning will not fail if installing packages fails, since `install.packages()` only generates a warning. It would be better to check that the packages are actually present and raise an error if not, but I don't do that here.) 74 | 75 | The script also installs one non-CRAN package: my own grab-bag package for my course, [hosted on github](http://github.com/agoldst/litdata). It is necessary for [the course assignments](http://rci.rutgers.edu/~ag978/litdata/hw) but if others are modifying this virtual machine configuration for their own uses, [the line installing it](r-packages.R#L22) can be deleted. For teachers, however, it may be useful to see the way I have used RStudio's [R Markdown document templates](http://rmarkdown.rstudio.com/developer_document_templates.html) for [student assignments](https://github.com/agoldst/litdata/tree/master/inst/rmarkdown/templates). 76 | 77 | # A pedagogical note 78 | 79 | In my Spring 2015 course, I did not have students rely exclusively on this VM. I wish I had, since attempting to support R, all the R packages I wanted, and especially LaTeX on each student's personal machine was very challenging and ever-more-frustrating as the semester went on. The disadvantage of this VM setup is the clumsiness of moving files on and off the VM and/or of editing entirely within the web-browser R Studio (which is sometimes quirky with respect to keyboard shortcuts). It's also fairly resource-intensive: my students with older Windows laptops never got the VM up and running. 80 | 81 | Nonetheless, I can say that this setup has indeed been used by students on a variety of Mac and Windows machines. I would be very pleased to hear from anyone who makes use of any part of this repository (or any of my other online course materials). I can be reached at . 82 | 83 | Andrew Goldstone 84 | June 2015 85 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 8 | # Set up the box 9 | config.vm.box = "ubuntu/trusty64" 10 | config.vm.provider "virtualbox" do |v| 11 | v.memory = 2048 12 | # v.cpus = 2 13 | end 14 | 15 | # Port forwarding 16 | # RStudio 17 | config.vm.network "forwarded_port", guest: 8787, host: 8787 18 | 19 | # add dummy to avoid "Could not retrieve fact fqdn" 20 | config.vm.hostname = "vagrant.example.com" 21 | 22 | # Provisioning 23 | config.vm.provision :puppet, 24 | # :options => ["--verbose", "--debug"] do |puppet| 25 | # :options => ["--debug"] do |puppet| 26 | :options => [] do |puppet| 27 | puppet.manifests_path = "puppet/manifests" 28 | puppet.manifest_file = "rstudio-server.pp" 29 | puppet.module_path = "puppet/modules" 30 | 31 | end 32 | 33 | end 34 | -------------------------------------------------------------------------------- /puppet/manifests/rstudio-server.pp: -------------------------------------------------------------------------------- 1 | include wget 2 | 3 | $rstudioserver = 'rstudio-server-0.99.465-amd64.deb' 4 | $urlrstudio = 'http://download2.rstudio.org/' 5 | 6 | # $texpkgs = 'hyperref ifxetex ifluatex fixltx2e listings fancyvrb longtable booktabs ulem framed' 7 | 8 | # Update system for r install 9 | class update_system { 10 | exec { 'apt_update': 11 | provider => shell, 12 | command => 'apt-get update;', 13 | } 14 | -> 15 | package { [ 16 | 'software-properties-common','libapparmor1', 17 | 'libdbd-mysql', 'libmysqlclient-dev','libssl-dev', 18 | 'python-software-properties', 19 | 'upstart', 'psmisc', 20 | 'python', 'g++', 'make','vim', 'whois','mc','libcairo2-dev', 21 | 'default-jdk', 'gdebi-core', 'libcurl4-gnutls-dev', 22 | 'libxml2-dev']: 23 | ensure => present, 24 | } 25 | -> 26 | exec { 'add-cran-repository': 27 | provider => shell, 28 | command => 29 | 'add-apt-repository "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/"; 30 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9; 31 | apt-get update;', 32 | } 33 | -> 34 | exec { 'upgrade-system': 35 | provider => shell, 36 | timeout => 2000, # On slow machines, this needs some time 37 | command =>'apt-get -y upgrade;apt-get -y autoremove;', 38 | } 39 | -> 40 | # Install host additions 41 | # (following https://www.virtualbox.org/manual/ch04.html 42 | # this must be done after upgrading. 43 | package { 'dkms': 44 | ensure => present, 45 | } 46 | } 47 | 48 | # Install r base and packages 49 | class install_r { 50 | package { ['r-base', 'r-base-dev']: 51 | ensure => present, 52 | require => Package['dkms'], 53 | } 54 | -> 55 | group { 'rstudio_users': 56 | ensure => present, 57 | } 58 | -> 59 | user { 'vagrant': 60 | # for R package installs, need: 61 | groups => ['vagrant', 'rstudio_users', 'staff'], 62 | } 63 | -> 64 | exec {'install-r-packages': 65 | provider => shell, 66 | timeout => 3000, 67 | command => 'Rscript /vagrant/r-packages.R' 68 | } 69 | } 70 | 71 | class install_tex { 72 | package { ['texlive-base', 'texlive-latex-recommended', 73 | 'texlive-fonts-recommended', 'texlive-latex-extra' ]: 74 | ensure => present, 75 | } 76 | } 77 | 78 | # install rstudio and start service 79 | class install_rstudio_server { 80 | # Download rstudio server 81 | wget::fetch {'rstudio-server-download': 82 | require => Package['r-base'], 83 | timeout => 0, 84 | destination => "${rstudioserver}", 85 | source => "${urlrstudio}${rstudioserver}", 86 | } 87 | -> 88 | exec {'rstudio-server-install': 89 | provider => shell, 90 | command => "gdebi -n ${rstudioserver}", 91 | } 92 | -> 93 | file { '/etc/rstudio/rsession.conf': 94 | ensure => file, 95 | mode => "a=r,u+w" 96 | } 97 | # -> 98 | # Create rstudio_users group 99 | # group {'rstudio_users': 100 | # ensure => present, 101 | # } 102 | # -> 103 | # Setting password during user creation does not work 104 | # Password is public; this is for local use only 105 | # exec { 'serverpass': 106 | # provider => shell, 107 | # command => 'usermod -p `mkpasswd -H md5 litdata` litdata', 108 | # } 109 | } 110 | 111 | # Make sure that both services are running 112 | class check_services { 113 | service {'rstudio-server': 114 | ensure => running, 115 | require => [Exec['rstudio-server-install']], 116 | hasstatus => true, 117 | } 118 | } 119 | 120 | 121 | 122 | include update_system 123 | include install_r 124 | include install_tex 125 | include install_rstudio_server 126 | include check_services 127 | 128 | -------------------------------------------------------------------------------- /puppet/modules/wget/Gemfile: -------------------------------------------------------------------------------- 1 | source :rubygems 2 | 3 | group :rake do 4 | gem 'puppet', '~>2.7.17' 5 | gem 'rspec-puppet', '>=0.1.3' 6 | gem 'rake', '>=0.9.2.2' 7 | gem 'puppet-lint', '~>0.1.12' 8 | gem 'puppetlabs_spec_helper' 9 | end 10 | -------------------------------------------------------------------------------- /puppet/modules/wget/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | diff-lcs (1.1.3) 5 | facter (1.6.10) 6 | metaclass (0.0.1) 7 | mocha (0.12.0) 8 | metaclass (~> 0.0.1) 9 | puppet (2.7.18) 10 | facter (~> 1.5) 11 | puppet-lint (0.1.13) 12 | puppetlabs_spec_helper (0.2.0) 13 | mocha (>= 0.10.5) 14 | rake 15 | rspec (>= 2.9.0) 16 | rspec-puppet (>= 0.1.1) 17 | rake (0.9.2.2) 18 | rspec (2.11.0) 19 | rspec-core (~> 2.11.0) 20 | rspec-expectations (~> 2.11.0) 21 | rspec-mocks (~> 2.11.0) 22 | rspec-core (2.11.0) 23 | rspec-expectations (2.11.1) 24 | diff-lcs (~> 1.1.3) 25 | rspec-mocks (2.11.1) 26 | rspec-puppet (0.1.3) 27 | rspec 28 | 29 | PLATFORMS 30 | ruby 31 | 32 | DEPENDENCIES 33 | puppet (~> 2.7.17) 34 | puppet-lint (~> 0.1.12) 35 | puppetlabs_spec_helper 36 | rake (>= 0.9.2.2) 37 | rspec-puppet (>= 0.1.3) 38 | -------------------------------------------------------------------------------- /puppet/modules/wget/Modulefile: -------------------------------------------------------------------------------- 1 | name 'maestrodev-wget' 2 | version '1.1.0' 3 | source 'http://github.com/maestrodev/puppet-wget.git' 4 | author 'maestrodev' 5 | license 'Apache License, Version 2.0' 6 | summary 'Download files with wget' 7 | description 'A module for wget that allows downloading of files, supporting authentication' 8 | project_page 'http://github.com/maestrodev/puppet-wget' 9 | -------------------------------------------------------------------------------- /puppet/modules/wget/README.md: -------------------------------------------------------------------------------- 1 | A Puppet module to download files with wget, supporting authentication. 2 | 3 | # Example 4 | 5 | include wget 6 | 7 | wget::fetch { "download": 8 | source => "http://www.google.com/index.html", 9 | destination => "/tmp/index.html", 10 | timeout => 0, 11 | verbose => false, 12 | } 13 | 14 | wget::authfetch { "download": 15 | source => "http://www.google.com/index.html", 16 | destination => "/tmp/index.html", 17 | user => "user", 18 | password => "password", 19 | timeout => 0, 20 | verbose => false, 21 | } 22 | 23 | # License 24 | 25 | Copyright 2011-2013 MaestroDev 26 | 27 | Licensed under the Apache License, Version 2.0 (the "License"); 28 | you may not use this file except in compliance with the License. 29 | You may obtain a copy of the License at 30 | 31 | http://www.apache.org/licenses/LICENSE-2.0 32 | 33 | Unless required by applicable law or agreed to in writing, software 34 | distributed under the License is distributed on an "AS IS" BASIS, 35 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 36 | See the License for the specific language governing permissions and 37 | limitations under the License. 38 | -------------------------------------------------------------------------------- /puppet/modules/wget/Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler' 2 | Bundler.require(:rake) 3 | 4 | require 'puppetlabs_spec_helper/rake_tasks' 5 | 6 | PuppetLint.configuration.send("disable_80chars") 7 | -------------------------------------------------------------------------------- /puppet/modules/wget/manifests/authfetch.pp: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Definition: wget::authfetch 3 | # 4 | # This class will download files from the internet. You may define a web proxy 5 | # using $::http_proxy if necessary. Username must be provided. And the user's 6 | # password must be stored in the password variable within the .wgetrc file. 7 | # 8 | ################################################################################ 9 | define wget::authfetch ( 10 | $destination, 11 | $user, 12 | $source = $title, 13 | $password = '', 14 | $timeout = '0', 15 | $verbose = false, 16 | $redownload = false, 17 | $nocheckcertificate = false, 18 | $execuser = undef, 19 | ) { 20 | 21 | notice("wget::authfetch is deprecated, use wget::fetch with user/password params") 22 | 23 | wget::fetch { $title: 24 | destination => $destination, 25 | source => $source, 26 | timeout => $timeout, 27 | verbose => $verbose, 28 | redownload => $redownload, 29 | nocheckcertificate => $nocheckcertificate, 30 | execuser => $execuser, 31 | user => $user, 32 | password => $password, 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /puppet/modules/wget/manifests/fetch.pp: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Definition: wget::fetch 3 | # 4 | # This class will download files from the internet. You may define a web proxy 5 | # using $http_proxy if necessary. 6 | # 7 | ################################################################################ 8 | define wget::fetch ( 9 | $destination, 10 | $source = $title, 11 | $timeout = '0', 12 | $verbose = false, 13 | $redownload = false, 14 | $nocheckcertificate = false, 15 | $execuser = undef, 16 | $user = undef, 17 | $password = undef, 18 | $cache_dir = undef, 19 | $cache_file = undef, 20 | ) { 21 | 22 | include wget 23 | 24 | $http_proxy_env = $::http_proxy ? { 25 | undef => [], 26 | default => [ "HTTP_PROXY=${::http_proxy}", "http_proxy=${::http_proxy}" ], 27 | } 28 | $https_proxy_env = $::http_proxy ? { 29 | undef => [], 30 | default => [ "HTTPS_PROXY=${::https_proxy}", "https_proxy=${::https_proxy}" ], 31 | } 32 | $password_env = $user ? { 33 | undef => [], 34 | default => [ "WGETRC=${destination}.wgetrc" ], 35 | } 36 | 37 | # not using stdlib.concat to avoid extra dependency 38 | $environment = split(inline_template("<%= (@http_proxy_env+@https_proxy_env+@password_env).join(',') %>"),',') 39 | 40 | $verbose_option = $verbose ? { 41 | true => '--verbose', 42 | false => '--no-verbose' 43 | } 44 | 45 | $unless_test = $redownload ? { 46 | true => 'test', 47 | false => "test -s ${destination}" 48 | } 49 | 50 | $nocheckcert_option = $nocheckcertificate ? { 51 | true => ' --no-check-certificate', 52 | false => '' 53 | } 54 | 55 | $user_option = $user ? { 56 | undef => '', 57 | default => " --user=${user}", 58 | } 59 | 60 | if $user != undef { 61 | $wgetrc_content = $::operatingsystem ? { 62 | # This is to work around an issue with macports wget and out of date CA cert bundle. This requires 63 | # installing the curl-ca-bundle package like so: 64 | # 65 | # sudo port install curl-ca-bundle 66 | 'Darwin' => "password=${password}\nCA_CERTIFICATE=/opt/local/share/curl/curl-ca-bundle.crt\n", 67 | default => "password=${password}", 68 | } 69 | 70 | file { "${destination}.wgetrc": 71 | owner => $execuser, 72 | mode => '0600', 73 | content => $wgetrc_content, 74 | before => Exec["wget-${name}"], 75 | } 76 | } 77 | 78 | $output_option = $cache_dir ? { 79 | undef => " --output-document='${destination}'", 80 | default => " -N -P '${cache_dir}'", 81 | } 82 | 83 | exec { "wget-${name}": 84 | command => "wget ${verbose_option}${nocheckcert_option}${user_option}${output_option} '${source}'", 85 | timeout => $timeout, 86 | unless => $unless_test, 87 | environment => $environment, 88 | user => $cache_dir ? { undef => $execuser, default => undef }, 89 | path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin:/opt/local/bin', 90 | require => Class['wget'], 91 | } 92 | 93 | if $cache_dir != undef { 94 | $cache = $cache_file ? { 95 | undef => inline_template("<%= require 'uri'; File.basename(URI::parse(@source).path) %>"), 96 | default => $cache_file, 97 | } 98 | file { $destination: 99 | ensure => file, 100 | source => "${cache_dir}/${cache}", 101 | owner => $execuser, 102 | require => Exec["wget-${name}"], 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /puppet/modules/wget/manifests/init.pp: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Class: wget 3 | # 4 | # This class will install wget - a tool used to download content from the web. 5 | # 6 | ################################################################################ 7 | class wget ( 8 | $version = present, 9 | ) { 10 | 11 | if $::kernel == 'Linux' { 12 | if ! defined(Package['wget']) { 13 | package { 'wget': ensure => $version } 14 | } 15 | } 16 | 17 | if $::kernel == 'FreeBSD' { 18 | if ! defined(Package['ftp/wget']) { 19 | package { 'ftp/wget': ensure => $version } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /puppet/modules/wget/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "maestrodev-wget", 3 | "version": "1.1.0", 4 | "source": "http://github.com/maestrodev/puppet-wget.git", 5 | "author": "maestrodev", 6 | "license": "Apache License, Version 2.0", 7 | "summary": "Download files with wget", 8 | "description": "A module for wget that allows downloading of files, supporting authentication", 9 | "project_page": "http://github.com/maestrodev/puppet-wget", 10 | "dependencies": [ 11 | 12 | ], 13 | "types": [ 14 | 15 | ], 16 | "checksums": { 17 | "Gemfile": "4867df718b033e152c59c2a418e88b92", 18 | "Gemfile.lock": "b3e4cf700f055d8d242ad877da298127", 19 | "Modulefile": "319654cea17d4ad7af5a45f4746f6678", 20 | "README.md": "53e3a8bdf9ad988aae9b9581831bbcd6", 21 | "Rakefile": "527f8893f2694a9bc92993074f011cc3", 22 | "manifests/init.pp": "7a1575c5a0a755b01dcdd2dbf4f8e956", 23 | "spec/classes/init_spec.rb": "337ce66ffc43c7478ff0d3ff166d278a", 24 | "spec/fixtures/manifests/site.pp": "627dec82fd1b0d0b4f9e47135ed3e1b7", 25 | "spec/spec_helper.rb": "0db89c9a486df193c0e40095422e19dc" 26 | } 27 | } -------------------------------------------------------------------------------- /puppet/modules/wget/spec/classes/init_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'wget' do 4 | 5 | context 'running on OS X' do 6 | let(:facts) { {:operatingsystem => 'Darwin'} } 7 | 8 | it { should_not contain_package('wget') } 9 | end 10 | 11 | context 'running on CentOS' do 12 | let(:facts) { {:operatingsystem => 'CentOS'} } 13 | 14 | it { should contain_package('wget') } 15 | end 16 | 17 | context 'no version specified' do 18 | it { should contain_package('wget').with_ensure('installed') } 19 | end 20 | 21 | context 'version is 1.2.3' do 22 | let(:params) { {:version => '1.2.3'} } 23 | 24 | it { should contain_package('wget').with_ensure('1.2.3') } 25 | end 26 | 27 | describe 'wget::fetch' do 28 | it { should contain_exec('wget-test').with_command('wget --no-verbose --output-document=/tmp/dest http://localhost/source') } 29 | end 30 | 31 | describe 'wget::authfetch' do 32 | it { should contain_exec('wget-authtest').with({ 33 | 'command' => 'wget --no-verbose --user=myuser --output-document=/tmp/dest http://localhost/source', 34 | 'environment' => 'WGETRC=/tmp/wgetrc-authtest' 35 | }) 36 | } 37 | it { should contain_file('/tmp/wgetrc-authtest').with_content('password=mypassword') } 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /puppet/modules/wget/spec/fixtures/manifests/site.pp: -------------------------------------------------------------------------------- 1 | wget::fetch { 'test': 2 | source => 'http://localhost/source', 3 | destination => '/tmp/dest', 4 | } 5 | 6 | wget::authfetch { 'authtest': 7 | source => 'http://localhost/source', 8 | destination => '/tmp/dest', 9 | user => 'myuser', 10 | password => 'mypassword', 11 | } 12 | -------------------------------------------------------------------------------- /puppet/modules/wget/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'puppetlabs_spec_helper/module_spec_helper' 2 | -------------------------------------------------------------------------------- /r-packages.R: -------------------------------------------------------------------------------- 1 | options("repos"="http://cran.rstudio.com") # set the cran mirror 2 | 3 | packages <- c("devtools", 4 | "ggplot2", 5 | "tidyr", 6 | "dplyr", 7 | "stringr", 8 | "rstudio", 9 | "knitr", 10 | "rmarkdown", 11 | "XML", 12 | "rJava", 13 | "mallet", 14 | "igraph", 15 | "SnowballC", 16 | "NLP", 17 | "openNLP") 18 | packages <- setdiff(packages, installed.packages()[, "Package"]) 19 | if (length(packages) != 0){ 20 | (install.packages(packages)) 21 | } 22 | devtools::install_github("agoldst/litdata") 23 | update.packages(ask=FALSE) 24 | -------------------------------------------------------------------------------- /test/test.R: -------------------------------------------------------------------------------- 1 | message("Testing virtual machine setup...") 2 | 3 | library("rmarkdown") 4 | render("/vagrant/test/test.Rmd") 5 | 6 | stopifnot(file.exists("/vagrant/test/test.pdf")) 7 | 8 | message("Looks okay.") 9 | -------------------------------------------------------------------------------- /test/test.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: Test File 3 | author: Test Author 4 | output: pdf_document 5 | --- 6 | 7 | # Ordinary markdown code 8 | 9 | Ordinary *emphasized* **bolded** text.[^1] 10 | 11 | [^1]: Footnote already! 12 | 13 | 1. List 14 | 2. Items 15 | 3. Hurrah! 16 | 17 | Inline code: two and two make `r 2 + 2`. 18 | 19 | # Plotting 20 | 21 | ```{r test-figure} 22 | library(ggplot2) 23 | ggplot(mtcars,aes(disp,hp)) + geom_point() 24 | ``` 25 | 26 | --------------------------------------------------------------------------------