Skip to content

Instantly share code, notes, and snippets.

@scicco
Forked from tekei/disable-ipv6.yml
Last active April 3, 2017 15:01
Show Gist options
  • Save scicco/1cddf534132cfbf445f562c8273f6c53 to your computer and use it in GitHub Desktop.
Save scicco/1cddf534132cfbf445f562c8273f6c53 to your computer and use it in GitHub Desktop.
ansible : (ubuntu) disable IPv6
---
- name: Remove ipv6 hosts entry
replace:
dest: /etc/hosts
regexp: '^.*::\d\t.+|.*IPv6.*$'
#backup: yes
become: yes
# TODO FIND A WAY TO ELIMINATE EMPTY ROWS INSIDE /etc/hosts file
- name: Find ipv6 kernel parameter
shell: sysctl --all | egrep '^net.ipv6\..*disable' | awk '{print $1}'
register: ipv6_sysctl_list
changed_when: false
check_mode: no
become: yes
- debug: var=ipv6_sysctl_list
- debug: var=ipv6_sysctl_list.stdout_lines
- name: Add ipv6 kernel parameter
sysctl: name={{ item }} value=1
with_items: "{{ ipv6_sysctl_list.stdout_lines }}"
become: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment