From a7b16cb3bc18f6466a6f4ed299608588728cdc5f Mon Sep 17 00:00:00 2001 From: vincent Date: Sun, 13 Feb 2022 09:01:05 +0100 Subject: [PATCH] add disable ipv6 --- defaults/main.yml | 2 ++ handlers/main.yml | 3 +++ tasks/main.yml | 2 +- tasks/tasks.sysctl.yml | 10 ++++++++++ templates/40-ipv6.j2 | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tasks/tasks.sysctl.yml create mode 100644 templates/40-ipv6.j2 diff --git a/defaults/main.yml b/defaults/main.yml index 454ee59..ce436b9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -117,3 +117,5 @@ hosts_entries: [] # Custom host file snippets to be added hosts_file_snippets: [] + +system_ipV6_disable: true diff --git a/handlers/main.yml b/handlers/main.yml index d03924c..6643765 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -12,3 +12,6 @@ - name: Restart sshd service: name=sshd state=restarted become: yes + +- name: restart_sysctl + service: name=systemd-sysctl state=restarted diff --git a/tasks/main.yml b/tasks/main.yml index dd9cde1..2a06ea6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,6 +1,6 @@ ---- #- include_tasks: hostname.yml - include_tasks: hosts.yml +- include_tasks: tasks.sysctl.yml - include_tasks: dhcpcd.yml - include_tasks: hostname.yml - include_tasks: locales.yml diff --git a/tasks/tasks.sysctl.yml b/tasks/tasks.sysctl.yml new file mode 100644 index 0000000..109d87b --- /dev/null +++ b/tasks/tasks.sysctl.yml @@ -0,0 +1,10 @@ +--- +- name: disable IPV6 + template: + src: 40-ipv6.j2 + dest: /etc/sysctl.d/40-ipv6.conf + owner: root + group: root + mode: 0644 + notify: restart_sysctl + become: True diff --git a/templates/40-ipv6.j2 b/templates/40-ipv6.j2 new file mode 100644 index 0000000..813b10b --- /dev/null +++ b/templates/40-ipv6.j2 @@ -0,0 +1 @@ +net.ipv6.conf.all.disable_ipv6 = {% if system_ipV6_disable %} 1 {% else %} 0 {% endif %}