feat(DHCP): Reconfigure IP addesses and ansible inventory

Ansible inventory can now be static with static IPs provisioned by Vangard.
The documentation has also been updated to include how the configuration of the ingress node can be node from any VPS provider.
This commit is contained in:
Tanguy Herbron 2023-10-30 16:54:48 +01:00
parent 9f16da3198
commit 6f57f55b97
6 changed files with 122 additions and 13 deletions

View File

@ -1,18 +1,18 @@
install:
install_vb:
vagrant up
cd ansible && $(MAKE) install
cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/lab.yml -i ../inventory/outsider.yml init.yml --extra-vars "enable_setup=true enable_wireguard=true enable_k3s=true"
make get_k3s_credentials
k3s_reset:
cd ansible && $(MAKE) uninstall
cd ansible && $(MAKE) k3s
get_k3s_credentials
cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/lab.yml -i ../inventory/outsider.yml k3s-ansible/reset.yml
cd ansible && ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ../inventory/lab.yml -i ../inventory/outsider.yml init.yml --extra-vars "enable_setup=true enable_wireguard=true enable_k3s=true"
make get_k3s_credentials
destroy:
vagrant destroy -f
get_k3s_credentials:
vagrant ssh -c "sudo cat /home/creator/.kube/config" hb-wide-1 > ~/.kube/config-halia
sed -i 's/10.20.*:/10.10.0.101:/g' ~/.kube/config-halia
sed -i 's/10.20.*:/192.168.56.101:/g' ~/.kube/config-halia
kube-merge
kubectl get nodes --context halia

View File

@ -5,6 +5,13 @@
- ansible
- vagrant-scp
## Setup
For ingress node connected to the internet, I recommend using a VPS of either choice, acting as the public input to the cluster.
To do so, complete the IP in the `inventory/outsider.yml` file.
This VPS needs to be pre-configured with [this script](https://git.halis.io/athens-school/ISO-repository/raw/branch/master/quick-installer.sh).
## Script
- Detect WSL or Linux
- Detect default network interface

14
Vagrantfile vendored
View File

@ -1,7 +1,7 @@
Vagrant.configure("2") do |config|
config.vm.box = "debian/bullseye64"
config.vm.synced_folder '.', '/vagrant', disabled: true # Allows WSL call to work within WSL filesystem
config.vm.provision :shell, path: "https://git.halis.io/athens-school/ISO-repository/raw/branch/master/quick-installer.sh", run: "always"
config.vm.provision :shell, path: "https://git.halis.io/athens-school/ISO-repository/raw/branch/master/quick-installer.sh", run: "once"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
@ -9,17 +9,17 @@ Vagrant.configure("2") do |config|
end
boxes = [
{ :name => "hb-slim-1", :mac => "080027117BED"},
{ :name => "hb-slim-2", :mac => "0800276FAEEC"},
{ :name => "hb-slim-3", :mac => "080027202C0B"},
{ :name => "hb-wide-1", :mac => "080027F3F85F", :cpus => 2, :memory => 4096},
{ :name => "hb-wide-2", :mac => "080027A74FDB", :cpus => 2, :memory => 4096},
{ :name => "hb-slim-1", :ip => "192.168.56.11"},
{ :name => "hb-slim-2", :ip => "192.168.56.12"},
{ :name => "hb-slim-3", :ip => "192.168.56.13"},
{ :name => "hb-wide-1", :ip => "192.168.56.101", :cpus => 2, :memory => 4096},
{ :name => "hb-wide-2", :ip => "192.168.56.102", :cpus => 2, :memory => 4096},
]
boxes.each do |opts|
config.vm.define opts[:name] do |box|
box.vm.hostname = opts[:name]
box.vm.network "public_network", bridge: "Intel(R) I211 Gigabit Network Connection", :mac => opts[:mac]
box.vm.network "private_network", ip: opts[:ip]
box.vm.provider "virtualbox" do |v|
if !opts[:memory].nil?
v.memory = opts[:memory]

1
inventory/group_vars Symbolic link
View File

@ -0,0 +1 @@
../ansible/inventory/group_vars/

71
inventory/lab.yml Normal file
View File

@ -0,0 +1,71 @@
all:
hosts:
hb-wide-1:
ansible_host: 192.168.56.101
is_nas: false
hostname: hb-wide-1
wireguard_ip: 10.20.0.1
k3s_label:
- type=worker
- size=wide
hb-wide-2:
ansible_host: 192.168.56.102
is_nas: false
hostname: hb-wide-2
wireguard_ip: 10.20.0.2
k3s_label:
- type=worker
- size=wide
hb-slim-1:
ansible_host: 192.168.56.11
is_nas: false
hostname: hb-slim-1
wireguard_ip: 10.20.0.11
k3s_label:
- type=worker
- size=slim
hb-slim-2:
ansible_host: 192.168.56.12
is_nas: false
hostname: hb-slim-2
wireguard_ip: 10.20.0.12
k3s_label:
- type=worker
- size=slim
hb-slim-3:
ansible_host: 192.168.56.13
is_nas: false
hostname: hb-slim-3
wireguard_ip: 10.20.0.13
k3s_label:
- type=worker
- size=slim
children:
master:
hosts:
hb-wide-1:
node:
hosts:
hb-wide-2:
hb-slim-1:
hb-slim-2:
hb-slim-3:
etcd_cluster:
hosts:
hb-wide-1:
hb-wide-2:
hb-slim-1:
hb-slim-2:
hb-slim-3:
k3s_cluster:
children:
master:
node:
vars:
ansible_ssh_private_key_file: ~/.ssh/creator
ansible_user: creator
ansible_become_password: aberation
ansible_ssh_port: 22
ufw_enabled: false
wireguard_port: 51820
wireguard_mask_bits: 8

30
inventory/outsider.yml Normal file
View File

@ -0,0 +1,30 @@
all:
hosts:
outsider:
ansible_host:
is_nas: false
hostname: outsider
wireguard_ip: 10.20.0.254
k3s_label:
- type=outbound
children:
node:
hosts:
outsider:
etcd_cluster:
hosts:
outsider:
replica:
hosts:
outsider:
k3s_cluster:
children:
node:
vars:
ansible_ssh_private_key_file: ~/.ssh/creator
ansible_user: creator
ansible_become_password: aberation
ansible_ssh_port: 22
ufw_enabled: false
wireguard_port: 51820
wireguard_mask_bits: 8