NadezhdaGeorgieva

DevOps3

Jun 4th, 2021
2,451
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- mode: ruby -*-
  2. # vi: set ft=ruby :
  3.  
  4. $install_docker_script = <<SCRIPT
  5. echo "Installing dependencies ..."
  6. sudo dnf -y upgrade
  7. sudo dnf -y install dnf-utils git
  8. echo Installing Docker...
  9. sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  10. sudo dnf -y install docker-ce docker-ce-cli containerd.io
  11. sudo systemctl enable docker
  12. sudo systemctl start docker
  13. sudo usermod -aG docker vagrant
  14. echo "* Configure Selinux and Firewall..."
  15. sudo setsebool -P httpd_can_network_connect=1
  16. sudo systemctl stop firewalld
  17. sudo systemctl disable firewalld
  18. SCRIPT
  19.  
  20. Vagrant.configure("2") do |config|
  21.   #Common setup
  22.   #config.vm.box_check_update = false
  23.  
  24.   #Setup Manager Node
  25.   config.vm.define "manager" do |manager|
  26.     manager.vm.box = "shekeriev/centos-8-minimal"
  27.     manager.vm.hostname = "manager"
  28.       manager.vm.network :private_network, ip: "192.168.89.105"
  29.       manager.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
  30.       manager.vm.synced_folder "app", "/vagrant", disabled: true
  31.     manager.vm.provision "shell", inline: $install_docker_script
  32.     manager.vm.provider :"virtualbox" do |vb|
  33.       vb.name = "manager"
  34.       vb.memory = "512"
  35.       vb.cpus = 2
  36.     end
  37.   end
  38.  
  39.   #Setup Woker1 Node
  40.   config.vm.define "worker1" do |worker|
  41.     worker.vm.box = "shekeriev/centos-8-minimal"
  42.     worker.vm.hostname = "worker1"
  43.       worker.vm.network :private_network, ip: "192.168.89.106"
  44.       worker.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
  45.       worker.vm.synced_folder "app", "/vagrant", disabled: true
  46.     worker.vm.provision "shell", inline: $install_docker_script
  47.     worker.vm.provider :"virtualbox" do |vb|
  48.       vb.name = "worker1"
  49.       vb.memory = "512"
  50.       vb.cpus = 2
  51.     end
  52.   end
  53.  
  54.   #Setup Woker2 Node
  55.   config.vm.define "worker2" do |node|
  56.     node.vm.box = "shekeriev/centos-8-minimal"
  57.     node.vm.hostname = "worker2"
  58.       node.vm.network :private_network, ip: "192.168.89.107"
  59.       node.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true
  60.       node.vm.synced_folder "app", "/vagrant", disabled: true
  61.     node.vm.provision "shell", inline: $install_docker_script
  62.     node.vm.provider :"virtualbox" do |vb|
  63.       vb.name = "worker2"
  64.       vb.memory = "512"
  65.       vb.cpus = 2
  66.     end
  67.   end
  68. end
  69.  
  70.  
  71.   # Share an additional folder to the guest VM.
  72.   # The first argument is the path on the host to the actual folder. /my local pc file system
  73.   # The second argument is the path on the guest to mount the folder. / vagrant file system
  74.   # And the optional third argument is a set of non-required options.
  75.   # config.vm.synced_folder "../data", "/vagrant_data"
RAW Paste Data