Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. require "yaml"
  4. require "vagrant-openstack-provider"
  5.  
  6. # Variable defaults (see below for overrides)
  7. $kube_version = "ubuntu/trusty64"
  8. $kube_memory = 512
  9. $kube_vcpus = 1
  10. $kube_count = 1
  11.  
  12. # Use a variable file for overrides:
  13. CONFIG = File.expand_path("config.rb")
  14. if File.exist?(CONFIG)
  15. require CONFIG
  16. end
  17.  
  18. # Force best practices for this environment:
  19. if $kube_memory < 512
  20. puts "WARNING: Your machine should have at least 512 MB of memory"
  21. end
  22.  
  23. # Install any Required Plugins
  24. missing_plugins_installed = false
  25. required_plugins = %w(vagrant-env vagrant-openstack-provider)
  26.  
  27. required_plugins.each do |plugin|
  28. if !Vagrant.has_plugin? plugin
  29. system "vagrant plugin install #{plugin}"
  30. missing_plugins_installed = true
  31. end
  32. end
  33.  
  34. # If any plugins were missing and have been installed, re-run vagrant
  35. if missing_plugins_installed
  36. exec "vagrant #{ARGV.join(" ")}"
  37. end
  38.  
  39.  
  40. # Vagrantfile API/sytax version. Don’t touch unless you know what you’re doing!
  41. VAGRANTFILE_API_VERSION = "2"
  42. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  43.  
  44. # Required line, override with variables later
  45. config.ssh.username = "ubuntu"
  46. config.ssh.private_key_path = "~/.ssh/id_rsa"
  47.  
  48. # Guest Definitions:
  49. # ------------------------
  50. #
  51. # START: Kube Definition(s)
  52. (1..$kube_count).each do |kb|
  53. config.vm.define vm_name = "kube#{kb}" do |kube|
  54. kube.vm.box = $kube_version
  55. kube.vm.hostname = "kube#{kb}"
  56. # NETWORK-SETTINGS: eth1 configured in the 192.168.236.0/24 network
  57. kube.vm.network "private_network", ip: "192.168.236.1#{kb}"
  58. kube.vm.network "forwarded_port", guest: 2368, host: "1236#{kb}", auto_correct: true
  59. # Openstack Provider (Optional --provider=openstack):
  60. kube.vm.provider "virtualbox" do |vb|
  61. vb.name = "kube#{kb}"
  62. vb.customize ["modifyvm", :id, "--memory", $kube_memory]
  63. vb.customize ["modifyvm", :id, "--cpus", $kube_vcpus]
  64. end
  65. # Openstack Provider (Optional --provider=openstack):
  66. kube.vm.provider "openstack" do |os|
  67. # Openstack Authentication Information:
  68. os.openstack_auth_url = $os_auth_url
  69. os.username = $os_username
  70. os.password = $os_password
  71. os.tenant_name = $os_tenant
  72. # Openstack Instance Information:
  73. os.server_name = "kube#{kb}"
  74. os.flavor = $os_flavor
  75. os.image = $os_image
  76. os.floating_ip_pool = $os_floatnet
  77. os.networks = $os_fixednet
  78. os.keypair_name = $os_keypair
  79. os.security_groups = $os_secgroups
  80. end
  81. end
  82. end
  83. # STOP: Kube Definition(s)
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement