mirror of
https://github.com/khuedoan/homelab.git
synced 2025-07-04 15:27:52 +07:00
Replace multipass with vagrant
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
|
.vagrant/
|
||||||
.venv/
|
.venv/
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ For the controller (to run Ansible, stateless PXE server, Terraform...):
|
|||||||
- `python3`
|
- `python3`
|
||||||
- Docker with `host` networking driver (which means [only Docker on Linux hosts](https://docs.docker.com/network/host/))
|
- Docker with `host` networking driver (which means [only Docker on Linux hosts](https://docs.docker.com/network/host/))
|
||||||
- `terraform` (0.14.x)
|
- `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:
|
For bare metal nodes:
|
||||||
|
|
||||||
|
@ -1,24 +1,9 @@
|
|||||||
.POSIX:
|
.POSIX:
|
||||||
|
|
||||||
NAME = metal
|
|
||||||
|
|
||||||
default: init metal infra
|
default: init metal infra
|
||||||
|
|
||||||
init:
|
init:
|
||||||
for count in 0 1; do \
|
vagrant up
|
||||||
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)
|
|
||||||
|
|
||||||
metal:
|
metal:
|
||||||
python3 -m venv .venv \
|
python3 -m venv .venv \
|
||||||
@ -31,10 +16,7 @@ infra:
|
|||||||
echo infra
|
echo infra
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
multipass stop $(NAME)
|
vagrant halt
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
for count in 0 1; do \
|
vagrant destroy -f
|
||||||
multipass delete $(NAME)$$count; \
|
|
||||||
done
|
|
||||||
multipass purge
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Test
|
# Test
|
||||||
|
|
||||||
Create a test environment in a Multipass VM (requires `multipass`)
|
Create a quick and dirty local test environment (requires `vagrant`)
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make
|
make
|
||||||
|
22
test/Vagrantfile
vendored
Normal file
22
test/Vagrantfile
vendored
Normal 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
|
@ -1,3 +1,3 @@
|
|||||||
[metal]
|
[metal]
|
||||||
metal0 ansible_host=192.168.64.6 ansible_user=ubuntu
|
metal0 ansible_host=192.168.50.2 ansible_user=vagrant
|
||||||
metal1 ansible_host=192.168.64.7 ansible_user=ubuntu
|
metal1 ansible_host=192.168.50.3 ansible_user=vagrant
|
||||||
|
@ -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
|
|
Reference in New Issue
Block a user