Replace multipass with vagrant

This commit is contained in:
Khue Doan 2021-02-21 09:55:26 +07:00
parent a84928ec60
commit 1fb9666e33
7 changed files with 30 additions and 35 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vagrant/
.venv/
build/

View File

@ -33,7 +33,7 @@ For the controller (to run Ansible, stateless PXE server, Terraform...):
- `python3`
- Docker with `host` networking driver (which means [only Docker on Linux hosts](https://docs.docker.com/network/host/))
- `terraform` (0.14.x)
- `multipass` (optional, to create a [test environment](./test) locally)
- `vagrant` (optional, to create a local [test environment](./test))
For bare metal nodes:

View File

@ -1,24 +1,9 @@
.POSIX:
NAME = metal
default: init metal infra
init:
for count in 0 1; do \
multipass list | grep $(NAME)$$count \
|| multipass launch \
--cpus 2 \
--mem 4G \
--disk 64G \
--cloud-init ./multipass-cloud-init.yaml \
--name $(NAME)$$count \
release:20.10; \
multipass exec $(NAME)$$count -- sed -i "$$ a\$(shell cat ~/.ssh/id_rsa.pub)" /home/ubuntu/.ssh/authorized_keys; \
done
shell:
multipass shell $(NAME)
vagrant up
metal:
python3 -m venv .venv \
@ -31,10 +16,7 @@ infra:
echo infra
stop:
multipass stop $(NAME)
vagrant halt
clean:
for count in 0 1; do \
multipass delete $(NAME)$$count; \
done
multipass purge
vagrant destroy -f

View File

@ -1,6 +1,6 @@
# Test
Create a test environment in a Multipass VM (requires `multipass`)
Create a quick and dirty local test environment (requires `vagrant`)
```sh
make

22
test/Vagrantfile vendored Normal file
View File

@ -0,0 +1,22 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian/buster64"
(0..1).each do |i|
config.vm.define "metal#{i}" do |metal|
metal.vm.network "private_network", ip: "192.168.50.#{i+2}"
end
end
config.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = "4096"
end
config.vbguest.auto_update = false
config.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "/tmp/id_rsa.pub"
config.vm.provision "shell", inline: <<-SHELL
cat /tmp/id_rsa.pub >> /home/vagrant/.ssh/authorized_keys
SHELL
end

View File

@ -1,3 +1,3 @@
[metal]
metal0 ansible_host=192.168.64.6 ansible_user=ubuntu
metal1 ansible_host=192.168.64.7 ansible_user=ubuntu
metal0 ansible_host=192.168.50.2 ansible_user=vagrant
metal1 ansible_host=192.168.50.3 ansible_user=vagrant

View File

@ -1,10 +0,0 @@
#cloud-config
runcmd:
- apt-get update
- curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -
- apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
- curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
- apt-add-repository "deb https://apt.kubernetes.io/ kubernetes-xenial main"
- apt-get update
- apt-get install -y kubectl terraform