vagrant-gpii-ci 0.0.1 → 0.0.3

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +44 -62
  3. data/gpii-ci.yml.template +44 -0
  4. data/lib/vagrant-gpii-ci/action/build_vagrantfile.rb +160 -0
  5. data/lib/vagrant-gpii-ci/action/init_environment.rb +7 -8
  6. data/lib/vagrant-gpii-ci/action/update_hosts.rb +138 -0
  7. data/lib/vagrant-gpii-ci/action.rb +8 -101
  8. data/lib/vagrant-gpii-ci/command/base.rb +1 -1
  9. data/lib/vagrant-gpii-ci/command/ci.rb +66 -0
  10. data/lib/vagrant-gpii-ci/command/init.rb +2 -2
  11. data/lib/vagrant-gpii-ci/command/test.rb +55 -47
  12. data/lib/vagrant-gpii-ci/plugin.rb +19 -16
  13. data/lib/vagrant-gpii-ci/version.rb +2 -2
  14. data/lib/vagrant-gpii-ci.rb +16 -3
  15. data/samples/gpii-linux/.gpii-ci.yml +25 -0
  16. data/samples/gpii-nexus/.gpii-ci.yml +26 -0
  17. data/samples/gpii-universal/.gpii-ci.yml +32 -0
  18. data/samples/gpii-windows/.gpii-ci.yml +33 -0
  19. data/spec/spec_helper.rb +4 -1
  20. data/spec/vagrant/gpiici_spec.rb +12 -0
  21. data/{vagrant-cienv.gemspec → vagrant-gpiici.gemspec} +3 -3
  22. metadata +15 -32
  23. data/lib/envs/default.json +0 -20
  24. data/lib/envs/linux-desktop.json +0 -22
  25. data/lib/envs/production.yml +0 -33
  26. data/lib/provisioning/base-playbook.yml +0 -16
  27. data/lib/provisioning/couchdb-playbook.yml +0 -11
  28. data/lib/provisioning/couchdb-requirements.yml +0 -5
  29. data/lib/provisioning/couchdb-vagrant-vars.yml +0 -1
  30. data/lib/provisioning/gpii-linux-playbook.yml +0 -11
  31. data/lib/provisioning/gpii-linux-requirements.yml +0 -6
  32. data/lib/provisioning/gpii-linux-vagrant-vars.yml +0 -23
  33. data/lib/provisioning/nodejs-playbook.yml +0 -12
  34. data/lib/provisioning/nodejs-requirements.yml +0 -7
  35. data/lib/provisioning/nodejs-vagrant-vars.yml +0 -11
  36. data/lib/provisioning/preferences-playbook.yml +0 -13
  37. data/lib/provisioning/preferences-requirements.yml +0 -9
  38. data/lib/provisioning/preferences-vagrant-vars.yml +0 -5
  39. data/lib/vagrant-gpii-ci/config/config_folders.rb +0 -17
  40. data/lib/vagrant-gpii-ci/config/config_network.rb +0 -69
  41. data/lib/vagrant-gpii-ci/config/config_provider.rb +0 -40
  42. data/lib/vagrant-gpii-ci/config/config_provision.rb +0 -50
  43. data/qi.yml.template +0 -56
  44. data/samples/gpii-linux/.qi.yml +0 -22
  45. data/samples/gpii-linux-production/.qi.yml +0 -41
  46. data/samples/gpii-nexus/.qi.yml +0 -24
  47. data/samples/gpii-universal/.qi.yml +0 -27
  48. data/spec/vagrant/cienv_spec.rb +0 -11
