--- - name: Disable IPv6 via sysctl sysctl: name: "{{ item }}" value: '1' sysctl_set: yes state: present reload: yes loop: - net.ipv6.conf.all.disable_ipv6 - net.ipv6.conf.default.disable_ipv6 - net.ipv6.conf.lo.disable_ipv6 - name: Disable IPv6 in GRUB lineinfile: path: /etc/default/grub regexp: '^GRUB_CMDLINE_LINUX=' line: 'GRUB_CMDLINE_LINUX="ipv6.disable=1"' - name: Update GRUB command: update-grub when: ansible_distribution == "Ubuntu" - name: Update initramfs command: update-initramfs -u when: ansible_distribution == "Ubuntu"