Vagrantfile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3. VAGRANTFILE_API_VERSION = "2"
  4. unless Vagrant.has_plugin?("vagrant-hostmanager")
  5. raise 'vagrant-hostmanager plugin is required'
  6. end
  7. Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  8. deployment_type = ENV['OPENSHIFT_DEPLOYMENT_TYPE'] || 'origin'
  9. num_nodes = (ENV['OPENSHIFT_NUM_NODES'] || 2).to_i
  10. config.hostmanager.enabled = true
  11. config.hostmanager.manage_host = true
  12. config.hostmanager.include_offline = true
  13. config.ssh.insert_key = false
  14. config.vm.provider "virtualbox" do |vbox, override|
  15. override.vm.box = "centos/7"
  16. vbox.memory = 1024
  17. vbox.cpus = 2
  18. # Enable multiple guest CPUs if available
  19. vbox.customize ["modifyvm", :id, "--ioapic", "on"]
  20. end
  21. config.vm.provider "libvirt" do |libvirt, override|
  22. libvirt.cpus = 2
  23. libvirt.memory = 1024
  24. libvirt.driver = 'kvm'
  25. case deployment_type
  26. when "enterprise"
  27. override.vm.box = "rhel-7"
  28. when "origin"
  29. override.vm.box = "centos/7"
  30. override.vm.box_download_checksum = "b2a9f7421e04e73a5acad6fbaf4e9aba78b5aeabf4230eebacc9942e577c1e05"
  31. override.vm.box_download_checksum_type = "sha256"
  32. end
  33. end
  34. num_nodes.times do |n|
  35. node_index = n+1
  36. config.vm.define "node#{node_index}" do |node|
  37. node.vm.hostname = "ose3-node#{node_index}.example.com"
  38. node.vm.network :private_network, ip: "192.168.100.#{200 + n}"
  39. config.vm.provision "shell", inline: "nmcli connection reload; systemctl restart NetworkManager.service"
  40. end
  41. end
  42. config.vm.define "master" do |master|
  43. master.vm.hostname = "ose3-master.example.com"
  44. master.vm.network :private_network, ip: "192.168.100.100"
  45. master.vm.network :forwarded_port, guest: 8443, host: 8443
  46. config.vm.provision "shell", inline: "nmcli connection reload; systemctl restart NetworkManager.service"
  47. master.vm.provision "ansible" do |ansible|
  48. ansible.limit = 'all'
  49. ansible.sudo = true
  50. ansible.groups = {
  51. "masters" => ["master"],
  52. "nodes" => ["master", "node1", "node2"],
  53. }
  54. ansible.extra_vars = {
  55. deployment_type: deployment_type,
  56. }
  57. ansible.playbook = "playbooks/byo/vagrant.yml"
  58. end
  59. end
  60. end