vagrant-qienv 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +10 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +94 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/lib/envs/default.json +20 -0
  13. data/lib/envs/linux-desktop.json +22 -0
  14. data/lib/envs/production.yml +33 -0
  15. data/lib/provisioning/base-playbook.yml +16 -0
  16. data/lib/provisioning/couchdb-playbook.yml +11 -0
  17. data/lib/provisioning/couchdb-requirements.yml +5 -0
  18. data/lib/provisioning/couchdb-vagrant-vars.yml +1 -0
  19. data/lib/provisioning/gpii-linux-playbook.yml +11 -0
  20. data/lib/provisioning/gpii-linux-requirements.yml +6 -0
  21. data/lib/provisioning/gpii-linux-vagrant-vars.yml +23 -0
  22. data/lib/provisioning/nodejs-playbook.yml +12 -0
  23. data/lib/provisioning/nodejs-requirements.yml +7 -0
  24. data/lib/provisioning/nodejs-vagrant-vars.yml +11 -0
  25. data/lib/provisioning/preferences-playbook.yml +13 -0
  26. data/lib/provisioning/preferences-requirements.yml +9 -0
  27. data/lib/provisioning/preferences-vagrant-vars.yml +5 -0
  28. data/lib/vagrant-qienv.rb +18 -0
  29. data/lib/vagrant-qienv/action.rb +122 -0
  30. data/lib/vagrant-qienv/action/init_environment.rb +24 -0
  31. data/lib/vagrant-qienv/command/base.rb +19 -0
  32. data/lib/vagrant-qienv/command/init.rb +28 -0
  33. data/lib/vagrant-qienv/command/test.rb +65 -0
  34. data/lib/vagrant-qienv/config/config_folders.rb +17 -0
  35. data/lib/vagrant-qienv/config/config_network.rb +69 -0
  36. data/lib/vagrant-qienv/config/config_provider.rb +40 -0
  37. data/lib/vagrant-qienv/config/config_provision.rb +50 -0
  38. data/lib/vagrant-qienv/plugin.rb +59 -0
  39. data/lib/vagrant-qienv/version.rb +5 -0
  40. data/qi.yml.template +56 -0
  41. data/samples/README.md +12 -0
  42. data/samples/gpii-linux-production/.qi.yml +41 -0
  43. data/samples/gpii-linux/.qi.yml +22 -0
  44. data/samples/gpii-nexus/.qi.yml +24 -0
  45. data/samples/gpii-universal/.qi.yml +27 -0
  46. data/spec/spec_helper.rb +2 -0
  47. data/spec/vagrant/cienv_spec.rb +11 -0
  48. data/vagrant-cienv.gemspec +33 -0
  49. metadata +137 -0
