summaryrefslogtreecommitdiffstats
path: root/roles/ands_vagrant_vm
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-02-16 20:54:52 +0100
committerSuren A. Chilingaryan <csa@suren.me>2018-02-16 20:54:52 +0100
commit96ced00e05b50f276841a9212ae89e018de4d92d (patch)
treeb86c75fa97326dc89cc37c6dd23d294bd13eb56a /roles/ands_vagrant_vm
parentcd94e324d3401e518578d91382a2b7ee67562112 (diff)
downloadands-96ced00e05b50f276841a9212ae89e018de4d92d.tar.gz
ands-96ced00e05b50f276841a9212ae89e018de4d92d.tar.bz2
ands-96ced00e05b50f276841a9212ae89e018de4d92d.tar.xz
ands-96ced00e05b50f276841a9212ae89e018de4d92d.zip
Updated to OpenShift 3.7 and tested
Diffstat (limited to 'roles/ands_vagrant_vm')
-rw-r--r--roles/ands_vagrant_vm/README7
-rw-r--r--roles/ands_vagrant_vm/defaults/main.yml2
-rw-r--r--roles/ands_vagrant_vm/templates/Vagrantfile.j230
3 files changed, 28 insertions, 11 deletions
diff --git a/roles/ands_vagrant_vm/README b/roles/ands_vagrant_vm/README
index ca4f0d5..1c271b4 100644
--- a/roles/ands_vagrant_vm/README
+++ b/roles/ands_vagrant_vm/README
@@ -7,7 +7,7 @@ Parameters:
- vagrant_project - The vagrant project name, just specifies a subdirectory with virtual machines to allow parallel execution of VMs for testing and staging setups
- vagrant_projects_dir - Location of all vagrant projects
- vagrant_project_dir - Location of this specific vagrant project, normally is vagrant_projects_dir/vagrant_project
- - vagrant_hosts - Number of VMs to generate, defaults to number of configured ands_hosts (i.e. OpenShift nodes currently)
+ - vagrant_hosts - Number of VMs to generate, defaults to number of configured ands_servers (i.e. OpenShift nodes currently)
- vagrant_cpu_cores - Number of CPU cores for each VM
- vagrant_mem_size - Memory per VM in GB
- vagrant_disk_size - Data disk size per VM in GB
@@ -17,3 +17,8 @@ Facts:
Actions:
- Creates and starts VMs
+
+
+ToDo:
+ - We need to install a couple of vagrant plugins (requires vbox 5.2)
+ vagrant plugin install vagrant-disksize
diff --git a/roles/ands_vagrant_vm/defaults/main.yml b/roles/ands_vagrant_vm/defaults/main.yml
index 93d92b6..8387ac2 100644
--- a/roles/ands_vagrant_vm/defaults/main.yml
+++ b/roles/ands_vagrant_vm/defaults/main.yml
@@ -5,4 +5,4 @@ vagrant_project_dir: "/home/vagrant/projects/{{vagrant_project}}"
vagrant_disk_size: 60200
vagrant_mem_size: 16384
vagrant_cpu_cores: 4
-vagrant_hosts: {{ groups.ands_hosts | length }}
+vagrant_hosts: "{{ groups.ands_servers | length }}"
diff --git a/roles/ands_vagrant_vm/templates/Vagrantfile.j2 b/roles/ands_vagrant_vm/templates/Vagrantfile.j2
index 54128d4..b044e2e 100644
--- a/roles/ands_vagrant_vm/templates/Vagrantfile.j2
+++ b/roles/ands_vagrant_vm/templates/Vagrantfile.j2
@@ -2,25 +2,32 @@
# vi: set ft=ruby :
{% set net = ands_openshift_network | ipaddr('network') | ipaddr(0) | regex_replace('\.\d+$', '') %}
{% set storage_net = ands_storage_network | ipaddr('network') | ipaddr(0) | regex_replace('\.\d+$', '') %}
+{% set public_net = ands_openshift_public_network | ipaddr('network') | ipaddr(0) | regex_replace('\.\d+$', '') %}
{% set netid = ( net | regex_replace('^.*\.', '') ) %}
{% set storage_netid = ( storage_net | regex_replace('^.*\.', '') ) %}
+{% set public_netid = ( public_net | regex_replace('^.*\.', '') ) %}
{% set macid = ( (netid | length) > 2 ) | ternary(netid, "0" ~ netid) %}
Vagrant.configure("2") do |config|
(1..{{ vagrant_hosts }}).each do |i|
config.vm.define "{{ vagrant_hostname_template }}#{i}" do |node|
- node.vm.network "public_network", bridge: "br0", mac: "080027{{ macid }}02#{i}", ip: "{{ net }}.#{i}"
- node.vm.network "private_network", mac: "080027{{ macid }}12#{i}", ip: "{{ storage_net }}.#{i}", name: "vboxnet0"
+ node.vm.network "public_network", nm_controlled: "yes", bridge: "br0", mac: "080027{{ macid }}02#{i}", ip: "{{ public_net }}.#{i}", type: "dhcp"
+ node.vm.network "private_network", nm_controlled: "yes", mac: "080027{{ macid }}12#{i}", ip: "{{ storage_net }}.#{i}", name: "vboxnet0", type: "static"
node.vm.box = "centos/7"
+ node.disksize.size = "80 GB"
node.vm.hostname = "{{ vagrant_hostname_template }}#{i}.ipe.kit.edu"
# node.vm.synced_folder "../data", "/root/data"
# Configuring DHCP in 'vm.network' causes 2 DHCP clients (dhclinet & nm) running in parallel and getting 2 IPs.
- node.vm.provision "shell", run: "always", inline: "( ip addr show | grep -v 141.52.64.15 | grep -v 141.52.64.17 | grep -v 141.52.64.28 | grep 141.52 ) || dhclient -cf /var/lib/NetworkManager/dhclient-eth0.conf eth1"
- node.vm.provision "shell", run: "always", inline: "( ip addr show | grep {{ netid }}.#{i} ) || ip addr add 192.168.{{ netid }}.#{i}/24 dev eth1"
- node.vm.provision "shell", run: "always", inline: "( ip addr show | grep {{ storage_netid }}.#{i} ) || ifcfg eth2 192.168.{{ storage_netid }}.#{i}"
+# node.vm.provision "shell", run: "always", inline: "( ip addr show dev eth1 | grep -v 141.52.64.15 | grep -v 141.52.64.17 | grep -v 141.52.64.28 | grep 141.52 ) || dhclient -cf /var/lib/NetworkManager/dhclient-eth0.conf eth1"
+ node.vm.provision "shell", run: "always", inline: "( ip addr show dev eth1 | grep {{ public_netid }}.#{i} ) || ip addr add 192.168.{{ public_netid }}.#{i}/24 dev eth1"
+
+ node.vm.provision "shell", run: "always", inline: "( ip addr show dev eth2 | grep {{ storage_netid }}.#{i} ) || ip addr add 192.168.{{ storage_netid }}.#{i}/24 dev eth2"
+ node.vm.provision "shell", run: "always", inline: "( ip addr show dev eth2 | grep {{ netid }}.#{i} ) || ip addr add 192.168.{{ netid }}.#{i}/24 dev eth2"
node.vm.provision "shell", run: "always", inline: "chmod +r /etc/sysconfig/network-scripts/ifcfg-eth*"
node.vm.provision "shell", run: "always", inline: "chcon --reference /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth*"
+
+ node.vm.provision "shell", run: "always", inline: "ip route del default dev eth0"
node.vm.provision "shell" do |s|
ssh_pub_key = File.readlines("authorized_keys").first.strip
@@ -36,15 +43,20 @@ Vagrant.configure("2") do |config|
#vb.gui = true
vb.customize [
"modifyvm", :id,
+ "--natnet1", "192.168.23#{i}/24",
# "--ostype", "Linux_64",
"--audio", "none",
]
- vb.customize [
+ unless File.exist?("../disks/#{i}.vdi")
+ vb.customize [
'createhd', '--filename', "../disks/#{i}", '--format', 'VDI', '--size', {{ 1024 * (vagrant_disk_size | int) }}
- ]
- vb.customize [
+ ]
+ vb.customize [
'storageattach', :id, '--storagectl', 'IDE Controller', '--port', 1, '--device', 0,'--type', 'hdd', '--medium', "../disks/#{i}.vdi"
- ]
+# Since VirtualBox 5.1
+# 'storageattach', :id, '--storagectl', 'IDE', '--port', 1, '--device', 0,'--type', 'hdd', '--medium', "../disks/#{i}.vdi"
+ ]
+ end
end
end
end