Vagrantfile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "openshift-enterprise"
  27. override.vm.box = "rhel-7"
  28. when "atomic-enterprise"
  29. override.vm.box = "rhel-7"
  30. when "origin"
  31. override.vm.box = "centos/7"
  32. override.vm.box_download_checksum = "b2a9f7421e04e73a5acad6fbaf4e9aba78b5aeabf4230eebacc9942e577c1e05"
  33. override.vm.box_download_checksum_type = "sha256"
  34. end
  35. end
  36. num_nodes.times do |n|
  37. node_index = n+1
  38. config.vm.define "node#{node_index}" do |node|
  39. node.vm.hostname = "ose3-node#{node_index}.example.com"
  40. node.vm.network :private_network, ip: "192.168.100.#{200 + n}"
  41. config.vm.provision "shell", inline: "nmcli connection reload; systemctl restart NetworkManager.service"
  42. end
  43. end
  44. config.vm.define "master" do |master|
  45. master.vm.hostname = "ose3-master.example.com"
  46. master.vm.network :private_network, ip: "192.168.100.100"
  47. master.vm.network :forwarded_port, guest: 8443, host: 8443
  48. config.vm.provision "shell", inline: "nmcli connection reload; systemctl restart NetworkManager.service"
  49. master.vm.provision "ansible" do |ansible|
  50. ansible.limit = 'all'
  51. ansible.sudo = true
  52. ansible.groups = {
  53. "masters" => ["master"],
  54. "nodes" => ["master", "node1", "node2"],
  55. }
  56. ansible.extra_vars = {
  57. deployment_type: deployment_type,
  58. }
  59. ansible.playbook = "playbooks/byo/vagrant.yml"
  60. end
  61. end
  62. end