@@ -1,11 +0,0 @@
1
- ---
2
-
3
- - hosts: localhost
4
- become: true
5
-
6
- vars_files:
7
- - "{{ lookup('env', 'VARS_FILE') }}"
8
-
9
- roles:
10
- - facts
11
- - nodejs
@@ -1,6 +0,0 @@
1
- - src: http://github.com/idi-ops/ansible-facts.git
2
- name: facts
3
-
4
- - src: http://github.com/amatas/ansible-nodejs.git
5
- version: test-vagrant-venv
6
- name: nodejs
@@ -1,23 +0,0 @@
1
- ---
2
-
3
- nodejs_npm_packages:
4
- - "@development-tools"
5
- - orca
6
- - glib2-devel
7
- - PackageKit-glib-devel
8
- - json-glib-devel
9
- - libXrandr-devel
10
- - libXrender-devel
11
- - libX11-devel
12
- - xorg-x11-proto-devel
13
- - alsa-lib-devel
14
- - tuxguitar
15
- nodejs_app_name: "{{ app_name | default('application') }}"
16
- #nodejs_version: "{{ software_stack_version }}"
17
- nodejs_app_commands: "{{ setup | default([]) }}"
18
- #nodejs_app_start_script: "{{ app_start_script }}"
19
- #nodejs_app_tcp_port: "{{ app_tcp_port }}"
20
- #nodejs_app_git_clone: false
21
- nodejs_app_git_repo: "{{ git_repository | default(false) }}"
22
- nodejs_app_git_branch: "{{ git_branch | default('master') }}"
23
- nodejs_app_install_dir: "{{ folder['dest'] }}"
@@ -1,12 +0,0 @@
1
- ---
2
-
3
- - hosts: localhost
4
- become: true
5
-
6
- vars_files:
7
- - "{{ lookup('env', 'VARS_FILE') }}"
8
-
9
- roles:
10
- - facts
11
- - nodejs
12
-
@@ -1,7 +0,0 @@
1
- - src: http://github.com/idi-ops/ansible-facts.git
2
- name: facts
3
-
4
- - src: https://github.com/amatas/ansible-nodejs.git
5
- version: test-vagrant-venv
6
- name: nodejs
7
-
@@ -1,11 +0,0 @@
1
- ---
2
-
3
- nodejs_app_name: "{{ app_name | default('application') }}"
4
- #nodejs_version: "{{ software_stack_version }}"
5
- nodejs_app_commands: "{{ setup | default([]) }}"
6
- #nodejs_app_start_script: "{{ app_start_script }}"
7
- #nodejs_app_tcp_port: "{{ app_tcp_port }}"
8
- #nodejs_app_git_clone: false
9
- nodejs_app_git_repo: "{{ git_repository | default(false) }}"
10
- nodejs_app_git_branch: "{{ git_branch | default('master') }}"
11
- nodejs_app_install_dir: "{{ folder['dest'] }}"
@@ -1,13 +0,0 @@
1
- ---
2
-
3
- - hosts: localhost
4
- become: true
5
-
6
- vars_files:
7
- - "{{ lookup('env', 'VARS_FILE') }}"
8
-
9
- roles:
10
- - facts
11
- - nodejs
12
- - preferences
13
-
@@ -1,9 +0,0 @@
1
- - src: http://github.com/idi-ops/ansible-facts.git
2
- name: facts
3
-
4
- - src: https://github.com/idi-ops/ansible-nodejs.git
5
- name: nodejs
6
-
7
- - src: https://github.com/gpii-ops/ansible-preferences-server.git
8
- name: preferences
9
-
@@ -1,5 +0,0 @@
1
- ---
2
-
3
- nodejs_app_install_dir: "{{ folder['dest'] }}"
4
- nodejs_app_git_repo: https://github.com/GPII/universal.git
5
- nodejs_app_git_branch: "{{ git_branch | default('master') }}"
@@ -1,17 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- def config_folders(instance, vm_id, apps, vagrant_ci_path)
5
-
6
- instance.vm.synced_folder ".", "/vagrant" # Always needed by the provisioning
7
- instance.vm.synced_folder vagrant_ci_path + "/provisioning", "/provisioning" # Always needed by the provisioning
8
-
9
- # Share folder if the "src" variable is set
10
- apps.each do |config|
11
- if config["run_in"] == vm_id and config["folder"] and config["folder"]["src"] then
12
- instance.vm.synced_folder config["folder"]["src"], config["folder"]["dest"]
13
- end
14
- end if apps
15
-
16
- end
17
-
@@ -1,69 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- # Builds a file with the list of pairs IP address: hostname which will be read
5
- # by Ansible to setup the hosts file in each VM
6
- # Params:
7
- # +env_vms+: object with the definition of the virtual machines
8
-
9
- def build_hosts_list(env_vms)
10
-
11
- int_id = 10
12
-
13
- first = true
14
- env_vms.each do |vm, vmconfig|
15
- vmconfig["networks"].each do |name, netcfg|
16
- if netcfg["type"] == "private" then
17
- if netcfg['ip'].nil? then
18
- netcfg['ip'] = "192.168.50." + int_id.to_s
19
- #add the default IP to the environment definnition
20
- env_vms[vm]["networks"][name]["ip"] = "192.168.50." + int_id.to_s
21
- int_id += 1
22
- end
23
- if first then
24
- $base_vars = "vms_hosts={"
25
- $base_vars << "\"#{netcfg['ip']}\":\"#{vm}\""
26
- first = false
27
- elsif
28
- $base_vars << ",\"#{netcfg['ip']}\":\"#{vm}\""
29
- end
30
- end
31
- end if vmconfig["networks"]
32
- end
33
- $base_vars << "}" if $base_vars
34
- end
35
-
36
- # Configure the network section of a virtual machine. You can set the type of
37
- # the network, the ip address if needed and a list of forwarded ports.
38
- # Params:
39
- # +instance+: The instance of the VM to configure
40
- # +vm_config+: the definition of the VM. There are to type of networks: private
41
- # - where the IP setting is available, and public - where virtualbox will set
42
- # the interface as an external NIC.
43
-
44
- def config_network(instance, vm_config)
45
-
46
- vm_config["networks"].each do |network, config|
47
- if config["type"] == "private" then
48
- if config["ip"] then
49
- instance.vm.network :private_network, ip: config["ip"]
50
- end
51
- elsif config["type"] == "public" then
52
- instance.vm.network :public_network
53
- end
54
- end if vm_config["networks"]
55
-
56
- vm_config["ports"].each do |port, config|
57
-
58
- raise "At least the guest port is needed in 'guest_port' variable" \
59
- if config["guest_port"].nil?
60
-
61
- instance.vm.network "forwarded_port",
62
- guest: config["guest_port"],
63
- host: config["host_port"] || config["guest_port"],
64
- protocol: config["protocol"] || "tcp",
65
- auto_correct: config["auto_correct"] || true
66
- end if vm_config["ports"]
67
-
68
- end
69
-
@@ -1,40 +0,0 @@
1
- # -*- mode: ruby -*-
2
- # vi: set ft=ruby :
3
-
4
- def config_provider(instance, vm_config, global_config)
5
-
6
- if global_config["provider"] == "virtualbox" then
7
-
8
- instance.vm.provider :virtualbox do |vm|
9
-
10
- vm.linked_clone = vm_config["clone"] || global_config["clone"] || false
11
-
12
- vm.customize ["modifyvm", :id, "--memory", vm_config["memory"] || global_config["memory"] ]
13
- vm.customize ["modifyvm", :id, "--cpus", vm_config["cpu"] || global_config["cpu"] ]
14
-
15
- if vm_config["gui"] == true then
16
- vm.customize ["modifyvm", :id, "--vram", "128"]
17
- vm.customize ["modifyvm", :id, "--accelerate3d", "on"]
18
- end
19
-
20
- if vm_config["sound"] == true then
21
- vm.customize ["modifyvm", :id, "--audio", "null", "--audiocontroller", "ac97"]
22
- end
23
-
24
- vm.customize ["modifyvm", :id, "--ioapic", "on"]
25
- vm.customize ["setextradata", "global", "GUI/SuppressMessages", "all"]
26
-
27
- vm.gui = vm_config["gui"] || global_config["gui"] || false
28
- end
29
-
30
- instance.vm.box = vm_config["box"]
31
-
32
- elsif global_config["provider"] == "libvirt" then
33
- raise "Not supported yet"
34
- else
35
- raise "Provider not defined in global configuration" unless global_config.include?('provider')
36
- raise "Provider #{global_config['provider']} not supported"
37
- end
38
-
39
- end
40
-
@@ -1,50 +0,0 @@
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
data/qi.yml.template DELETED
@@ -1,56 +0,0 @@
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 }}"
@@ -1,22 +0,0 @@
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
-
@@ -1,41 +0,0 @@
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 }}"
@@ -1,24 +0,0 @@
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
-
@@ -1,27 +0,0 @@
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
-
@@ -1,11 +0,0 @@
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