Skip to content

Commit

Permalink
initial stab at manually configuring interface
Browse files Browse the repository at this point in the history
doing this as hashicorp/vagrant#12762 mentioned that Fedora 36 and later doesn't use ifconfig-rh anymore which is why we're getting dhcp addreses
  • Loading branch information
xinkecf35 committed Nov 17, 2024
1 parent 6ab3805 commit 02a0356
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Vagrant.configure("2") do |config|

hostname = "vagrant-k8s-control"
bridged_ip = "10.211.55.10"
private_ip = "10.255.0.10"
private_ip = "10.37.132.10"
control.vm.hostname = hostname

# Configure general private networking
control.vm.network "private_network", ip: private_ip
control.vm.network "private_network", ip: private_ip, auto_config: false
control.vm.network "forwarded_port", guest: 6443, host: 6443

# Hyper-V Specific Configuration
Expand Down Expand Up @@ -73,7 +73,8 @@ Vagrant.configure("2") do |config|
ansible.playbook = "ansible/k8s-control.yml"
ansible.extra_vars = {
project_kubeconfig_path: project_kubeconfig_path,
advertise_ip: private_ip
advertise_ip: private_ip,
private_ip: private_ip
}
end
end
Expand All @@ -87,10 +88,11 @@ Vagrant.configure("2") do |config|
end

hostname = "vagrant-k8s-worker-#{i}"
private_ip = "10.37.132.#{i + 10}"
worker.vm.hostname = hostname

# Configure general private networking
worker.vm.network "private_network", ip: "10.255.0.#{i + 10}"
worker.vm.network "private_network", ip: private_ip, auto_config: false

# Hyper-V Specific Configuration
worker.vm.provider "hyperv" do |h, override|
Expand Down Expand Up @@ -122,7 +124,8 @@ Vagrant.configure("2") do |config|
ansible.playbook = "ansible/k8s-worker.yml"
ansible.limit = (1..WORKER_COUNT).to_a.map { |i| "worker-#{i}" }
ansible.extra_vars = {
project_kubeconfig_path: project_kubeconfig_path
project_kubeconfig_path: project_kubeconfig_path,
private_ip: private_ip
}
end
end
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/common/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
private_ip: '10.37.132.254'
kube_major_version: '1.30'
cri_o_major_version: '1.30'
14 changes: 14 additions & 0 deletions ansible/roles/common/tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
---
- name: Configure private interface eth1 with static ip
block:
- name: Template and copy NetPlan Config
ansible.builtin.template:
src: netplan.yaml.j2
dest: /etc/netplan/99-private-vagrant-interface.yaml
mode: "0644"
owner: root
group: root
- name: Apply new interface config
ansible.builtin.command:
netplan apply
changed_when: true

# taken from https://github.com/freehck/ansible-role-disable-swap/blob/master/tasks/main.yml
# and https://github.com/geerlingguy/ansible-role-swap/blob/master/tasks/disable.yml
- name: Disable swap immediately
Expand Down
14 changes: 14 additions & 0 deletions ansible/roles/common/tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
---
- name: Configure private interface eth1 with static ip
block:
- name: Template and copy NetworkManager Keyfile
ansible.builtin.template:
src: nm-keyfile.conf.js
dest: /etc/NetworkManager/system-connections/private-vagrant-interface.nmconnection
mode: "0644"
owner: root
group: root
- name: Apply new interface config
ansible.builtin.command:
nmcli conn reload
changed_when: true

- name: Update Packages
ansible.builtin.dnf:
name: "*"
Expand Down
7 changes: 7 additions & 0 deletions ansible/roles/common/templates/netplan.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
network:
version: 2
renderer: networkd
ethernets:
eth1:
addresses:
- {{ private_ip }}/24
12 changes: 12 additions & 0 deletions ansible/roles/common/templates/nm-keyfile.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[connection]
id=Private Vagrant Interface eth1
uuid={{ 1234567890 | random | to_uuid }}
type=802-3-ethernet
interface-name=eth1

[802-3-ethernet]

[ipv4]
address1={{ private_ip }}/24
method=manual

2 changes: 1 addition & 1 deletion ansible/roles/control/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
advertise_ip: '10.255.0.10'
advertise_ip: '10.37.132.10'
project_kubeconfig_path: "{{ playbook_dir }}/../.kube/default"

0 comments on commit 02a0356

Please sign in to comment.