Skip to content

Commit

Permalink
Implement Vagrant (#34)
Browse files Browse the repository at this point in the history
* (WIP) Create Vagrant README, basic files, setup shellscript

Signed-off-by: lbgracioso <[email protected]>

* Add Rocky support, create a extra disk to each machine

Signed-off-by: lbgracioso <[email protected]>

* Add Rocky support, create a extra disk to each machine

Signed-off-by: lbgracioso <[email protected]>

* Remove unused file

Signed-off-by: lbgracioso <[email protected]>

* Improve shellscript code

Signed-off-by: lbgracioso <[email protected]>

* Suppress the use of NFS on /vagrant folder, change to rsync

Signed-off-by: lbgracioso <[email protected]>

* Change shellscript variables, remove rsync '/mnt/iso' from Vagrantfile,  add new answerfiles, update README

Signed-off-by: lbgracioso <[email protected]>

* Change /opt/iso perms, run Cloyster binary with sudo, change rocky8 Vagrant box

Signed-off-by: lbgracioso <[email protected]>

* Fix RHEL8 shellscript

Signed-off-by: lbgracioso <[email protected]>

* Update README.md ISOs

Signed-off-by: lbgracioso <[email protected]>

---------

Signed-off-by: lbgracioso <[email protected]>
  • Loading branch information
lbgracioso committed Feb 20, 2024
1 parent d183240 commit 7a70107
Show file tree
Hide file tree
Showing 12 changed files with 665 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,6 @@ tags
.ionide

# End of https://www.toptal.com/developers/gitignore/api/c,c++,cmake,ninja,macos,linux,executable,visualstudiocode,vim,clion+all,pvs,sonar

# Vagrant auto-generated folder
.vagrant
2 changes: 1 addition & 1 deletion example.answerfile.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ domain_name=cluster.example.com
[system]
# Full path to the disk image
disk_image=/root/OracleLinux-R8-U7-x86_64-dvd.iso
# Supported distros: rhel, ol, rocky
# Supported distros: rhel, ol, rocky, almalinux
distro=ol
version=8.7
kernel=5.4.17-2136.302.6.1.el8uek.x86_64
Expand Down
58 changes: 58 additions & 0 deletions vagrant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Vagrant

## Configuration

**Please run all commands in this file as root or with elevated privileges.**

### Dependencies

```shell
$ dnf install -y dnf-plugins-core libvirt libvirt-devel qemu-kvm virt-install

$ dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo

$ dnf -y install vagrant

$ vagrant plugin install vagrant-libvirt vagrant-scp
```

---

### Configure libvirt

First, enable **libvirt** it by using:
```shell
$ systemctl enable --now libvirtd`
$ systemctl start libvirtd
```

And then you must create a CA cert for it
```shell
$ mkdir -p /etc/pki/CA/private
$ openssl req -x509 -newkey rsa:4096 -keyout /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 3650
$ chmod 600 /etc/pki/CA/private/cakey.pem
$ chmod 644 /etc/pki/CA/cacert.pem
```

---

## Running

Run `./setupVagrant /path/to/cloyster_binary
<vagrant_machine_name> <iso_image_path>` in this directory.

You can SSH to the machine using `vagrant ssh <vagrant_machine_name>`.

Already tested ISOs:

| Name | 8.8 |
|------------|---------|
| RHEL | Passing |
| RockyLinux | Passing |
| Alma | Passing |
| Oracle | Passing |

42 changes: 42 additions & 0 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

default_memory = '4096';
default_cpus = 2;

machines = {
'alma-8' => {'memory' => default_memory, 'cpus' => default_cpus, 'ip' => '22', 'box' => 'almalinux/8', 'provision' => 'rhel-8-based.sh'},
'rhel-8' => {'memory' => default_memory, 'cpus' => default_cpus, 'ip' => '23', 'box' => 'generic/rhel8', 'provision' => 'rhel-8.sh'},
'oracle-8' => {'memory' => default_memory, 'cpus' => default_cpus, 'ip' => '24', 'box' => 'generic/oracle8', 'provision' => 'rhel-8-based.sh'},
'rocky-8' => {'memory' => default_memory, 'cpus' => default_cpus, 'ip' => '25', 'box' => 'generic/rocky8', 'provision' => 'rhel-8-based.sh'},
#'rocky-9' => {'memory' => default_memory, 'cpus' => default_cpus, 'ip' => '30', 'box' => 'rockylinux/9', 'provision' => 'rhel-based.sh'}, # Not implemented yet.
}

specified_machines = ENV['MACHINES'].to_s.split(',')

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

config.vm.box_check_update = false

machines.each do |name, conf|
next unless specified_machines.empty? || specified_machines.include?(name)

config.vm.define "#{name}" do |m|
m.vm.box = "#{conf['box']}"
m.vm.network 'private_network', ip: "192.168.20.#{conf['ip']}", name: "external_network"
m.vm.network 'private_network', ip: "192.168.30.10", name: "management_network"
m.vm.hostname = "cloyster.hpc"
m.vm.provider 'libvirt' do |lv|
lv.memory = conf['memory']
lv.cpus = conf['cpus']
lv.host = 'localhost'
lv.driver = 'kvm'
lv.uri = 'qemu:///system'
#lv.connect_via_ssh = false
lv.username = 'root' # Replace with your username
end
m.vm.provision :shell, path: "provision/#{conf['provision']}"
m.vm.synced_folder '.', '/vagrant', type: "rsync"
end
end
end
87 changes: 87 additions & 0 deletions vagrant/include/alma-8.answerfile.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Example answerfile model to use with Cloyster.

[information]
cluster_name=cloyster
company_name=cloyster-enterprises
administrator_email[email protected]

[time]
timezone=America/Sao_Paulo
timeserver=0.br.pool.ntp.org
locale=en_US.utf8

[hostname]
hostname=cloyster
domain_name=cluster.example.com

# Cloyster must have an external network
[network_external]
interface=eth1
#ip_address=172.16.144.0
#subnet_mask=255.255.255.0
#gateway=192.168.122.1
domain_name=cluster.external.example.com
#nameservers=146.164.36.7,146.164.36.15
#mac_address=de:ad:be:ff:00:00

# Cloyster must have an management network
[network_management]
interface=eth2
ip_address=172.26.30.10
subnet_mask=255.255.255.0
#gateway=172.26.0.1
domain_name=cluster.management.example.com
#nameservers=172.26.0.1
#mac_address=de:ad:be:ff:00:01

# Use the network_application if using a Infiniband
# Must inform all options if enabled
#[network_application]
#interface=ib0
#ip_address=172.26.0.0
#subnet_mask=255.255.0.0
#gateway=0.0.0.0
#domain_name=cloysterhpc.example
#nameservers=0.0.0.0,0.0.0.0
#mac_address=de:ad:be:ff:00:01

[system]
# Full path to the disk image
disk_image=/opt/iso/AlmaLinux-8.8-x86_64-dvd.iso
# Supported distros: rhel, ol, rocky
distro=almalinux
version=8.8
kernel=4.18.0-513.5.1.el8_9.x86_64

# Generic. If a node.XX section does not have one of these options, they are obtained here.
# Comment if you don't want to use generic options. In this case, you MUST fulfill all the node.XX options.
# These options MUST exist, either specifically in the node.XX sections or in the generic section [node].
[node]
prefix=n
padding=2
node_start_ip=172.26.0.1
node_root_password=pwd
sockets=1
cores_per_socket=1
threads_per_core=1
bmc_username=admin
bmc_password=admin
bmc_serialport=0
bmc_serialspeed=9600

# Uncomment if you want to override any of the [node] options.
# These options MUST exist, either specifically in the node.XX sections or in the generic section [node].
[node.1]
# Hostname is optional. If commented, you MUST specify "prefix" and "padding".
hostname=foo
mac_address=ca:fe:de:ad:be:ef
#node_start_ip=172.26.0.1
#node_root_password=pwd
#sockets=1
#cores_per_socket=1
#threads_per_core=1
bmc_address=10.0.0.2
#bmc_username=admin
#bmc_password=admin
#bmc_serialport=0
#bmc_serialspeed=9600
87 changes: 87 additions & 0 deletions vagrant/include/oracle-8.answerfile.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Example answerfile model to use with Cloyster.

[information]
cluster_name=cloyster
company_name=cloyster-enterprises
administrator_email[email protected]

[time]
timezone=America/Sao_Paulo
timeserver=0.br.pool.ntp.org
locale=en_US.utf8

[hostname]
hostname=cloyster
domain_name=cluster.example.com

# Cloyster must have an external network
[network_external]
interface=eth1
#ip_address=172.16.144.0
#subnet_mask=255.255.255.0
#gateway=192.168.122.1
domain_name=cluster.external.example.com
#nameservers=146.164.36.7,146.164.36.15
#mac_address=de:ad:be:ff:00:00

# Cloyster must have an management network
[network_management]
interface=eth2
ip_address=172.26.30.10
subnet_mask=255.255.255.0
#gateway=172.26.0.1
domain_name=cluster.management.example.com
#nameservers=172.26.0.1
#mac_address=de:ad:be:ff:00:01

# Use the network_application if using a Infiniband
# Must inform all options if enabled
#[network_application]
#interface=ib0
#ip_address=172.26.0.0
#subnet_mask=255.255.0.0
#gateway=0.0.0.0
#domain_name=cloysterhpc.example
#nameservers=0.0.0.0,0.0.0.0
#mac_address=de:ad:be:ff:00:01

[system]
# Full path to the disk image
disk_image=/opt/iso/OracleLinux-R8-U8-x86_64-dvd.iso
# Supported distros: rhel, ol, rocky
distro=ol
version=8.8
kernel=4.18.0-513.5.1.el8_9.x86_64

# Generic. If a node.XX section does not have one of these options, they are obtained here.
# Comment if you don't want to use generic options. In this case, you MUST fulfill all the node.XX options.
# These options MUST exist, either specifically in the node.XX sections or in the generic section [node].
[node]
prefix=n
padding=2
node_start_ip=172.26.0.1
node_root_password=pwd
sockets=1
cores_per_socket=1
threads_per_core=1
bmc_username=admin
bmc_password=admin
bmc_serialport=0
bmc_serialspeed=9600

# Uncomment if you want to override any of the [node] options.
# These options MUST exist, either specifically in the node.XX sections or in the generic section [node].
[node.1]
# Hostname is optional. If commented, you MUST specify "prefix" and "padding".
hostname=foo
mac_address=ca:fe:de:ad:be:ef
#node_start_ip=172.26.0.1
#node_root_password=pwd
#sockets=1
#cores_per_socket=1
#threads_per_core=1
bmc_address=10.0.0.2
#bmc_username=admin
#bmc_password=admin
#bmc_serialport=0
#bmc_serialspeed=9600
87 changes: 87 additions & 0 deletions vagrant/include/rhel-8.answerfile.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Example answerfile model to use with Cloyster.

[information]
cluster_name=cloyster
company_name=cloyster-enterprises
administrator_email[email protected]

[time]
timezone=America/Sao_Paulo
timeserver=0.br.pool.ntp.org
locale=en_US.utf8

[hostname]
hostname=cloyster
domain_name=cluster.example.com

# Cloyster must have an external network
[network_external]
interface=eth1
#ip_address=172.16.144.0
#subnet_mask=255.255.255.0
#gateway=192.168.122.1
domain_name=cluster.external.example.com
#nameservers=146.164.36.7,146.164.36.15
#mac_address=de:ad:be:ff:00:00

# Cloyster must have an management network
[network_management]
interface=eth2
ip_address=172.26.30.10
subnet_mask=255.255.255.0
#gateway=172.26.0.1
domain_name=cluster.management.example.com
#nameservers=172.26.0.1
#mac_address=de:ad:be:ff:00:01

# Use the network_application if using a Infiniband
# Must inform all options if enabled
#[network_application]
#interface=ib0
#ip_address=172.26.0.0
#subnet_mask=255.255.0.0
#gateway=0.0.0.0
#domain_name=cloysterhpc.example
#nameservers=0.0.0.0,0.0.0.0
#mac_address=de:ad:be:ff:00:01

[system]
# Full path to the disk image
disk_image=/opt/iso/rhel-8.8-x86_64-dvd.iso
# Supported distros: rhel, ol, rocky
distro=rhel
version=8.8
kernel=4.18.0-513.5.1.el8_9.x86_64

# Generic. If a node.XX section does not have one of these options, they are obtained here.
# Comment if you don't want to use generic options. In this case, you MUST fulfill all the node.XX options.
# These options MUST exist, either specifically in the node.XX sections or in the generic section [node].
[node]
prefix=n
padding=2
node_start_ip=172.26.0.1
node_root_password=pwd
sockets=1
cores_per_socket=1
threads_per_core=1
bmc_username=admin
bmc_password=admin
bmc_serialport=0
bmc_serialspeed=9600

# Uncomment if you want to override any of the [node] options.
# These options MUST exist, either specifically in the node.XX sections or in the generic section [node].
[node.1]
# Hostname is optional. If commented, you MUST specify "prefix" and "padding".
hostname=foo
mac_address=ca:fe:de:ad:be:ef
#node_start_ip=172.26.0.1
#node_root_password=pwd
#sockets=1
#cores_per_socket=1
#threads_per_core=1
bmc_address=10.0.0.2
#bmc_username=admin
#bmc_password=admin
#bmc_serialport=0
#bmc_serialspeed=9600
Loading

0 comments on commit 7a70107

Please sign in to comment.