Facebook
From Mungo Baboon, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 52
  1. $common_provision = <<SCRIPT
  2. cat <<EOF >> /etc/hosts
  3. 172.24.0.11 openshift-master.example.com openshift-master
  4. 172.24.0.12 openshift-node-1.example.com openshift-node-1
  5. 172.24.0.13 openshift-node-2.example.com openshift-node-2
  6. EOF
  7. sed -i '/^127.0.0.1.*openshift.*$/d' /etc/hosts
  8. yum -y update
  9. yum install -y docker
  10. systemctl start docker
  11. systemctl enable docker
  12. SCRIPT
  13.  
  14. $master_provision = <<SCRIPT
  15. yum -y install git epel-release
  16. yum -y install ansible
  17. git clone -b release-3.9 https://github.com/openshift/openshift-ansible /root/openshift-ansible
  18. ssh-keygen -f /root/.ssh/id_rsa -N ''
  19. cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys
  20. for i in 1 3; do ssh-keyscan 172.24.0.1$i; done >> .ssh/known_hosts
  21. cp .ssh/known_hosts /root/.ssh/known_hosts
  22. for i in 1 2; do sudo ssh-copy-id -o IdentityFile=/vagrant_private_keys/machines/openshift-node-$i/virtualbox/private_key -f -i /root/.ssh/id_rsa root@172.24.0.1$((i+1)); done
  23. reboot
  24. SCRIPT
  25.  
  26. $node_provision = <<SCRIPT
  27. cp -r /home/vagrant/.ssh /root
  28. reboot
  29. SCRIPT
  30.  
  31. Vagrant.configure(2) do |config|
  32.   config.vm.define "openshift-node-1" do |conf|
  33.     conf.vm.box = "centos/7"
  34.     conf.vm.hostname = 'openshift-node-1.example.com'
  35.     conf.vm.network "private_network", ip: "172.24.0.12"
  36.     conf.vm.provider "virtualbox" do |v|
  37.        v.memory = 2048
  38.        v.cpus = 2
  39.     end
  40.     conf.vm.provision "shell", inline: $common_provision
  41.     conf.vm.provision "shell", inline: $node_provision
  42.   end
  43.  
  44.   config.vm.define "openshift-node-2" do |conf|
  45.     conf.vm.box = "centos/7"
  46.     conf.vm.hostname = 'openshift-node-2.example.com'
  47.     conf.vm.network "private_network", ip: "172.24.0.13"
  48.     conf.vm.provider "virtualbox" do |v|
  49.        v.memory = 2048
  50.        v.cpus = 2
  51.     end
  52.     conf.vm.provision "shell", inline: $common_provision
  53.     conf.vm.provision "shell", inline: $node_provision
  54.   end
  55.  
  56.   config.vm.define "openshift-master" do |conf|
  57.     conf.vm.box = "centos/7"
  58.     conf.vm.hostname = 'openshift-master.example.com'
  59.     conf.vm.network "private_network", ip: "172.24.0.11"
  60.     conf.vm.synced_folder '.vagrant/', '/vagrant_private_keys', type: 'rsync'
  61.     conf.vm.provider "virtualbox" do |v|
  62.        v.memory = 4096
  63.        v.cpus = 2
  64.     end
  65.     conf.vm.provision "shell", inline: $common_provision
  66.     conf.vm.provision "shell", inline: $master_provision
  67.   end
  68. end