feat: internet access to the private compute instances
This commit is contained in:
36
playbooks/configure_servers.yml
Normal file
36
playbooks/configure_servers.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
- name: Configure NAT
|
||||
hosts: servers
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Uninstall Hetzner Cloud Utils.
|
||||
ansible.builtin.apt:
|
||||
state: absent
|
||||
name: [hc-utils]
|
||||
|
||||
- name: Check if default route exists.
|
||||
ansible.builtin.command: ip route
|
||||
changed_when: "'default' in route_output.stdout"
|
||||
register: route_output
|
||||
notify:
|
||||
- Disable default IP route.
|
||||
|
||||
- name: Configure networking.
|
||||
ansible.builtin.blockinfile:
|
||||
path: /etc/network/interfaces
|
||||
marker: "# {mark} CONFIGURE NETWORKING"
|
||||
block: |
|
||||
auto enp7s0
|
||||
iface enp7s0 inet dhcp
|
||||
post-up ip route add default via 10.0.0.1
|
||||
dns-nameservers 8.8.8.8 1.1.1.1
|
||||
|
||||
- name: Restart networking module.
|
||||
ansible.builtin.systemd:
|
||||
state: restarted
|
||||
name: networking
|
||||
|
||||
handlers:
|
||||
- name: Disable default IP route.
|
||||
ansible.builtin.command:
|
||||
ip route del default
|
||||
changed_when: true
|
||||
Reference in New Issue
Block a user