vagrant-gpii-ci 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-gpii-ci/action/init_environment.rb +24 -0
  29. data/lib/vagrant-gpii-ci/action.rb +122 -0
  30. data/lib/vagrant-gpii-ci/command/base.rb +19 -0
  31. data/lib/vagrant-gpii-ci/command/init.rb +28 -0
  32. data/lib/vagrant-gpii-ci/command/test.rb +65 -0
  33. data/lib/vagrant-gpii-ci/config/config_folders.rb +17 -0
  34. data/lib/vagrant-gpii-ci/config/config_network.rb +69 -0
  35. data/lib/vagrant-gpii-ci/config/config_provider.rb +40 -0
  36. data/lib/vagrant-gpii-ci/config/config_provision.rb +50 -0
  37. data/lib/vagrant-gpii-ci/plugin.rb +59 -0
  38. data/lib/vagrant-gpii-ci/version.rb +5 -0
  39. data/lib/vagrant-gpii-ci.rb +18 -0
  40. data/qi.yml.template +56 -0
  41. data/samples/README.md +12 -0
  42. data/samples/gpii-linux/.qi.yml +22 -0
  43. data/samples/gpii-linux-production/.qi.yml +41 -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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f84a3bc955514289f984de6bd5b4b18f42e31ca6
4
+ data.tar.gz: a794a423590916f864c43d5b870a5c2438f45e3e
5
+ SHA512:
6
+ metadata.gz: 164d38c4cc0b4d7c92f3dde9180cf06dba4fba575a188cb1b1a13cf84457988e63cc940116793bd58c2f690da87e8b03674a2c82e85cbcb191fc9331ee326bf8
7
+ data.tar.gz: 529c4a02a5f24b8fb52f68f0dffdabcf26c81493aab6b5fba9f5c458cc8be04145bb4a1b6dbce8fc0dd8f69310537571d8d8a9c94cd8e6b00883606cf062139c
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .vagrant
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at amatas@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ gem "vagrant-spec", git: "https://github.com/mitchellh/vagrant-spec.git"
6
+ end
7
+
8
+ group :plugins do
9
+ gemspec
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Alfredo Matas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ Vagrant-vmenv
2
+ =============
3
+
4
+ Vagrant-vmenv is a npm module that is used to extend the behavior of a
5
+ Vagrantfile. It uses virtual machine definitions to spin up complete
6
+ enviroments where you can run tests or run your code.
7
+
8
+ Installation
9
+ ------------
10
+
11
+ ```
12
+ npm install -g http://github.com/amatas/vagrant-vmenv
13
+ cp node_modules/vagrant-vmenv/Vagrantfile.template Vagrantfile
14
+ cp node_modules/vagrant-vmenv/qi.yml.template .qi.yml
15
+ ```
16
+
17
+ The Vagrantfile acts as a pointer to the module, it shouldn't be modified. If
18
+ you want to make a change at the environment level do so in the [environment
19
+ configuration file](envs/), and if you want to configure how the applications
20
+ are deployed and tested do so in the [.qi.yml](qi.yml.template) file of your
21
+ repository.
22
+
23
+ Working with vms
24
+ ----------------
25
+
26
+ Commands:
27
+
28
+ * `vagrant up` to spin up the [environment](envs/) defined in the .qi.yml file.
29
+ * `vagrant destroy` to stop and destroy the vm.
30
+ * `vagrant halt` to shutdown the vm without destroy it.
31
+
32
+ Note:
33
+
34
+ * `vagrant up` will exec the commands listed in the *setup* variable of each
35
+ application listed in the .qi.yml file.
36
+ * `vagrant provision` will exec the commands listed in the *test_cmds* variable
37
+ of each application listed in the .qi.yml file.
38
+
39
+ Networking
40
+ ----------
41
+
42
+ A VM can have multiple virtual NICs. Two types are avilable for each NIC: public
43
+ and private. The public NICs will be attached to the host's physical network,
44
+ the private NICs will be attached to a private network only visible between the
45
+ other VMs and the host. The IP address of a private network can be customized in
46
+ the definition of the VM. An example of the network definition of a VM can be:
47
+
48
+ ```
49
+ networks:
50
+ privatenet:
51
+ type: private
52
+ ip: 192.168.45.22
53
+ publicnet:
54
+ type: public
55
+ ```
56
+
57
+ If an environment has multiple VMs definitions with several NICs the *hosts*
58
+ file of each VM will list all the IP address of each VM plus the name of the VM,
59
+ this is very useful to point services between the VMs.
60
+
61
+ Forwarded ports
62
+ ---------------
63
+
64
+ The port forwarding is configured in the VMs definition. The `guest_port`
65
+ variable is the source port to be mapped to the `host_port` variable. The
66
+ `guest_port` must be set in each port forward block, `host_port` and protocol are
67
+ optionals.
68
+
69
+ ```
70
+ ports:
71
+ - guest_port: 8080
72
+ host_port: 8888
73
+ protocol: tcp
74
+ - guest_port: 8181
75
+ host_port: 9999
76
+ - guest_port:8081
77
+ ```
78
+
79
+ Shared folders
80
+ --------------
81
+
82
+ Each application can use a shared folder. If the *folder* variable of the
83
+ application has a *src* key, Vagrant will map the path set in the src folder of
84
+ the host to the path set in the *dest* variable in the VM.
85
+
86
+ ```
87
+ folder:
88
+ src: "."
89
+ dest: "/app/universal"
90
+ ```
91
+
92
+ More samples definitions can be found either in the [envs](envs) directory or in
93
+ the [qi.yml.template](qi.yml.template).
94
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vagrant/cienv"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+ {
2
+ "global": {
3
+ "provider": "virtualbox",
4
+ "cpu": 2,
5
+ "memory": 1024
6
+ },
7
+ "vms": {
8
+ "fedora": {
9
+ "autostart": true,
10
+ "box": "inclusivedesign/centos7",
11
+ "folders": {
12
+ "code": {
13
+ "src": ".",
14
+ "dest": "/home/vagrant/sync"
15
+ }
16
+ }
17
+ }
18
+ }
19
+ }
20
+
@@ -0,0 +1,22 @@
1
+ {
2
+ "global": {
3
+ "provider": "virtualbox",
4
+ "cpu": 2,
5
+ "memory": 1024
6
+ },
7
+ "vms": {
8
+ "fedora": {
9
+ "autostart": true,
10
+ "box": "inclusivedesign/fedora24",
11
+ "gui": true,
12
+ "sound": true,
13
+ "folders": {
14
+ "code": {
15
+ "src": ".",
16
+ "dest": "/home/vagrant/sync"
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+
@@ -0,0 +1,33 @@
1
+ ---
2
+
3
+ global:
4
+ provider: virtualbox
5
+ cpu: 2
6
+ memory: 1024
7
+ vms:
8
+ server:
9
+ autostart: true
10
+ box: inclusivedesign/centos7
11
+ gui: false
12
+ networks:
13
+ private:
14
+ type: private
15
+ folders:
16
+ code:
17
+ src: "."
18
+ dest: "/home/vagrant/sync/node_modules/universal"
19
+ fedora:
20
+ autostart: true
21
+ box: inclusivedesign/fedora24
22
+ gui: true
23
+ sound: true
24
+ cpu: 4
25
+ memory: 2048
26
+ networks:
27
+ private:
28
+ type: private
29
+ folders:
30
+ code:
31
+ src: "."
32
+ dest: "/home/vagrant/sync/node_modules/universal"
33
+
@@ -0,0 +1,16 @@
1
+ ---
2
+
3
+ - hosts: localhost
4
+ become: true
5
+
6
+ pre_tasks:
7
+ - name: Set hostname
8
+ hostname: "name={{ lookup('env', 'VM_HOSTNAME') }}"
9
+
10
+ - name: "Build hosts file"
11
+ lineinfile:
12
+ dest: /etc/hosts
13
+ line: "{{ item.key }} {{ item.value }}"
14
+ state: present
15
+ with_dict: "{{ vms_hosts|default({}) }}"
16
+
@@ -0,0 +1,11 @@
1
+ ---
2
+
3
+ - hosts: localhost
4
+ become: true
5
+
6
+ vars_files:
7
+ - "{{ lookup('env', 'VARS_FILE') }}"
8
+
9
+ roles:
10
+ - facts
11
+ - couchdb
@@ -0,0 +1,5 @@
1
+ - src: http://github.com/idi-ops/ansible-couchdb.git
2
+ name: couchdb
3
+
4
+ - src: http://github.com/idi-ops/ansible-facts.git
5
+ name: facts
@@ -0,0 +1 @@
1
+ ---
@@ -0,0 +1,11 @@
1
+ ---
2
+
3
+ - hosts: localhost
4
+ become: true
5
+
6
+ vars_files:
7
+ - "{{ lookup('env', 'VARS_FILE') }}"
8
+
9
+ roles:
10
+ - facts
11
+ - nodejs
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,23 @@
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'] }}"
@@ -0,0 +1,12 @@
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
+
@@ -0,0 +1,7 @@
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
+
@@ -0,0 +1,11 @@
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'] }}"
@@ -0,0 +1,13 @@
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
+
@@ -0,0 +1,9 @@
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
+
@@ -0,0 +1,5 @@
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') }}"
@@ -0,0 +1,24 @@
1
+ require "log4r"
2
+
3
+ module VagrantPlugins
4
+ module Cienv
5
+ module Action
6
+
7
+ # This action sets up the QI QI environment
8
+ class InitEnvironment
9
+
10
+ def initialize(app, env)
11
+ @app = app
12
+ @logger = Log4r::Logger.new("vagrant_qi::action::init_environment")
13
+ end
14
+
15
+ def call(env)
16
+ puts "i am inside class InitEnvironment"
17
+ @logger.info('i am inside class InitEnvironment - call()')
18
+ @app.call(env)
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,122 @@
1
+ require "pathname"
2
+ require 'json'
3
+ require 'yaml'
4
+
5
+ require "vagrant/action/builder"
6
+
7
+ module VagrantPlugins
8
+ module Cienv
9
+ module Action
10
+ # Include the built-in modules so we can use them as top-level things.
11
+ include Vagrant::Action::Builtin
12
+
13
+ def self.action_init
14
+ Vagrant::Action::Builder.new.tap do |b|
15
+ b.use InitEnvironment
16
+ end
17
+ end
18
+
19
+ # The autoload farm
20
+ action_root = Pathname.new(File.expand_path("../action", __FILE__))
21
+ autoload :InitEnvironment, action_root.join("init_environment")
22
+
23
+ class BuildVagrantfile
24
+
25
+ def gem_path
26
+ Pathname.new(File.dirname __dir__)
27
+ end
28
+
29
+ def project_home
30
+ environment = @env[:env]
31
+ environment.instance_variable_get(:@cwd)
32
+ end
33
+
34
+ def vagrant_home
35
+ project_home.join(Vagrant::Environment::DEFAULT_LOCAL_DATA)
36
+ end
37
+
38
+ def initialize(app, env)
39
+ @app = app
40
+ @env = env
41
+ environment = @env[:env]
42
+
43
+ # Only make all the magic if the .qi.yml definition file is found
44
+ return if !File.exist?(project_home.join(".qi.yml"))
45
+
46
+ require_relative "config/config_provider.rb"
47
+ require_relative "config/config_provision.rb"
48
+ require_relative "config/config_network.rb"
49
+ require_relative "config/config_folders.rb"
50
+
51
+ # $vagrant_vmenv_path = vagrant_home.to_s + "/provision-ci/"
52
+
53
+ # load the .qi.yml file
54
+ qi_file = File.expand_path (project_home.join(".qi.yml"))
55
+ qi_definition = YAML.load(File.read(qi_file))
56
+
57
+ # Copy enviroments and playbooks to home dir if needed
58
+ FileUtils.mkdir(vagrant_home) if !File.exist?(vagrant_home)
59
+ FileUtils.mkdir(vagrant_home.join('provision-ci')) if !File.exist?(vagrant_home.join('provision-ci'))
60
+ FileUtils.cp_r(gem_path.join('envs'), vagrant_home.join('provision-ci/envs')) if !File.exist?(vagrant_home.join('provision-ci/envs'))
61
+ FileUtils.cp_r(gem_path.join('provisioning'), vagrant_home.join('provision-ci/provisioning')) if !File.exist?(vagrant_home.join('provision-ci/provisioning'))
62
+
63
+ # load the environment based on "env_runtime" variable of .qi.yml
64
+ vagrant_env = qi_definition["env_runtime"] || "default"
65
+ environment_file = File.expand_path(vagrant_home.to_s + "/provision-ci/envs", File.dirname(__FILE__)) +
66
+ File::SEPARATOR + vagrant_env
67
+ if File.exists?(environment_file + ".json")
68
+ environment_ci = JSON.parse(File.read(environment_file + ".json"))
69
+ elsif File.exists?(environment_file + ".yml")
70
+ environment_ci = YAML.load(File.read(environment_file + ".yml"))
71
+ else
72
+ raise "Environment_ci config file not found, see envs directory\n #{environment_file}"
73
+ end
74
+
75
+ # build the host list of the VMs used, very useful to allow the communication
76
+ # between them based on the hostname and IP stored in the hosts file
77
+ build_hosts_list(environment_ci["vms"])
78
+
79
+ vagrantfile_proc = Proc.new do
80
+ Vagrant.configure(2) do |config|
81
+
82
+ environment_ci["vms"].each do |vm_id, vm_config|
83
+
84
+ config.vm.define vm_id, autostart: vm_config["autostart"] do |instance|
85
+
86
+ # Ansible handles this task better than Vagrant
87
+ #instance.vm.hostname = vm_id
88
+
89
+ config_provider(instance, vm_config, environment_ci["global"])
90
+
91
+ config_provision(instance, vm_config, vm_id, qi_definition["apps"], vagrant_home.join('provision-ci').to_s)
92
+
93
+ config_network(instance, vm_config)
94
+
95
+ config_folders(instance, vm_id, qi_definition["apps"], vagrant_home.join('provision-ci').to_s)
96
+
97
+ end
98
+ end
99
+ end
100
+ end
101
+
102
+ # The Environment instance has been instantiated without a Vagrantfile
103
+ # that means that we need to store some internal variables and
104
+ # instantiate again the Vagrantfile instance with our previous code.
105
+
106
+ environment.instance_variable_set(:@root_path, project_home)
107
+ environment.instance_variable_set(:@local_data_path, vagrant_home)
108
+
109
+ # the cienv code will be the first item to check in the list of
110
+ # Vagrantfile sources
111
+ config_loader = environment.config_loader
112
+ config_loader.set(:cienv, vagrantfile_proc.call)
113
+ environment.instance_variable_set(:@vagrantfile, Vagrant::Vagrantfile.new(config_loader, [:cienv, :home, :root]))
114
+
115
+ end
116
+ def call(env)
117
+ @app.call(env)
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,19 @@
1
+ require "vagrant/plugin/state_file"
2
+
3
+ module VagrantPlugins
4
+ module Cienv
5
+ module Command
6
+ class Base < Vagrant.plugin("2", :command)
7
+ # This is a helper for executing an action sequence with the proper
8
+ # environment hash setup so that the plugin specific helpers are
9
+ # in.
10
+ #
11
+ # @param [Object] callable the Middleware callable
12
+ # @param [Hash] env Extra environment hash that is merged in.
13
+ def action(callable, env=nil)
14
+ @env.action_runner.run(callable, env)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ require 'optparse'
2
+
3
+ require_relative "base"
4
+
5
+ module VagrantPlugins
6
+ module Cienv
7
+ module Command
8
+ class InitEnvironment < Base
9
+ def execute
10
+ opts = OptionParser.new do |o|
11
+ o.banner = "Usage: vagrant qi init [-h]"
12
+ end
13
+
14
+ # Parse the options
15
+ argv = parse_options(opts)
16
+ return if !argv
17
+ raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp if argv.length > 0
18
+
19
+ # List the installed plugins
20
+ action(Action.action_init)
21
+
22
+ # Success, exit status 0
23
+ 0
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end