Преглед изворни кода

Add an option to enable/disable IPv6

Emmanuel Bouthenot пре 7 година
родитељ
комит
e8db11199b

+ 2 - 0
roles/common/defaults/main.yml

@@ -15,6 +15,8 @@ timezone_city: 'Paris'
 hosts_fqdn: True
 hosts_static_lookup: Null
 
+ipv6_disabled: False
+
 debian_mirror: 'http://httpredir.debian.org/debian'
 
 apt_keys: Null

+ 3 - 0
roles/common/tasks/base.yml

@@ -98,9 +98,12 @@
 - name: 'Install kernel configuration (proc)'
   template: src=kernel/sysctl.d/{{ item }}.j2 dest=/etc/sysctl.d/{{ item }} owner=root group=root mode=0644
   with_items:
+      - '05-ipv6.conf'
       - '10-increase-file-descriptors.conf'
   notify:
     - 'Apply kernel configuration (proc)'
+  tags:
+      - 'ipv6'
 
 - name: 'Create sysfs configuration directory - /etc/sysfs.d'
   file: path=/etc/sysfs.d state=directory owner=root group=root mode=0755

+ 15 - 0
roles/common/templates/kernel/sysctl.d/05-ipv6.conf.j2

@@ -0,0 +1,15 @@
+#
+# sysfs: ipv6 settings / tuning
+#
+
+{% if ipv6_disabled %}
+net.ipv6.conf.all.disable_ipv6 = 1
+net.ipv6.conf.default.disable_ipv6 = 1
+{% else %}
+net.ipv6.conf.all.disable_ipv6 = 0
+net.ipv6.conf.default.disable_ipv6 = 0
+{% endif %}
+
+# Keep ipv6 enabled for loopback
+net.ipv6.conf.lo.disable_ipv6 = 0
+