Vagrantfile 1.81 KB
Newer Older
John-Paul Robinson's avatar
John-Paul Robinson committed
1
2
3
4
5
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

John-Paul Robinson's avatar
John-Paul Robinson committed
6
7
8
  # don't configure host-specific keys, config will use the user's key
  config.ssh.insert_key = false

John-Paul Robinson's avatar
John-Paul Robinson committed
9
10
11
12
13
14
15
16
  config.vm.define "ohpc" do |ohpc|
    ohpc.vm.box = "ravi89/centos7.5"
    ohpc.vm.box_version = "1"
    ohpc.vm.hostname = "ohpc"
    ohpc.vm.network "private_network", ip: "10.1.1.1", virtualbox__intnet: "compute"
    #ohpc.vm.customize ["modifyvm", :id, "--name", "ohpc"]
  end

17
18
19
  config.vm.define "ood" do |ood|
    ood.vm.box = "ravi89/centos7.5"
    ood.vm.box_version = "1"
20
    ood.vm.hostname = "ood"
21
    ood.vm.network "private_network", ip: "10.1.1.254", virtualbox__intnet: "compute"
22
23
24
25
    ood.vm.network "forwarded_port", guest: 80, host: 8080,
      auto_correct: true
    ood.vm.network "forwarded_port", guest: 443, host: 8443,
      auto_correct: true
26
27
  end

John-Paul Robinson's avatar
John-Paul Robinson committed
28
29
30
31
32
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    vb.memory = "2048"
  end

John-Paul Robinson's avatar
John-Paul Robinson committed
33
34
  # define user's key and insecure default
  # insecure default is required for initial provisioning
35
  config.ssh.private_key_path = ["~/.ssh/id_rsa", "~/.vagrant.d/insecure_private_key"]
John-Paul Robinson's avatar
John-Paul Robinson committed
36
37
38
39
40
41
42
43
  # append user's key to vagrant config to avoid overwrite of existing authorized_keys
  # https://stackoverflow.com/a/31153912/8928529
  config.vm.provision "ssh_pub_key", type: "shell" do |s|
      ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
      s.inline = <<-SHELL
        echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
      SHELL
  end
44

John-Paul Robinson's avatar
John-Paul Robinson committed
45
46
47
48
49
50
51
52
53
54
55
  config.vm.provision "shell", inline: <<-SHELL
    if [ -f /vagrant/localenv.sh ]; then
      . /vagrant/localenv.sh
    fi

    yum install -y ansible git vim bash-completion
    ansible-playbook -c local -i /vagrant/CRI_XCBC/hosts -l `hostname` /vagrant/CRI_XCBC/site.yaml

  SHELL

end