--- # Playbook to fix private network configuration on servers # This fixes the netplan configuration to properly enable DHCP # on the private network interface (enp7s0) - name: Fix private network configuration hosts: all gather_facts: no become: yes tasks: - name: Check if server is reachable ansible.builtin.wait_for_connection: timeout: 5 register: connection_test ignore_errors: yes - name: Create corrected netplan configuration for private network ansible.builtin.copy: dest: /etc/netplan/60-private-network.yaml mode: '0600' content: | network: version: 2 ethernets: enp7s0: dhcp4: true dhcp4-overrides: use-routes: false routes: - to: default via: 10.0.0.1 when: connection_test is succeeded - name: Apply netplan configuration ansible.builtin.command: netplan apply when: connection_test is succeeded register: netplan_result - name: Show netplan result ansible.builtin.debug: msg: "Netplan applied successfully on {{ inventory_hostname }}" when: connection_test is succeeded and netplan_result is succeeded - name: Wait for network to stabilize ansible.builtin.wait_for_connection: timeout: 10 when: connection_test is succeeded