From dea5c4e962f49be6f0fb7dcf07f48e1a282f1953 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 12 Jun 2017 13:27:36 -0700 Subject: [PATCH 1/4] Updated Dockerfile Set to use a newer JRuby Added an environment variable for the log file location Changed entrypoint to cmd to add flexibility Added missing trailing slash to copy command path --- Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index e0a679bca..b2e0ce86b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,24 +8,25 @@ # RUN: # docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler -FROM jruby:1.7-jdk +FROM jruby:9.1-jdk + +RUN mkdir -p /var/lib/vmpooler && mkdir /var/log/vmpooler -RUN mkdir -p /var/lib/vmpooler WORKDIR /var/lib/vmpooler -ADD Gemfile* /var/lib/vmpooler +ADD Gemfile* /var/lib/vmpooler/ RUN bundle install --system RUN ln -s /opt/jruby/bin/jruby /usr/bin/jruby RUN echo "deb http://httpredir.debian.org/debian jessie main" >/etc/apt/sources.list.d/jessie-main.list -RUN apt-get update -RUN apt-get install -y redis-server +RUN apt-get update && apt-get install -y redis-server && rm -rf /var/lib/apt/lists/* COPY . /var/lib/vmpooler -ENTRYPOINT \ +ENV VMPOOLER_LOG /var/log/vmpooler.log +CMD \ /etc/init.d/redis-server start \ && /var/lib/vmpooler/scripts/vmpooler_init.sh start \ - && while [ ! -f /var/log/vmpooler.log ]; do sleep 1; done ; \ - tail -f /var/log/vmpooler.log + && while [ ! -f ${VMPOOLER_LOG} ]; do sleep 1; done ; \ + tail -f ${VMPOOLER_LOG} From fb1847f5385d7b3f9090729e510eed21b5950113 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 12 Jun 2017 13:28:24 -0700 Subject: [PATCH 2/4] added sample usage of the dummy provider --- vmpooler.yaml.dummy-example | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 vmpooler.yaml.dummy-example diff --git a/vmpooler.yaml.dummy-example b/vmpooler.yaml.dummy-example new file mode 100644 index 000000000..ffb298587 --- /dev/null +++ b/vmpooler.yaml.dummy-example @@ -0,0 +1,48 @@ +--- +:providers: + :dummy: + filename: '/tmp/dummy-backing.yaml' + +:redis: + server: 'localhost' + +:auth: + provider: 'dummy' + +:tagfilter: + url: '(.*)\/' + +:config: + site_name: 'vmpooler' + logfile: '/var/log/vmpooler/vmpooler.log' + task_limit: 10 + timeout: 15 + vm_checktime: 15 + vm_lifetime: 12 + vm_lifetime_auth: 24 + allowed_tags: + - 'created_by' + - 'project' + domain: 'company.com' + prefix: 'poolvm-' + +:pools: + - name: 'debian-7-i386' + alias: [ 'debian-7-32' ] + template: 'Templates/debian-7-i386' + folder: 'Pooled VMs/debian-7-i386' + datastore: 'vmstorage' + size: 5 + timeout: 15 + ready_ttl: 1440 + provider: dummy + - name: 'debian-7-x86_64' + alias: [ 'debian-7-64', 'debian-7-amd64' ] + template: 'Templates/debian-7-x86_64' + folder: 'Pooled VMs/debian-7-x86_64' + datastore: 'vmstorage' + size: 5 + timeout: 15 + ready_ttl: 1440 + provider: dummy + From fdf5f5beb0c030c9c61006cb6f3b6d8c33410a00 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 12 Jun 2017 13:29:33 -0700 Subject: [PATCH 3/4] Added a Vagrant file that is caplable of running vmpooler in Docker or locally --- .gitignore | 1 + Vagrantfile | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Vagrantfile diff --git a/.gitignore b/.gitignore index 99789c436..6dcdc33a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vagrant/ .ruby-version Gemfile.lock Gemfile.local diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..799ae6a3a --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,19 @@ +# vim: autoindent tabstop=2 shiftwidth=2 expandtab softtabstop=2 filetype=ruby +Vagrant.configure("2") do |config| + config.vm.box = "genebean/centos-7-rvm-221" + config.vm.network "forwarded_port", guest: 4567, host: 4567 + config.vm.network "forwarded_port", guest: 8080, host: 8080 + config.vm.provision "shell", inline: <<-SCRIPT + mkdir /var/log/vmpooler + chown vagrant:vagrant /var/log/vmpooler + yum -y install docker + groupadd docker + usermod -aG docker vagrant + systemctl enable docker + systemctl start docker + docker build -t vmpooler /vagrant + docker images + echo 'To use the container with the dummy provider do this after "vagrant ssh":' + echo "docker run -e VMPOOLER_DEBUG=true -p 8080:4567 -v /vagrant/vmpooler.yaml.dummy-example:/var/lib/vmpooler/vmpooler.yaml -e VMPOOLER_LOG='/var/log/vmpooler/vmpooler.log' -it --rm --name pooler vmpooler" + SCRIPT +end From a7274f3869b3f72b067d3be89903befd04779387 Mon Sep 17 00:00:00 2001 From: Gene Liverman Date: Mon, 12 Jun 2017 15:19:25 -0700 Subject: [PATCH 4/4] Updated README with Vagrant info --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 8dcbfbb69..3e95612f1 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,49 @@ A [Dockerfile](Dockerfile) is included in this repository to allow running vmpoo docker build -t vmpooler . && docker run -e VMPOOLER_CONFIG -p 80:4567 -it vmpooler ``` +### Running Docker inside Vagrant + +A [Vagrantfile](Vagrantfile) is also included in this repository so that you dont have to run Docker on your local computer. +To use it run: + +``` +vagrant up +vagrant ssh +docker run -p 8080:4567 -v /vagrant/vmpooler.yaml.example:/var/lib/vmpooler/vmpooler.yaml -it --rm --name pooler vmpooler +``` + +To run vmpooler with the example dummy provider you can replace the above docker command with this: + +``` +docker run -e VMPOOLER_DEBUG=true -p 8080:4567 -v /vagrant/vmpooler.yaml.dummy-example:/var/lib/vmpooler/vmpooler.yaml -e VMPOOLER_LOG='/var/log/vmpooler/vmpooler.log' -it --rm --name pooler vmpooler +``` + +Either variation will allow you to access the dashboard from [localhost:8080](http://localhost:8080/). + +### Running directly in Vagrant + +You can also run vmpooler directly in the Vagrant box. To do so run this: + +``` +vagrant up +vagrant ssh +cd /vagrant + +# Do this if using the dummy provider +export VMPOOLER_DEBUG=true +cp vmpooler.yaml.dummy-example vmpooler.yaml + +# vmpooler needs a redis server. +sudo yum -y install redis +sudo systemctl start redis + +gem install bundler +bundle install +bundle exec ruby vmpooler +``` + +When run this way you can access vmpooler from your local computer via [localhost:4567](http://localhost:4567/). + ## API and Dashboard vmpooler provides an API and web front-end (dashboard) on port `:4567`. See the provided YAML configuration example, [vmpooler.yaml.example](vmpooler.yaml.example), to specify an alternative port to listen on.