Skip to content

Instantly share code, notes, and snippets.

@tekei
Created February 27, 2016 14:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tekei/02a90624614fccdac32e to your computer and use it in GitHub Desktop.
Save tekei/02a90624614fccdac32e to your computer and use it in GitHub Desktop.
ansible : (ubuntu) disable IPv6
---
- hosts: localhost
connection: local
become: yes
tasks:
- name: remove ipv6 hosts entry
shell: sed -i -e '/::/d' -e '/IPv6/d' /etc/hosts
- name: find ipv6 kernel parameter
shell: sysctl --all | egrep '^net.ipv6\..*disable' | awk '{print $1}'
register: ipv6_sysctl_list
changed_when: false
always_run: yes
- name: add ipv6 kernel parameter
sysctl: name={{ item }} value=1
with_items: ipv6_sysctl_list.stdout_lines
@scicco
Copy link

scicco commented Apr 3, 2017

this worked for me (as an included sub-task):

---
  - name: remove ipv6 hosts entry
    shell: sed -i -e '/::/d' -e '/IPv6/d' /etc/hosts
    become: yes
  - 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
  - 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