diff --git a/Vagrantfile b/Vagrantfile index 7adaf4b..4828c67 100755 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 @@ -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 @@ -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| @@ -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 diff --git a/ansible/roles/common/defaults/main.yml b/ansible/roles/common/defaults/main.yml index e0b3966..816c7d3 100755 --- a/ansible/roles/common/defaults/main.yml +++ b/ansible/roles/common/defaults/main.yml @@ -1,3 +1,4 @@ --- +private_ip: '10.37.132.254' kube_major_version: '1.30' cri_o_major_version: '1.30' diff --git a/ansible/roles/common/tasks/debian.yml b/ansible/roles/common/tasks/debian.yml index a9bb82a..722570a 100644 --- a/ansible/roles/common/tasks/debian.yml +++ b/ansible/roles/common/tasks/debian.yml @@ -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 diff --git a/ansible/roles/common/tasks/redhat.yml b/ansible/roles/common/tasks/redhat.yml index 5fd663d..6ee6025 100644 --- a/ansible/roles/common/tasks/redhat.yml +++ b/ansible/roles/common/tasks/redhat.yml @@ -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: "*" diff --git a/ansible/roles/common/templates/netplan.yaml.j2 b/ansible/roles/common/templates/netplan.yaml.j2 new file mode 100644 index 0000000..ad60447 --- /dev/null +++ b/ansible/roles/common/templates/netplan.yaml.j2 @@ -0,0 +1,7 @@ +network: + version: 2 + renderer: networkd + ethernets: + eth1: + addresses: + - {{ private_ip }}/24 \ No newline at end of file diff --git a/ansible/roles/common/templates/nm-keyfile.conf.j2 b/ansible/roles/common/templates/nm-keyfile.conf.j2 new file mode 100644 index 0000000..8ebec5a --- /dev/null +++ b/ansible/roles/common/templates/nm-keyfile.conf.j2 @@ -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 + diff --git a/ansible/roles/control/defaults/main.yml b/ansible/roles/control/defaults/main.yml index f1115a6..4b85d35 100755 --- a/ansible/roles/control/defaults/main.yml +++ b/ansible/roles/control/defaults/main.yml @@ -1,3 +1,3 @@ --- -advertise_ip: '10.255.0.10' +advertise_ip: '10.37.132.10' project_kubeconfig_path: "{{ playbook_dir }}/../.kube/default"