@@ -0,0 +1,50 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ require 'yaml'
5
+
6
+ def config_provision(instance, vm_config, vm_id, apps, vagrant_ci_path)
7
+
8
+
9
+ apps.each do |config|
10
+ if config["run_in"] == vm_id then
11
+ if ARGV[0] == "up" then
12
+ app = config["app_name"] #app_name
13
+ stack = config["software_stack"]
14
+
15
+ #check if every file is in place
16
+ raise "File vagrant/provisioning/#{stack}-requirements.yml doesn't exist"\
17
+ unless File.file?(vagrant_ci_path + "/provisioning/#{stack}-requirements.yml")
18
+ raise "File vagrant/provisioning/#{stack}-vars.yml doesn't exist"\
19
+ unless File.file?(vagrant_ci_path + "/provisioning/#{stack}-vagrant-vars.yml")
20
+ raise "File vagrant/provisioning/#{stack}-playbook.yml doesn't exist"\
21
+ unless File.file?(vagrant_ci_path + "/provisioning/#{stack}-playbook.yml")
22
+ raise "File vagrant/provisioning/base-playbook.yml doesn't exist"\
23
+ unless File.file?(vagrant_ci_path + "/provisioning/base-playbook.yml")
24
+
25
+ qi_vars = JSON.dump(YAML::load(config.to_yaml))
26
+
27
+ basecmd = "sudo PYTHONUNBUFFERED=1 VM_HOSTNAME=#{vm_id} "\
28
+ "ansible-playbook --extra-vars='#$base_vars' /provisioning/base-playbook.yml"
29
+ instance.vm.provision "shell", inline: basecmd
30
+
31
+ cmds = \
32
+ "sudo ansible-galaxy install -fr /provisioning/#{stack}-requirements.yml \n"\
33
+ "sudo VARS_FILE=#{stack}-vagrant-vars.yml PYTHONUNBUFFERED=1 \\\n"
34
+ if config["deploy"] then
35
+ cmds << "ansible-playbook --tags='install,configure,deploy' --extra-vars='#{qi_vars}' /provisioning/#{stack}-playbook.yml"
36
+ else
37
+ cmds << "ansible-playbook --tags='install,configure' --extra-vars='#{qi_vars}' /provisioning/#{stack}-playbook.yml"
38
+ end
39
+ instance.vm.provision "shell", inline: cmds
40
+
41
+ elsif ARGV[0] == "provision" and config["test_cmds"] and config["folder"] and config["folder"]["dest"] then
42
+ test_cmds = "cd #{config['folder']['dest']} \n"
43
+ config["test_cmds"].each do |cmd|
44
+ test_cmds << "DISPLAY=:0 " + cmd + "\n"
45
+ end unless config["test_cmds"].nil?
46
+ instance.vm.provision "shell", privileged: false, inline: test_cmds
47
+ end
48
+ end
49
+ end if apps
50
+ end
@@ -0,0 +1,59 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant QI plugin must be run within Vagrant."
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < "1.8.0"
10
+ raise "The Vagrant QI plugin is only compatible with Vagrant 1.8+"
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module Cienv
15
+ class Plugin < Vagrant.plugin("2")
16
+ name "Cienv"
17
+ description "This plugin enabled Vagrant to work with QI QI environments"
18
+
19
+ action_hook(:build_config, :environment_load) do |hook|
20
+ hook.prepend(VagrantPlugins::Cienv::Action::BuildVagrantfile)
21
+ end
22
+ command("test") do
23
+ require File.expand_path("../command/test", __FILE__)
24
+ Command::Test
25
+ end
26
+
27
+ # This sets up our log level to be whatever VAGRANT_LOG is.
28
+ def self.setup_logging
29
+ require "log4r"
30
+
31
+ level = nil
32
+ begin
33
+ level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
34
+ rescue NameError
35
+ # This means that the logging constant wasn't found,
36
+ # which is fine. We just keep `level` as `nil`. But
37
+ # we tell the user.
38
+ level = nil
39
+ end
40
+
41
+ # Some constants, such as "true" resolve to booleans, so the
42
+ # above error checking doesn't catch it. This will check to make
43
+ # sure that the log level is an integer, as Log4r requires.
44
+ level = nil if !level.is_a?(Integer)
45
+
46
+ # Set the logging level on all "vagrant" namespaced
47
+ # logs as long as we have a valid level.
48
+ if level
49
+ logger = Log4r::Logger.new("vagrant_cienv")
50
+ logger.outputters = Log4r::Outputter.stderr
51
+ logger.level = level
52
+ logger = nil
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+ require 'vagrant-qienv/plugin'
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Cienv
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/qi.yml.template ADDED
@@ -0,0 +1,56 @@
1
+ ---
2
+
3
+ # This is a template .qi.yml file. It shows the available variables to setup the
4
+ # applications that will run in the VM enviroment. More examples are available
5
+ # in the 'samples' directory.
6
+
7
+ email: anonymous@testdomain.org
8
+ # env_runtime variable set the VM enviroment that will be used to run the
9
+ # applications below. You can see the available environments in 'env' directory
10
+ env_runtime: linux-desktop
11
+
12
+ # The apps variable lists the applications that must be installed. The
13
+ # properties of each application define the source of the code, the way that are
14
+ # deployed and how should run
15
+
16
+ apps:
17
+ # The app_name variable set an unique identifier that can be used to create the
18
+ # instances of the running applications, or to name a directory where all the
19
+ # files related to the application will be stored.
20
+ - app_name: name-of-application
21
+ # the git_repository variable is used to retrieve the source code of the
22
+ # application if the code is not available through a shared folder. You can also
23
+ # set a git_branch variable to set the branch,tag,commit or pull request to
24
+ # retrieve.
25
+ git_repository: https://github.com/user/repo.git
26
+ git_branch: pr/1
27
+ # The software_stack variable set the software applicance that will be installed
28
+ # in the vm. The avaliable software stacks are in the provisioning directory.
29
+ software_stack: [nodejs | couchdb]
30
+ # The deploy variable notifies to the stack that this application will be
31
+ # launched as a service. Note that the stack must know how to launch this
32
+ # application.
33
+ deploy: false
34
+ # The 'run_in' variable indicates which VM of the environment will contain the
35
+ # application. To know the name of the VMs see the environment files found in
36
+ # the 'env' directory.
37
+ run_in: fedora
38
+ # The setup variable list the command that will be executed after the
39
+ # provisioning of the software_stack is finished.
40
+ setup:
41
+ - command 1
42
+ - command 2
43
+ # The test_cmds variable list the commands that will be executed on every
44
+ # 'vagrant provision' command. This list usually have the commands that test the
45
+ # application, so every time you run 'vagrant provision' all these commands
46
+ # will run the tests of your application.
47
+ test_cmds:
48
+ - test command 1
49
+ - test command 2
50
+ # The folder variable sets the installation folder of the application. The
51
+ # 'dest' child variable is the destination folder where the application will be
52
+ # installed. If you add a 'src' child variable Vagrant will map that path from
53
+ # the host to the 'dest' path in the VM. Vagrant will create a shared folder
54
+ # using this information.
55
+ folder:
56
+ dest: "/app/{{ app_name }}"
data/samples/README.md ADDED
@@ -0,0 +1,12 @@
1
+ Examples
2
+ -------
3
+
4
+ This folder contains several examples of how to use the vagrant-qienv plugin. To
5
+ run any of these examples:
6
+
7
+ 1. Copy the directory in some place
8
+ 2. Go to that directory
9
+ 2. Install the plugin
10
+ `vagrant plugin install vagrant-qienv`
11
+ 3. Run vagrant:
12
+ `vagrant up && vagrant test`
@@ -0,0 +1,41 @@
1
+ ---
2
+
3
+ # This sample will spin up two VMs, one server without desktop interface, and
4
+ # another one with a desktop interface called 'fedora', both are provided by the
5
+ # file 'production.json'. Then 3 applications will be installed, gpii-linux will
6
+ # be installed in the 'fedora' VM and couchdb and preferences will be installed
7
+ # in then 'server' VM. The commands listed in the 'setup' variable will run at
8
+ # 'vagrant up' time, and the commands listed in the 'test_cmds' variable will be
9
+ # run using the 'vagrant provision' command.
10
+
11
+ email: anonymous@testdomain.org
12
+ env_runtime: production
13
+
14
+ apps:
15
+ - app_name: gpii-linux
16
+ git_repository: https://github.com/GPII/linux.git
17
+ software_stack: gpii-linux
18
+ folder:
19
+ dest: /app/gpii-linux
20
+ run_in: fedora
21
+ deploy: false
22
+ setup:
23
+ - npm install
24
+ - sudo npm install -g grunt-cli node-gyp
25
+ - grunt --force build
26
+ test_cmds:
27
+ - "find -name \\*.sh -exec chmod +x '{}' \\;"
28
+ - node tests/AcceptanceTests.js
29
+ - cd tests && bash UnitTests.sh
30
+
31
+ - app_name: couchdb
32
+ software_stack: couchdb
33
+ run_in: server
34
+ deploy: true
35
+
36
+ - app_name: preferences
37
+ software_stack: preferences
38
+ run_in: server
39
+ deploy: true
40
+ folder:
41
+ dest: "/app/{{ app_name }}"
@@ -0,0 +1,22 @@
1
+ ---
2
+
3
+ email: anonymous@testdomain.org
4
+ env_runtime: linux-desktop
5
+
6
+ apps:
7
+ - app_name: gpii-linux
8
+ git_repository: https://github.com/GPII/linux.git
9
+ software_stack: gpii-linux
10
+ folder:
11
+ dest: /app/gpii-linux
12
+ run_in: fedora
13
+ deploy: false
14
+ setup:
15
+ - npm install
16
+ - sudo npm install -g grunt-cli node-gyp
17
+ - grunt --force build
18
+ test_cmds:
19
+ - "find -name \\*.sh -exec chmod +x '{}' \\;"
20
+ - node tests/AcceptanceTests.js
21
+ - cd tests && bash UnitTests.sh
22
+
@@ -0,0 +1,24 @@
1
+ ---
2
+
3
+ # This sample fetchs the Pull Request #1 of the GPII/nexus repository, spin up a
4
+ # fedora VM an run the tests when 'vagrant provision' command is run.
5
+
6
+ email: anonymous@testdomain.org
7
+ env_runtime: linux-desktop
8
+
9
+ apps:
10
+ - app_name: gpii-nexus
11
+ git_repository: https://github.com/GPII/nexus.git
12
+ git_branch: pr/1
13
+ software_stack: nodejs
14
+ folder:
15
+ dest: /app/gpii-nexus
16
+ run_in: fedora
17
+ deploy: false
18
+ setup:
19
+ - npm install
20
+ - sudo npm install -g grunt-cli node-gyp
21
+ - grunt --force build
22
+ test_cmds:
23
+ - node tests/all-tests.js
24
+
@@ -0,0 +1,27 @@
1
+ ---
2
+
3
+ # This sample will spin up one VM with the desktop interface (linux-desktop
4
+ # environment). Then will deploy an application named 'gpii-universal' which is
5
+ # a clone of the repository https://github.com/GPII/universal.git. It will exec
6
+ # the commands listed in the 'setup' variable at 'vagrant up' time, and the
7
+ # 'test_cmds' commands will be executed with 'vagrant provision'.
8
+
9
+ email: anonymous@testdomain.org
10
+ env_runtime: linux-desktop
11
+
12
+ apps:
13
+ - app_name: gpii-universal
14
+ git_repository: https://github.com/GPII/universal.git
15
+ software_stack: nodejs
16
+ folder:
17
+ dest: /app/gpii-universal
18
+ run_in: fedora
19
+ setup:
20
+ - npm install
21
+ - "sudo npm install -g testem"
22
+ - "git clone {{ git_repository }} /app/gpii-universal/node_modules/universal"
23
+ test_cmds:
24
+ - "npm test"
25
+ - "testem ci --file tests/web/testem_qi.json"
26
+ - "node tests/ProductionConfigTests.js"
27
+
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'vagrant/cienv'
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vagrant::Cienv do
4
+ it 'has a version number' do
5
+ expect(Vagrant::Cienv::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-qienv/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-qienv"
8
+ spec.version = VagrantPlugins::Cienv::VERSION
9
+ spec.authors = ["Alfredo Matas"]
10
+ spec.email = ["amatas@gmail.com"]
11
+
12
+ spec.summary = %q{Vagrant CI environment builder}
13
+ spec.description = %q{Vagrant CI environment builder}
14
+ spec.homepage = "http://github.com/amatas/vagrant-qienv.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files`.split($\)
26
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
27
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.11"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "method_source", "~> 0.8.2"
33
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-qienv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alfredo Matas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: method_source
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.2
55
+ description: Vagrant CI environment builder
56
+ email:
57
+ - amatas@gmail.com
58
+ executables:
59
+ - console
60
+ - setup
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - lib/envs/default.json
75
+ - lib/envs/linux-desktop.json
76
+ - lib/envs/production.yml
77
+ - lib/provisioning/base-playbook.yml
78
+ - lib/provisioning/couchdb-playbook.yml
79
+ - lib/provisioning/couchdb-requirements.yml
80
+ - lib/provisioning/couchdb-vagrant-vars.yml
81
+ - lib/provisioning/gpii-linux-playbook.yml
82
+ - lib/provisioning/gpii-linux-requirements.yml
83
+ - lib/provisioning/gpii-linux-vagrant-vars.yml
84
+ - lib/provisioning/nodejs-playbook.yml
85
+ - lib/provisioning/nodejs-requirements.yml
86
+ - lib/provisioning/nodejs-vagrant-vars.yml
87
+ - lib/provisioning/preferences-playbook.yml
88
+ - lib/provisioning/preferences-requirements.yml
89
+ - lib/provisioning/preferences-vagrant-vars.yml
90
+ - lib/vagrant-qienv.rb
91
+ - lib/vagrant-qienv/action.rb
92
+ - lib/vagrant-qienv/action/init_environment.rb
93
+ - lib/vagrant-qienv/command/base.rb
94
+ - lib/vagrant-qienv/command/init.rb
95
+ - lib/vagrant-qienv/command/test.rb
96
+ - lib/vagrant-qienv/config/config_folders.rb
97
+ - lib/vagrant-qienv/config/config_network.rb
98
+ - lib/vagrant-qienv/config/config_provider.rb
99
+ - lib/vagrant-qienv/config/config_provision.rb
100
+ - lib/vagrant-qienv/plugin.rb
101
+ - lib/vagrant-qienv/version.rb
102
+ - qi.yml.template
103
+ - samples/README.md
104
+ - samples/gpii-linux-production/.qi.yml
105
+ - samples/gpii-linux/.qi.yml
106
+ - samples/gpii-nexus/.qi.yml
107
+ - samples/gpii-universal/.qi.yml
108
+ - spec/spec_helper.rb
109
+ - spec/vagrant/cienv_spec.rb
110
+ - vagrant-cienv.gemspec
111
+ homepage: http://github.com/amatas/vagrant-qienv.git
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.5.2
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: Vagrant CI environment builder
135
+ test_files:
136
+ - spec/spec_helper.rb
137
+ - spec/vagrant/cienv_spec.rb