ansible/roles/common/tasks/network.yaml

39 lines
1 KiB
YAML

---
- name: Install bridge-utils
ansible.builtin.apt:
name: bridge-utils
state: present
when: network_br
- name: Configure sysctl.conf
ansible.builtin.lineinfile:
path: /etc/sysctl.conf
regexp: "^#?{{ item.k }}"
line: "{{ item.k }}={{ item.v }} # Managed by Ansible"
with_items:
- { k: net.ipv4.ip_forward, v: "1" }
- { k: net.ipv6.conf.all.forwarding, v: "1" }
notify: reboot
when: network_br
- name: Make network interfaces really predictable
ansible.builtin.lineinfile:
path: /etc/default/grub
regexp: ^GRUB_CMDLINE_LINUX
line: 'GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" # Managed by Ansible'
notify:
- update grub
- reboot
when: network_br or network_dhcp or network_static
- name: Configure network interfaces
ansible.builtin.template:
src: network-interfaces
dest: /etc/network/interfaces
owner: root
group: root
mode: 0644
notify: reboot
when: network_br or network_dhcp or network_static
- ansible.builtin.meta: flush_handlers