Vagrantfile 1.77 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
  config.vm.define "ohpc" do |ohpc|
10
    ohpc.vm.box = "centos/7"
John-Paul Robinson's avatar
John-Paul Robinson committed
11
12
13
14
15
    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

16
  config.vm.define "ood" do |ood|
17
    ood.vm.box = "centos/7"
18
    ood.vm.hostname = "ood"
19
    ood.vm.network "private_network", ip: "10.1.1.254", virtualbox__intnet: "compute"
20
21
22
23
    ood.vm.network "forwarded_port", guest: 80, host: 8080,
      auto_correct: true
    ood.vm.network "forwarded_port", guest: 443, host: 8443,
      auto_correct: true
24
25
  end

John-Paul Robinson's avatar
John-Paul Robinson committed
26
27
28
29
30
  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
31
32
  # define user's key and insecure default
  # insecure default is required for initial provisioning
33
  config.ssh.private_key_path = ["~/.ssh/id_rsa", "~/.vagrant.d/insecure_private_key"]
John-Paul Robinson's avatar
John-Paul Robinson committed
34
35
36
37
38
39
40
41
  # 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
42

John-Paul Robinson's avatar
John-Paul Robinson committed
43
44
45
46
47
  config.vm.provision "shell", inline: <<-SHELL
    if [ -f /vagrant/localenv.sh ]; then
      . /vagrant/localenv.sh
    fi

48
    yum install -y epel-release
John-Paul Robinson's avatar
John-Paul Robinson committed
49
    yum install -y ansible git vim bash-completion
50
    ansible-playbook -c local -i /vagrant/CRI_XCBC/hosts -l `hostname` /vagrant/CRI_XCBC/site.yaml -b
John-Paul Robinson's avatar
John-Paul Robinson committed
51
52
53
54

  SHELL

end