diff --git a/ansible/files/magic_router_netplan.yaml b/ansible/files/magic_router_netplan.yaml new file mode 100644 index 0000000..e8e453f --- /dev/null +++ b/ansible/files/magic_router_netplan.yaml @@ -0,0 +1,32 @@ +network: + version: 2 + ethernets: + + # cloud + enp1s0f0: + dhcp4: false + dhcp6: false + gateway4: 192.168.110.1 + addresses: + - "192.168.110.10/24" + + # edge-1 + enp1s0f1: + dhcp4: false + dhcp6: false + addresses: + - "192.168.111.10/24" + + # edge-2 + enp1s0f2: + dhcp4: false + dhcp6: false + addresses: + - "192.168.112.10/24" + + # site + enp1s0f3: + dhcp4: false + dhcp6: false + addresses: + - "192.168.113.10/24" diff --git a/ansible/inventory.yaml b/ansible/inventory.yaml index fc1a7c0..a91f6c1 100644 --- a/ansible/inventory.yaml +++ b/ansible/inventory.yaml @@ -13,7 +13,6 @@ cloud-1: cloud-cluster-1-worker-1: cloud-cluster-1-worker-2: - edge-1: vars: magic_router_ip: 192.168.111.10 @@ -56,9 +55,21 @@ site-1: hosts: site-emulator-1: -all: +networking: + vars: + ansible_become: true + ansible_user: ubuntu + hosts: + magic-router: + +kubernetes: children: cloud-1: edge-1: edge-2: + +all: + children: + networking: + kubernetes: site-1: diff --git a/ansible/prepare.yaml b/ansible/prepare.yaml index 2156056..62b78d5 100644 --- a/ansible/prepare.yaml +++ b/ansible/prepare.yaml @@ -12,6 +12,10 @@ state: restarted tasks: + + - name: "fix dns" + import_tasks: tasks/fix-dns-resolution.yaml + - name: "do apt stuff" import_tasks: tasks/apt.yaml @@ -24,8 +28,9 @@ - name: "clean motd" import_tasks: tasks/clean-motd.yaml - - name: "fix dns" - import_tasks: tasks/fix-dns-resolution.yaml - - name: "setup static route" - import_tasks: tasks/setup-static-route.yaml \ No newline at end of file + import_tasks: tasks/setup-static-route.yaml + + - name: "setup router stuff" + import_tasks: tasks/enable-routing.yaml + when: ansible_host == "magic-router" \ No newline at end of file diff --git a/ansible/tasks/apt.yaml b/ansible/tasks/apt.yaml index 32d9fcb..2650dd4 100644 --- a/ansible/tasks/apt.yaml +++ b/ansible/tasks/apt.yaml @@ -6,6 +6,7 @@ - name: "Install my favourite applications" apt: + update_cache: true state: present name: - tmux diff --git a/ansible/tasks/enable-routing.yaml b/ansible/tasks/enable-routing.yaml new file mode 100644 index 0000000..a747956 --- /dev/null +++ b/ansible/tasks/enable-routing.yaml @@ -0,0 +1,6 @@ +- name: enable routing in sysctl config + ansible.posix.sysctl: + name: net.ipv4.ip_forward + value: 1 + state: present + reload: true \ No newline at end of file diff --git a/ansible/tasks/setup-static-route.yaml b/ansible/tasks/setup-static-route.yaml index 5cc80ad..3f7d019 100644 --- a/ansible/tasks/setup-static-route.yaml +++ b/ansible/tasks/setup-static-route.yaml @@ -7,4 +7,12 @@ template: src: templates/netplan.yaml dest: /etc/netplan/00-static.yaml - notify: netplanapply \ No newline at end of file + notify: netplanapply + when: ansible_host != "magic-router" + +- name: "install static config for magic router" + copy: + src: files/magic_router_netplan.yaml + dest: /etc/netplan/00-static.yaml + notify: netplanapply + when: ansible_host == "magic-router" \ No newline at end of file